Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
c542b6be
Commit
c542b6be
authored
May 29, 2018
by
Yecheng Fu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove mount.GetMountRefs in favor of mounter.GetMountRefs
parent
27c327cd
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
23 additions
and
78 deletions
+23
-78
mount_linux.go
pkg/util/mount/mount_linux.go
+1
-36
mount_linux_test.go
pkg/util/mount/mount_linux_test.go
+1
-1
mount_unsupported.go
pkg/util/mount/mount_unsupported.go
+0
-6
mount_windows.go
pkg/util/mount/mount_windows.go
+3
-13
mount_windows_test.go
pkg/util/mount/mount_windows_test.go
+1
-1
attacher.go
pkg/volume/aws_ebs/attacher.go
+1
-1
azure_dd.go
pkg/volume/azure_dd/azure_dd.go
+1
-2
attacher.go
pkg/volume/cinder/attacher.go
+1
-1
cinder.go
pkg/volume/cinder/cinder.go
+2
-2
BUILD
pkg/volume/csi/BUILD
+0
-1
csi_plugin.go
pkg/volume/csi/csi_plugin.go
+1
-2
attacher.go
pkg/volume/fc/attacher.go
+1
-1
fc.go
pkg/volume/fc/fc.go
+1
-1
fc_test.go
pkg/volume/fc/fc_test.go
+2
-2
plugin.go
pkg/volume/flexvolume/plugin.go
+1
-1
attacher.go
pkg/volume/gce_pd/attacher.go
+1
-2
attacher.go
pkg/volume/iscsi/attacher.go
+1
-1
iscsi.go
pkg/volume/iscsi/iscsi.go
+1
-1
attacher.go
pkg/volume/photon_pd/attacher.go
+1
-1
attacher.go
pkg/volume/rbd/attacher.go
+1
-1
attacher.go
pkg/volume/vsphere_volume/attacher.go
+1
-1
No files found.
pkg/util/mount/mount_linux.go
View file @
c542b6be
...
...
@@ -155,41 +155,6 @@ func (m *Mounter) doMount(mounterPath string, mountCmd string, source string, ta
return
err
}
// GetMountRefs finds all other references to the device referenced
// by mountPath; returns a list of paths.
func
GetMountRefs
(
mounter
Interface
,
mountPath
string
)
([]
string
,
error
)
{
mps
,
err
:=
mounter
.
List
()
if
err
!=
nil
{
return
nil
,
err
}
// Find the device name.
deviceName
:=
""
// If mountPath is symlink, need get its target path.
slTarget
,
err
:=
filepath
.
EvalSymlinks
(
mountPath
)
if
err
!=
nil
{
slTarget
=
mountPath
}
for
i
:=
range
mps
{
if
mps
[
i
]
.
Path
==
slTarget
{
deviceName
=
mps
[
i
]
.
Device
break
}
}
// Find all references to the device.
var
refs
[]
string
if
deviceName
==
""
{
glog
.
Warningf
(
"could not determine device for path: %q"
,
mountPath
)
}
else
{
for
i
:=
range
mps
{
if
mps
[
i
]
.
Device
==
deviceName
&&
mps
[
i
]
.
Path
!=
slTarget
{
refs
=
append
(
refs
,
mps
[
i
]
.
Path
)
}
}
}
return
refs
,
nil
}
// detectSystemd returns true if OS runs with systemd as init. When not sure
// (permission errors, ...), it returns false.
// There may be different ways how to detect systemd, this one makes sure that
...
...
@@ -352,7 +317,7 @@ func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (str
// the mount path reference should match the given plugin directory. In case no mount path reference
// matches, returns the volume name taken from its given mountPath
func
getDeviceNameFromMount
(
mounter
Interface
,
mountPath
,
pluginDir
string
)
(
string
,
error
)
{
refs
,
err
:=
GetMountRefs
(
mounter
,
mountPath
)
refs
,
err
:=
mounter
.
GetMountRefs
(
mountPath
)
if
err
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"GetMountRefs failed for mount path %q: %v"
,
mountPath
,
err
)
return
""
,
err
...
...
pkg/util/mount/mount_linux_test.go
View file @
c542b6be
...
...
@@ -113,7 +113,7 @@ func TestGetMountRefs(t *testing.T) {
}
for
i
,
test
:=
range
tests
{
if
refs
,
err
:=
GetMountRefs
(
fm
,
test
.
mountPath
);
err
!=
nil
||
!
setEquivalent
(
test
.
expectedRefs
,
refs
)
{
if
refs
,
err
:=
fm
.
GetMountRefs
(
test
.
mountPath
);
err
!=
nil
||
!
setEquivalent
(
test
.
expectedRefs
,
refs
)
{
t
.
Errorf
(
"%d. getMountRefs(%q) = %v, %v; expected %v, nil"
,
i
,
test
.
mountPath
,
refs
,
err
,
test
.
expectedRefs
)
}
}
...
...
pkg/util/mount/mount_unsupported.go
View file @
c542b6be
...
...
@@ -46,12 +46,6 @@ func (mounter *Mounter) Unmount(target string) error {
return
unsupportedErr
}
// GetMountRefs finds all other references to the device referenced
// by mountPath; returns a list of paths.
func
GetMountRefs
(
mounter
Interface
,
mountPath
string
)
([]
string
,
error
)
{
return
[]
string
{},
unsupportedErr
}
func
(
mounter
*
Mounter
)
List
()
([]
MountPoint
,
error
)
{
return
[]
MountPoint
{},
unsupportedErr
}
...
...
pkg/util/mount/mount_windows.go
View file @
c542b6be
...
...
@@ -114,16 +114,6 @@ func (mounter *Mounter) Unmount(target string) error {
return
nil
}
// GetMountRefs finds all other references to the device(drive) referenced
// by mountPath; returns a list of paths.
func
GetMountRefs
(
mounter
Interface
,
mountPath
string
)
([]
string
,
error
)
{
refs
,
err
:=
getAllParentLinks
(
normalizeWindowsPath
(
mountPath
))
if
err
!=
nil
{
return
nil
,
err
}
return
refs
,
nil
}
// List returns a list of all mounted filesystems. todo
func
(
mounter
*
Mounter
)
List
()
([]
MountPoint
,
error
)
{
return
[]
MountPoint
{},
nil
...
...
@@ -170,7 +160,7 @@ func (mounter *Mounter) GetDeviceNameFromMount(mountPath, pluginDir string) (str
// the mount path reference should match the given plugin directory. In case no mount path reference
// matches, returns the volume name taken from its given mountPath
func
getDeviceNameFromMount
(
mounter
Interface
,
mountPath
,
pluginDir
string
)
(
string
,
error
)
{
refs
,
err
:=
GetMountRefs
(
mounter
,
mountPath
)
refs
,
err
:=
mounter
.
GetMountRefs
(
mountPath
)
if
err
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"GetMountRefs failed for mount path %q: %v"
,
mountPath
,
err
)
return
""
,
err
...
...
@@ -458,11 +448,11 @@ func getAllParentLinks(path string) ([]string, error) {
}
func
(
mounter
*
Mounter
)
GetMountRefs
(
pathname
string
)
([]
string
,
error
)
{
re
alpath
,
err
:=
filepath
.
EvalSymlinks
(
pathname
)
re
fs
,
err
:=
getAllParentLinks
(
normalizeWindowsPath
(
pathname
)
)
if
err
!=
nil
{
return
nil
,
err
}
return
getMountRefsByDev
(
mounter
,
realpath
)
return
refs
,
nil
}
// Note that on windows, it always returns 0. We actually don't set FSGroup on
...
...
pkg/util/mount/mount_windows_test.go
View file @
c542b6be
...
...
@@ -127,7 +127,7 @@ func TestGetMountRefs(t *testing.T) {
}
}
if
refs
,
err
:=
GetMountRefs
(
fm
,
mountPath
);
err
!=
nil
||
!
setEquivalent
(
expectedRefs
,
refs
)
{
if
refs
,
err
:=
fm
.
GetMountRefs
(
mountPath
);
err
!=
nil
||
!
setEquivalent
(
expectedRefs
,
refs
)
{
t
.
Errorf
(
"getMountRefs(%q) = %v, error: %v; expected %v"
,
mountPath
,
refs
,
err
,
expectedRefs
)
}
...
...
pkg/volume/aws_ebs/attacher.go
View file @
c542b6be
...
...
@@ -55,7 +55,7 @@ func (plugin *awsElasticBlockStorePlugin) NewAttacher() (volume.Attacher, error)
func
(
plugin
*
awsElasticBlockStorePlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
func
(
attacher
*
awsElasticBlockStoreAttacher
)
Attach
(
spec
*
volume
.
Spec
,
nodeName
types
.
NodeName
)
(
string
,
error
)
{
...
...
pkg/volume/azure_dd/azure_dd.go
View file @
c542b6be
...
...
@@ -26,7 +26,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/cloudprovider/providers/azure"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
...
...
@@ -267,5 +266,5 @@ func (plugin *azureDataDiskPlugin) ConstructVolumeSpec(volumeName, mountPath str
func
(
plugin
*
azureDataDiskPlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
m
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
m
ount
.
GetMountRefs
(
m
,
deviceMountPath
)
return
m
.
GetMountRefs
(
deviceMountPath
)
}
pkg/volume/cinder/attacher.go
View file @
c542b6be
...
...
@@ -69,7 +69,7 @@ func (plugin *cinderPlugin) NewAttacher() (volume.Attacher, error) {
func
(
plugin
*
cinderPlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
func
(
attacher
*
cinderDiskAttacher
)
waitOperationFinished
(
volumeID
string
)
error
{
...
...
pkg/volume/cinder/cinder.go
View file @
c542b6be
...
...
@@ -437,7 +437,7 @@ func (c *cinderVolumeUnmounter) TearDownAt(dir string) error {
// Find Cinder volumeID to lock the right volume
// TODO: refactor VolumePlugin.NewUnmounter to get full volume.Spec just like
// NewMounter. We could then find volumeID there without probing MountRefs.
refs
,
err
:=
mount
.
GetMountRefs
(
c
.
mounter
,
dir
)
refs
,
err
:=
c
.
mounter
.
GetMountRefs
(
dir
)
if
err
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"GetMountRefs failed: %v"
,
err
)
return
err
...
...
@@ -454,7 +454,7 @@ func (c *cinderVolumeUnmounter) TearDownAt(dir string) error {
defer
c
.
plugin
.
volumeLocks
.
UnlockKey
(
c
.
pdName
)
// Reload list of references, there might be SetUpAt finished in the meantime
refs
,
err
=
mount
.
GetMountRefs
(
c
.
mounter
,
dir
)
refs
,
err
=
c
.
mounter
.
GetMountRefs
(
dir
)
if
err
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"GetMountRefs failed: %v"
,
err
)
return
err
...
...
pkg/volume/csi/BUILD
View file @
c542b6be
...
...
@@ -14,7 +14,6 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/features:go_default_library",
"//pkg/util/mount:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/csi/labelmanager:go_default_library",
...
...
pkg/volume/csi/csi_plugin.go
View file @
c542b6be
...
...
@@ -31,7 +31,6 @@ import (
"k8s.io/apimachinery/pkg/types"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/csi/labelmanager"
)
...
...
@@ -309,7 +308,7 @@ func (p *csiPlugin) NewDetacher() (volume.Detacher, error) {
func
(
p
*
csiPlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
m
:=
p
.
host
.
GetMounter
(
p
.
GetPluginName
())
return
m
ount
.
GetMountRefs
(
m
,
deviceMountPath
)
return
m
.
GetMountRefs
(
deviceMountPath
)
}
// BlockVolumePlugin methods
...
...
pkg/volume/fc/attacher.go
View file @
c542b6be
...
...
@@ -51,7 +51,7 @@ func (plugin *fcPlugin) NewAttacher() (volume.Attacher, error) {
func
(
plugin
*
fcPlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
func
(
attacher
*
fcAttacher
)
Attach
(
spec
*
volume
.
Spec
,
nodeName
types
.
NodeName
)
(
string
,
error
)
{
...
...
pkg/volume/fc/fc.go
View file @
c542b6be
...
...
@@ -237,7 +237,7 @@ func (plugin *fcPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*volu
// globalPDPath : plugins/kubernetes.io/fc/50060e801049cfd1-lun-0
var
globalPDPath
string
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
paths
,
err
:=
mount
.
GetMountRefs
(
mounter
,
mountPath
)
paths
,
err
:=
mount
er
.
GetMountRefs
(
mountPath
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/volume/fc/fc_test.go
View file @
c542b6be
...
...
@@ -441,7 +441,7 @@ func Test_ConstructVolumeSpec(t *testing.T) {
"/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~fc/fc-in-pod2"
,
}
for
_
,
path
:=
range
mountPaths
{
refs
,
err
:=
mount
.
GetMountRefs
(
fm
,
path
)
refs
,
err
:=
fm
.
GetMountRefs
(
path
)
if
err
!=
nil
{
t
.
Errorf
(
"couldn't get mountrefs. err: %v"
,
err
)
}
...
...
@@ -488,7 +488,7 @@ func Test_ConstructVolumeSpecNoRefs(t *testing.T) {
"/var/lib/kubelet/pods/some-pod/volumes/kubernetes.io~fc/fc-in-pod1"
,
}
for
_
,
path
:=
range
mountPaths
{
refs
,
_
:=
mount
.
GetMountRefs
(
fm
,
path
)
refs
,
_
:=
fm
.
GetMountRefs
(
path
)
var
globalPDPath
string
for
_
,
ref
:=
range
refs
{
if
strings
.
Contains
(
ref
,
"kubernetes.io/fc"
)
{
...
...
pkg/volume/flexvolume/plugin.go
View file @
c542b6be
...
...
@@ -265,7 +265,7 @@ func (plugin *flexVolumePlugin) isUnsupported(command string) bool {
func
(
plugin
*
flexVolumePlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
func
(
plugin
*
flexVolumePlugin
)
getDeviceMountPath
(
spec
*
volume
.
Spec
)
(
string
,
error
)
{
...
...
pkg/volume/gce_pd/attacher.go
View file @
c542b6be
...
...
@@ -29,7 +29,6 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil
"k8s.io/kubernetes/pkg/volume/util"
)
...
...
@@ -57,7 +56,7 @@ func (plugin *gcePersistentDiskPlugin) NewAttacher() (volume.Attacher, error) {
func
(
plugin
*
gcePersistentDiskPlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
// Attach checks with the GCE cloud provider if the specified volume is already
...
...
pkg/volume/iscsi/attacher.go
View file @
c542b6be
...
...
@@ -49,7 +49,7 @@ func (plugin *iscsiPlugin) NewAttacher() (volume.Attacher, error) {
func
(
plugin
*
iscsiPlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
iscsiPluginName
)
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
func
(
attacher
*
iscsiAttacher
)
Attach
(
spec
*
volume
.
Spec
,
nodeName
types
.
NodeName
)
(
string
,
error
)
{
...
...
pkg/volume/iscsi/iscsi.go
View file @
c542b6be
...
...
@@ -203,7 +203,7 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v
// Find globalPDPath from pod volume directory(mountPath)
var
globalPDPath
string
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
paths
,
err
:=
mount
.
GetMountRefs
(
mounter
,
mountPath
)
paths
,
err
:=
mount
er
.
GetMountRefs
(
mountPath
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/volume/photon_pd/attacher.go
View file @
c542b6be
...
...
@@ -182,7 +182,7 @@ func (attacher *photonPersistentDiskAttacher) GetDeviceMountPath(spec *volume.Sp
// by deviceMountPath; returns a list of paths.
func
(
plugin
*
photonPersistentDiskPlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
// MountDevice mounts device to global mount point.
...
...
pkg/volume/rbd/attacher.go
View file @
c542b6be
...
...
@@ -58,7 +58,7 @@ func (plugin *rbdPlugin) newDetacherInternal(manager diskManager) (volume.Detach
// GetDeviceMountRefs implements AttachableVolumePlugin.GetDeviceMountRefs.
func
(
plugin
*
rbdPlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
// rbdAttacher implements volume.Attacher interface.
...
...
pkg/volume/vsphere_volume/attacher.go
View file @
c542b6be
...
...
@@ -191,7 +191,7 @@ func (attacher *vsphereVMDKAttacher) GetDeviceMountPath(spec *volume.Spec) (stri
// by deviceMountPath; returns a list of paths.
func
(
plugin
*
vsphereVolumePlugin
)
GetDeviceMountRefs
(
deviceMountPath
string
)
([]
string
,
error
)
{
mounter
:=
plugin
.
host
.
GetMounter
(
plugin
.
GetPluginName
())
return
mount
.
GetMountRefs
(
mounter
,
deviceMountPath
)
return
mount
er
.
GetMountRefs
(
deviceMountPath
)
}
// MountDevice mounts device to global mount point.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment