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
b05cab0b
Commit
b05cab0b
authored
Aug 19, 2015
by
Saad Ali
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6945 from eparis/IsMountPoint
Rename IsMountPoint to IsLikelyNotMountPoint
parents
ed36bfa8
f125ad88
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
116 additions
and
109 deletions
+116
-109
fake.go
pkg/util/mount/fake.go
+3
-3
mount.go
pkg/util/mount/mount.go
+2
-2
mount_linux.go
pkg/util/mount/mount_linux.go
+15
-8
mount_unsupported.go
pkg/util/mount/mount_unsupported.go
+2
-2
nsenter_mount.go
pkg/util/mount/nsenter_mount.go
+7
-7
nsenter_mount_unsupported.go
pkg/util/mount/nsenter_mount_unsupported.go
+2
-2
aws_ebs.go
pkg/volume/aws_ebs/aws_ebs.go
+14
-14
aws_util.go
pkg/volume/aws_ebs/aws_util.go
+3
-3
empty_dir.go
pkg/volume/empty_dir/empty_dir.go
+2
-2
empty_dir_linux.go
pkg/volume/empty_dir/empty_dir_linux.go
+4
-4
gce_pd.go
pkg/volume/gce_pd/gce_pd.go
+14
-14
gce_util.go
pkg/volume/gce_pd/gce_util.go
+3
-3
glusterfs.go
pkg/volume/glusterfs/glusterfs.go
+9
-9
disk_manager.go
pkg/volume/iscsi/disk_manager.go
+7
-7
iscsi_util.go
pkg/volume/iscsi/iscsi_util.go
+2
-2
nfs.go
pkg/volume/nfs/nfs.go
+15
-15
disk_manager.go
pkg/volume/rbd/disk_manager.go
+7
-7
rbd_util.go
pkg/volume/rbd/rbd_util.go
+3
-3
secret.go
pkg/volume/secret/secret.go
+2
-2
No files found.
pkg/util/mount/fake.go
View file @
b05cab0b
...
@@ -62,11 +62,11 @@ func (f *FakeMounter) List() ([]MountPoint, error) {
...
@@ -62,11 +62,11 @@ func (f *FakeMounter) List() ([]MountPoint, error) {
return
f
.
MountPoints
,
nil
return
f
.
MountPoints
,
nil
}
}
func
(
f
*
FakeMounter
)
IsMountPoint
(
file
string
)
(
bool
,
error
)
{
func
(
f
*
FakeMounter
)
Is
LikelyNot
MountPoint
(
file
string
)
(
bool
,
error
)
{
for
_
,
mp
:=
range
f
.
MountPoints
{
for
_
,
mp
:=
range
f
.
MountPoints
{
if
mp
.
Path
==
file
{
if
mp
.
Path
==
file
{
return
tru
e
,
nil
return
fals
e
,
nil
}
}
}
}
return
fals
e
,
nil
return
tru
e
,
nil
}
}
pkg/util/mount/mount.go
View file @
b05cab0b
...
@@ -30,8 +30,8 @@ type Interface interface {
...
@@ -30,8 +30,8 @@ type Interface interface {
// it could change between chunked reads). This is guaranteed to be
// it could change between chunked reads). This is guaranteed to be
// consistent.
// consistent.
List
()
([]
MountPoint
,
error
)
List
()
([]
MountPoint
,
error
)
// IsMountPoint determines if a directory is a mountpoint.
// Is
LikelyNot
MountPoint determines if a directory is a mountpoint.
IsMountPoint
(
file
string
)
(
bool
,
error
)
Is
LikelyNot
MountPoint
(
file
string
)
(
bool
,
error
)
}
}
// This represents a single line in /proc/mounts or /etc/fstab.
// This represents a single line in /proc/mounts or /etc/fstab.
...
...
pkg/util/mount/mount_linux.go
View file @
b05cab0b
...
@@ -141,20 +141,27 @@ func (*Mounter) List() ([]MountPoint, error) {
...
@@ -141,20 +141,27 @@ func (*Mounter) List() ([]MountPoint, error) {
return
listProcMounts
(
procMountsPath
)
return
listProcMounts
(
procMountsPath
)
}
}
// IsMountPoint determines if a directory is a mountpoint, by comparing the device for the
// IsLikelyNotMountPoint determines if a directory is not a mountpoint.
// directory with the device for it's parent. If they are the same, it's not a mountpoint,
// It is fast but not necessarily ALWAYS correct. If the path is in fact
// if they're different, it is.
// a bind mount from one part of a mount to another it will not be detected.
func
(
mounter
*
Mounter
)
IsMountPoint
(
file
string
)
(
bool
,
error
)
{
// mkdir /tmp/a /tmp/b; mount --bin /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b")
// will return true. When in fact /tmp/b is a mount point. If this situation
// if of interest to you, don't use this function...
func
(
mounter
*
Mounter
)
IsLikelyNotMountPoint
(
file
string
)
(
bool
,
error
)
{
stat
,
err
:=
os
.
Stat
(
file
)
stat
,
err
:=
os
.
Stat
(
file
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fals
e
,
err
return
tru
e
,
err
}
}
rootStat
,
err
:=
os
.
Lstat
(
file
+
"/.."
)
rootStat
,
err
:=
os
.
Lstat
(
file
+
"/.."
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fals
e
,
err
return
tru
e
,
err
}
}
// If the directory has the same device as parent, then it's not a mountpoint.
// If the directory has a different device as parent, then it is a mountpoint.
return
stat
.
Sys
()
.
(
*
syscall
.
Stat_t
)
.
Dev
!=
rootStat
.
Sys
()
.
(
*
syscall
.
Stat_t
)
.
Dev
,
nil
if
stat
.
Sys
()
.
(
*
syscall
.
Stat_t
)
.
Dev
!=
rootStat
.
Sys
()
.
(
*
syscall
.
Stat_t
)
.
Dev
{
return
false
,
nil
}
return
true
,
nil
}
}
func
listProcMounts
(
mountFilePath
string
)
([]
MountPoint
,
error
)
{
func
listProcMounts
(
mountFilePath
string
)
([]
MountPoint
,
error
)
{
...
...
pkg/util/mount/mount_unsupported.go
View file @
b05cab0b
...
@@ -32,6 +32,6 @@ func (mounter *Mounter) List() ([]MountPoint, error) {
...
@@ -32,6 +32,6 @@ func (mounter *Mounter) List() ([]MountPoint, error) {
return
[]
MountPoint
{},
nil
return
[]
MountPoint
{},
nil
}
}
func
(
mounter
*
Mounter
)
IsMountPoint
(
file
string
)
(
bool
,
error
)
{
func
(
mounter
*
Mounter
)
Is
LikelyNot
MountPoint
(
file
string
)
(
bool
,
error
)
{
return
fals
e
,
nil
return
tru
e
,
nil
}
}
pkg/util/mount/nsenter_mount.go
View file @
b05cab0b
...
@@ -162,12 +162,12 @@ func (*NsenterMounter) List() ([]MountPoint, error) {
...
@@ -162,12 +162,12 @@ func (*NsenterMounter) List() ([]MountPoint, error) {
return
listProcMounts
(
hostProcMountsPath
)
return
listProcMounts
(
hostProcMountsPath
)
}
}
// IsMountPoint determines whether a path is a mountpoint by calling findmnt
// Is
LikelyNot
MountPoint determines whether a path is a mountpoint by calling findmnt
// in the host's root mount namespace.
// in the host's root mount namespace.
func
(
n
*
NsenterMounter
)
IsMountPoint
(
file
string
)
(
bool
,
error
)
{
func
(
n
*
NsenterMounter
)
Is
LikelyNot
MountPoint
(
file
string
)
(
bool
,
error
)
{
file
,
err
:=
filepath
.
Abs
(
file
)
file
,
err
:=
filepath
.
Abs
(
file
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fals
e
,
err
return
tru
e
,
err
}
}
args
:=
[]
string
{
"--mount=/rootfs/proc/1/ns/mnt"
,
"--"
,
n
.
absHostPath
(
"findmnt"
),
"-o"
,
"target"
,
"--noheadings"
,
"--target"
,
file
}
args
:=
[]
string
{
"--mount=/rootfs/proc/1/ns/mnt"
,
"--"
,
n
.
absHostPath
(
"findmnt"
),
"-o"
,
"target"
,
"--noheadings"
,
"--target"
,
file
}
...
@@ -177,16 +177,16 @@ func (n *NsenterMounter) IsMountPoint(file string) (bool, error) {
...
@@ -177,16 +177,16 @@ func (n *NsenterMounter) IsMountPoint(file string) (bool, error) {
out
,
err
:=
exec
.
Command
(
nsenterPath
,
args
...
)
.
CombinedOutput
()
out
,
err
:=
exec
.
Command
(
nsenterPath
,
args
...
)
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
// If findmnt didn't run, just claim it's not a mount point.
// If findmnt didn't run, just claim it's not a mount point.
return
fals
e
,
nil
return
tru
e
,
nil
}
}
strOut
:=
strings
.
TrimSuffix
(
string
(
out
),
"
\n
"
)
strOut
:=
strings
.
TrimSuffix
(
string
(
out
),
"
\n
"
)
glog
.
V
(
5
)
.
Infof
(
"IsMountPoint findmnt output: %v"
,
strOut
)
glog
.
V
(
5
)
.
Infof
(
"Is
LikelyNot
MountPoint findmnt output: %v"
,
strOut
)
if
strOut
==
file
{
if
strOut
==
file
{
return
tru
e
,
nil
return
fals
e
,
nil
}
}
return
fals
e
,
nil
return
tru
e
,
nil
}
}
func
(
n
*
NsenterMounter
)
absHostPath
(
command
string
)
string
{
func
(
n
*
NsenterMounter
)
absHostPath
(
command
string
)
string
{
...
...
pkg/util/mount/nsenter_mount_unsupported.go
View file @
b05cab0b
...
@@ -38,6 +38,6 @@ func (*NsenterMounter) List() ([]MountPoint, error) {
...
@@ -38,6 +38,6 @@ func (*NsenterMounter) List() ([]MountPoint, error) {
return
[]
MountPoint
{},
nil
return
[]
MountPoint
{},
nil
}
}
func
(
*
NsenterMounter
)
IsMountPoint
(
file
string
)
(
bool
,
error
)
{
func
(
*
NsenterMounter
)
Is
LikelyNot
MountPoint
(
file
string
)
(
bool
,
error
)
{
return
fals
e
,
nil
return
tru
e
,
nil
}
}
pkg/volume/aws_ebs/aws_ebs.go
View file @
b05cab0b
...
@@ -189,12 +189,12 @@ func (b *awsElasticBlockStoreBuilder) SetUp() error {
...
@@ -189,12 +189,12 @@ func (b *awsElasticBlockStoreBuilder) SetUp() error {
// SetUpAt attaches the disk and bind mounts to the volume path.
// SetUpAt attaches the disk and bind mounts to the volume path.
func
(
b
*
awsElasticBlockStoreBuilder
)
SetUpAt
(
dir
string
)
error
{
func
(
b
*
awsElasticBlockStoreBuilder
)
SetUpAt
(
dir
string
)
error
{
// TODO: handle failed mounts here.
// TODO: handle failed mounts here.
mountpoint
,
err
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
glog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v"
,
dir
,
mountpoi
nt
,
err
)
glog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v"
,
dir
,
!
notM
nt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
return
nil
return
nil
}
}
...
@@ -216,22 +216,22 @@ func (b *awsElasticBlockStoreBuilder) SetUpAt(dir string) error {
...
@@ -216,22 +216,22 @@ func (b *awsElasticBlockStoreBuilder) SetUpAt(dir string) error {
}
}
err
=
b
.
mounter
.
Mount
(
globalPDPath
,
dir
,
""
,
options
)
err
=
b
.
mounter
.
Mount
(
globalPDPath
,
dir
,
""
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
mountpoint
,
mntErr
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"
isMountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"
IsLikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
if
mntErr
=
b
.
mounter
.
Unmount
(
dir
);
mntErr
!=
nil
{
if
mntErr
=
b
.
mounter
.
Unmount
(
dir
);
mntErr
!=
nil
{
glog
.
Errorf
(
"Failed to unmount: %v"
,
mntErr
)
glog
.
Errorf
(
"Failed to unmount: %v"
,
mntErr
)
return
err
return
err
}
}
mountpoint
,
mntErr
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"
isMountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"
IsLikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
// This is very odd, we don't expect it. We'll try again next sync loop.
// This is very odd, we don't expect it. We'll try again next sync loop.
glog
.
Errorf
(
"%s is still mounted, despite call to unmount(). Will try again next sync loop."
,
dir
)
glog
.
Errorf
(
"%s is still mounted, despite call to unmount(). Will try again next sync loop."
,
dir
)
return
err
return
err
...
@@ -295,12 +295,12 @@ func (c *awsElasticBlockStoreCleaner) TearDown() error {
...
@@ -295,12 +295,12 @@ func (c *awsElasticBlockStoreCleaner) TearDown() error {
// Unmounts the bind mount, and detaches the disk only if the PD
// Unmounts the bind mount, and detaches the disk only if the PD
// resource was the last reference to that disk on the kubelet.
// resource was the last reference to that disk on the kubelet.
func
(
c
*
awsElasticBlockStoreCleaner
)
TearDownAt
(
dir
string
)
error
{
func
(
c
*
awsElasticBlockStoreCleaner
)
TearDownAt
(
dir
string
)
error
{
mountpoint
,
err
:=
c
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error checking if mountpoint "
,
dir
,
": "
,
err
)
glog
.
V
(
2
)
.
Info
(
"Error checking if mountpoint "
,
dir
,
": "
,
err
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
glog
.
V
(
2
)
.
Info
(
"Not mountpoint, deleting"
)
glog
.
V
(
2
)
.
Info
(
"Not mountpoint, deleting"
)
return
os
.
Remove
(
dir
)
return
os
.
Remove
(
dir
)
}
}
...
@@ -334,12 +334,12 @@ func (c *awsElasticBlockStoreCleaner) TearDownAt(dir string) error {
...
@@ -334,12 +334,12 @@ func (c *awsElasticBlockStoreCleaner) TearDownAt(dir string) error {
}
else
{
}
else
{
glog
.
V
(
2
)
.
Infof
(
"Found multiple refs; won't detach EBS volume: %v"
,
refs
)
glog
.
V
(
2
)
.
Infof
(
"Found multiple refs; won't detach EBS volume: %v"
,
refs
)
}
}
mountpoint
,
mntErr
:=
c
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"
isMountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"
IsLikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error removing mountpoint "
,
dir
,
": "
,
err
)
glog
.
V
(
2
)
.
Info
(
"Error removing mountpoint "
,
dir
,
": "
,
err
)
return
err
return
err
...
...
pkg/volume/aws_ebs/aws_util.go
View file @
b05cab0b
...
@@ -61,13 +61,13 @@ func (util *AWSDiskUtil) AttachAndMountDisk(b *awsElasticBlockStoreBuilder, glob
...
@@ -61,13 +61,13 @@ func (util *AWSDiskUtil) AttachAndMountDisk(b *awsElasticBlockStoreBuilder, glob
}
}
// Only mount the PD globally once.
// Only mount the PD globally once.
mountpoint
,
err
:=
b
.
mounter
.
Is
MountPoint
(
globalPDPath
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
globalPDPath
)
if
err
!=
nil
{
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
if
err
:=
os
.
MkdirAll
(
globalPDPath
,
0750
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
globalPDPath
,
0750
);
err
!=
nil
{
return
err
return
err
}
}
mountpoint
=
fals
e
notMnt
=
tru
e
}
else
{
}
else
{
return
err
return
err
}
}
...
@@ -76,7 +76,7 @@ func (util *AWSDiskUtil) AttachAndMountDisk(b *awsElasticBlockStoreBuilder, glob
...
@@ -76,7 +76,7 @@ func (util *AWSDiskUtil) AttachAndMountDisk(b *awsElasticBlockStoreBuilder, glob
if
b
.
readOnly
{
if
b
.
readOnly
{
options
=
append
(
options
,
"ro"
)
options
=
append
(
options
,
"ro"
)
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
err
=
b
.
diskMounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
options
)
err
=
b
.
diskMounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
os
.
Remove
(
globalPDPath
)
os
.
Remove
(
globalPDPath
)
...
...
pkg/volume/empty_dir/empty_dir.go
View file @
b05cab0b
...
@@ -144,7 +144,7 @@ func (ed *emptyDir) SetUp() error {
...
@@ -144,7 +144,7 @@ func (ed *emptyDir) SetUp() error {
// SetUpAt creates new directory.
// SetUpAt creates new directory.
func
(
ed
*
emptyDir
)
SetUpAt
(
dir
string
)
error
{
func
(
ed
*
emptyDir
)
SetUpAt
(
dir
string
)
error
{
isMnt
,
err
:=
ed
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
ed
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
// Getting an os.IsNotExist err from is a contingency; the directory
// Getting an os.IsNotExist err from is a contingency; the directory
// may not exist yet, in which case, setup should run.
// may not exist yet, in which case, setup should run.
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
...
@@ -156,7 +156,7 @@ func (ed *emptyDir) SetUpAt(dir string) error {
...
@@ -156,7 +156,7 @@ func (ed *emptyDir) SetUpAt(dir string) error {
// medium is memory, and a mountpoint is present, then the volume is
// medium is memory, and a mountpoint is present, then the volume is
// ready.
// ready.
if
volumeutil
.
IsReady
(
ed
.
getMetaDir
())
{
if
volumeutil
.
IsReady
(
ed
.
getMetaDir
())
{
if
ed
.
medium
==
api
.
StorageMediumMemory
&&
is
Mnt
{
if
ed
.
medium
==
api
.
StorageMediumMemory
&&
!
not
Mnt
{
return
nil
return
nil
}
else
if
ed
.
medium
==
api
.
StorageMediumDefault
{
}
else
if
ed
.
medium
==
api
.
StorageMediumDefault
{
return
nil
return
nil
...
...
pkg/volume/empty_dir/empty_dir_linux.go
View file @
b05cab0b
...
@@ -37,9 +37,9 @@ type realMountDetector struct {
...
@@ -37,9 +37,9 @@ type realMountDetector struct {
func
(
m
*
realMountDetector
)
GetMountMedium
(
path
string
)
(
storageMedium
,
bool
,
error
)
{
func
(
m
*
realMountDetector
)
GetMountMedium
(
path
string
)
(
storageMedium
,
bool
,
error
)
{
glog
.
V
(
5
)
.
Infof
(
"Determining mount medium of %v"
,
path
)
glog
.
V
(
5
)
.
Infof
(
"Determining mount medium of %v"
,
path
)
isMnt
,
err
:=
m
.
mounter
.
Is
MountPoint
(
path
)
notMnt
,
err
:=
m
.
mounter
.
IsLikelyNot
MountPoint
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
false
,
fmt
.
Errorf
(
"IsMountPoint(%q): %v"
,
path
,
err
)
return
0
,
false
,
fmt
.
Errorf
(
"Is
LikelyNot
MountPoint(%q): %v"
,
path
,
err
)
}
}
buf
:=
syscall
.
Statfs_t
{}
buf
:=
syscall
.
Statfs_t
{}
if
err
:=
syscall
.
Statfs
(
path
,
&
buf
);
err
!=
nil
{
if
err
:=
syscall
.
Statfs
(
path
,
&
buf
);
err
!=
nil
{
...
@@ -48,9 +48,9 @@ func (m *realMountDetector) GetMountMedium(path string) (storageMedium, bool, er
...
@@ -48,9 +48,9 @@ func (m *realMountDetector) GetMountMedium(path string) (storageMedium, bool, er
glog
.
V
(
5
)
.
Info
(
"Statfs_t of %v: %+v"
,
path
,
buf
)
glog
.
V
(
5
)
.
Info
(
"Statfs_t of %v: %+v"
,
path
,
buf
)
if
buf
.
Type
==
linuxTmpfsMagic
{
if
buf
.
Type
==
linuxTmpfsMagic
{
return
mediumMemory
,
is
Mnt
,
nil
return
mediumMemory
,
!
not
Mnt
,
nil
}
}
return
mediumUnknown
,
is
Mnt
,
nil
return
mediumUnknown
,
!
not
Mnt
,
nil
}
}
// selinuxEnabled determines whether SELinux is enabled.
// selinuxEnabled determines whether SELinux is enabled.
...
...
pkg/volume/gce_pd/gce_pd.go
View file @
b05cab0b
...
@@ -172,12 +172,12 @@ func (b *gcePersistentDiskBuilder) SetUp() error {
...
@@ -172,12 +172,12 @@ func (b *gcePersistentDiskBuilder) SetUp() error {
// SetUpAt attaches the disk and bind mounts to the volume path.
// SetUpAt attaches the disk and bind mounts to the volume path.
func
(
b
*
gcePersistentDiskBuilder
)
SetUpAt
(
dir
string
)
error
{
func
(
b
*
gcePersistentDiskBuilder
)
SetUpAt
(
dir
string
)
error
{
// TODO: handle failed mounts here.
// TODO: handle failed mounts here.
mountpoint
,
err
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
glog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v"
,
dir
,
mountpoi
nt
,
err
)
glog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v"
,
dir
,
!
notM
nt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
return
nil
return
nil
}
}
...
@@ -199,22 +199,22 @@ func (b *gcePersistentDiskBuilder) SetUpAt(dir string) error {
...
@@ -199,22 +199,22 @@ func (b *gcePersistentDiskBuilder) SetUpAt(dir string) error {
}
}
err
=
b
.
mounter
.
Mount
(
globalPDPath
,
dir
,
""
,
options
)
err
=
b
.
mounter
.
Mount
(
globalPDPath
,
dir
,
""
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
mountpoint
,
mntErr
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"
isMountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"
IsLikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
if
mntErr
=
b
.
mounter
.
Unmount
(
dir
);
mntErr
!=
nil
{
if
mntErr
=
b
.
mounter
.
Unmount
(
dir
);
mntErr
!=
nil
{
glog
.
Errorf
(
"Failed to unmount: %v"
,
mntErr
)
glog
.
Errorf
(
"Failed to unmount: %v"
,
mntErr
)
return
err
return
err
}
}
mountpoint
,
mntErr
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"
isMountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"
IsLikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
// This is very odd, we don't expect it. We'll try again next sync loop.
// This is very odd, we don't expect it. We'll try again next sync loop.
glog
.
Errorf
(
"%s is still mounted, despite call to unmount(). Will try again next sync loop."
,
dir
)
glog
.
Errorf
(
"%s is still mounted, despite call to unmount(). Will try again next sync loop."
,
dir
)
return
err
return
err
...
@@ -257,11 +257,11 @@ func (c *gcePersistentDiskCleaner) TearDown() error {
...
@@ -257,11 +257,11 @@ func (c *gcePersistentDiskCleaner) TearDown() error {
// Unmounts the bind mount, and detaches the disk only if the PD
// Unmounts the bind mount, and detaches the disk only if the PD
// resource was the last reference to that disk on the kubelet.
// resource was the last reference to that disk on the kubelet.
func
(
c
*
gcePersistentDiskCleaner
)
TearDownAt
(
dir
string
)
error
{
func
(
c
*
gcePersistentDiskCleaner
)
TearDownAt
(
dir
string
)
error
{
mountpoint
,
err
:=
c
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
return
os
.
Remove
(
dir
)
return
os
.
Remove
(
dir
)
}
}
...
@@ -282,12 +282,12 @@ func (c *gcePersistentDiskCleaner) TearDownAt(dir string) error {
...
@@ -282,12 +282,12 @@ func (c *gcePersistentDiskCleaner) TearDownAt(dir string) error {
return
err
return
err
}
}
}
}
mountpoint
,
mntErr
:=
c
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"
isMountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"
IsLikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/volume/gce_pd/gce_util.go
View file @
b05cab0b
...
@@ -71,13 +71,13 @@ func (diskUtil *GCEDiskUtil) AttachAndMountDisk(b *gcePersistentDiskBuilder, glo
...
@@ -71,13 +71,13 @@ func (diskUtil *GCEDiskUtil) AttachAndMountDisk(b *gcePersistentDiskBuilder, glo
}
}
// Only mount the PD globally once.
// Only mount the PD globally once.
mountpoint
,
err
:=
b
.
mounter
.
Is
MountPoint
(
globalPDPath
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
globalPDPath
)
if
err
!=
nil
{
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
if
os
.
IsNotExist
(
err
)
{
if
err
:=
os
.
MkdirAll
(
globalPDPath
,
0750
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
globalPDPath
,
0750
);
err
!=
nil
{
return
err
return
err
}
}
mountpoint
=
fals
e
notMnt
=
tru
e
}
else
{
}
else
{
return
err
return
err
}
}
...
@@ -86,7 +86,7 @@ func (diskUtil *GCEDiskUtil) AttachAndMountDisk(b *gcePersistentDiskBuilder, glo
...
@@ -86,7 +86,7 @@ func (diskUtil *GCEDiskUtil) AttachAndMountDisk(b *gcePersistentDiskBuilder, glo
if
b
.
readOnly
{
if
b
.
readOnly
{
options
=
append
(
options
,
"ro"
)
options
=
append
(
options
,
"ro"
)
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
err
=
b
.
diskMounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
options
)
err
=
b
.
diskMounter
.
Mount
(
devicePath
,
globalPDPath
,
b
.
fsType
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
os
.
Remove
(
globalPDPath
)
os
.
Remove
(
globalPDPath
)
...
...
pkg/volume/glusterfs/glusterfs.go
View file @
b05cab0b
...
@@ -140,12 +140,12 @@ func (b *glusterfsBuilder) SetUp() error {
...
@@ -140,12 +140,12 @@ func (b *glusterfsBuilder) SetUp() error {
}
}
func
(
b
*
glusterfsBuilder
)
SetUpAt
(
dir
string
)
error
{
func
(
b
*
glusterfsBuilder
)
SetUpAt
(
dir
string
)
error
{
mountpoint
,
err
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
glog
.
V
(
4
)
.
Infof
(
"Glusterfs: mount set up: %s %v %v"
,
dir
,
mountpoi
nt
,
err
)
glog
.
V
(
4
)
.
Infof
(
"Glusterfs: mount set up: %s %v %v"
,
dir
,
!
notM
nt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
return
nil
return
nil
}
}
...
@@ -185,12 +185,12 @@ func (c *glusterfsCleaner) TearDownAt(dir string) error {
...
@@ -185,12 +185,12 @@ func (c *glusterfsCleaner) TearDownAt(dir string) error {
}
}
func
(
c
*
glusterfsCleaner
)
cleanup
(
dir
string
)
error
{
func
(
c
*
glusterfsCleaner
)
cleanup
(
dir
string
)
error
{
mountpoint
,
err
:=
c
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Glusterfs: Error checking IsMountPoint: %v"
,
err
)
glog
.
Errorf
(
"Glusterfs: Error checking Is
LikelyNot
MountPoint: %v"
,
err
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
return
os
.
RemoveAll
(
dir
)
return
os
.
RemoveAll
(
dir
)
}
}
...
@@ -198,12 +198,12 @@ func (c *glusterfsCleaner) cleanup(dir string) error {
...
@@ -198,12 +198,12 @@ func (c *glusterfsCleaner) cleanup(dir string) error {
glog
.
Errorf
(
"Glusterfs: Unmounting failed: %v"
,
err
)
glog
.
Errorf
(
"Glusterfs: Unmounting failed: %v"
,
err
)
return
err
return
err
}
}
mountpoint
,
mntErr
:=
c
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"Glusterfs: Is
Mountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"Glusterfs: Is
LikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
mntErr
return
mntErr
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
if
err
:=
os
.
RemoveAll
(
dir
);
err
!=
nil
{
if
err
:=
os
.
RemoveAll
(
dir
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/volume/iscsi/disk_manager.go
View file @
b05cab0b
...
@@ -36,13 +36,13 @@ type diskManager interface {
...
@@ -36,13 +36,13 @@ type diskManager interface {
func
diskSetUp
(
manager
diskManager
,
b
iscsiDiskBuilder
,
volPath
string
,
mounter
mount
.
Interface
)
error
{
func
diskSetUp
(
manager
diskManager
,
b
iscsiDiskBuilder
,
volPath
string
,
mounter
mount
.
Interface
)
error
{
globalPDPath
:=
manager
.
MakeGlobalPDName
(
*
b
.
iscsiDisk
)
globalPDPath
:=
manager
.
MakeGlobalPDName
(
*
b
.
iscsiDisk
)
// TODO: handle failed mounts here.
// TODO: handle failed mounts here.
mountpoint
,
err
:=
mounter
.
Is
MountPoint
(
volPath
)
notMnt
,
err
:=
mounter
.
IsLikelyNot
MountPoint
(
volPath
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
glog
.
Errorf
(
"cannot validate mountpoint: %s"
,
volPath
)
glog
.
Errorf
(
"cannot validate mountpoint: %s"
,
volPath
)
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
return
nil
return
nil
}
}
if
err
:=
manager
.
AttachDisk
(
b
);
err
!=
nil
{
if
err
:=
manager
.
AttachDisk
(
b
);
err
!=
nil
{
...
@@ -69,12 +69,12 @@ func diskSetUp(manager diskManager, b iscsiDiskBuilder, volPath string, mounter
...
@@ -69,12 +69,12 @@ func diskSetUp(manager diskManager, b iscsiDiskBuilder, volPath string, mounter
// utility to tear down a disk based filesystem
// utility to tear down a disk based filesystem
func
diskTearDown
(
manager
diskManager
,
c
iscsiDiskCleaner
,
volPath
string
,
mounter
mount
.
Interface
)
error
{
func
diskTearDown
(
manager
diskManager
,
c
iscsiDiskCleaner
,
volPath
string
,
mounter
mount
.
Interface
)
error
{
mountpoint
,
err
:=
mounter
.
Is
MountPoint
(
volPath
)
notMnt
,
err
:=
mounter
.
IsLikelyNot
MountPoint
(
volPath
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"cannot validate mountpoint %s"
,
volPath
)
glog
.
Errorf
(
"cannot validate mountpoint %s"
,
volPath
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
return
os
.
Remove
(
volPath
)
return
os
.
Remove
(
volPath
)
}
}
...
@@ -97,12 +97,12 @@ func diskTearDown(manager diskManager, c iscsiDiskCleaner, volPath string, mount
...
@@ -97,12 +97,12 @@ func diskTearDown(manager diskManager, c iscsiDiskCleaner, volPath string, mount
}
}
}
}
mountpoint
,
mntErr
:=
mounter
.
Is
MountPoint
(
volPath
)
notMnt
,
mntErr
:=
mounter
.
IsLikelyNot
MountPoint
(
volPath
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"
isMountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"
IsLikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
if
err
:=
os
.
Remove
(
volPath
);
err
!=
nil
{
if
err
:=
os
.
Remove
(
volPath
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/volume/iscsi/iscsi_util.go
View file @
b05cab0b
...
@@ -101,8 +101,8 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskBuilder) error {
...
@@ -101,8 +101,8 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskBuilder) error {
}
}
// mount it
// mount it
globalPDPath
:=
b
.
manager
.
MakeGlobalPDName
(
*
b
.
iscsiDisk
)
globalPDPath
:=
b
.
manager
.
MakeGlobalPDName
(
*
b
.
iscsiDisk
)
mountpoint
,
err
:=
b
.
mounter
.
Is
MountPoint
(
globalPDPath
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
globalPDPath
)
if
mountpoi
nt
{
if
!
notM
nt
{
glog
.
Infof
(
"iscsi: %s already mounted"
,
globalPDPath
)
glog
.
Infof
(
"iscsi: %s already mounted"
,
globalPDPath
)
return
nil
return
nil
}
}
...
...
pkg/volume/nfs/nfs.go
View file @
b05cab0b
...
@@ -144,12 +144,12 @@ func (b *nfsBuilder) SetUp() error {
...
@@ -144,12 +144,12 @@ func (b *nfsBuilder) SetUp() error {
}
}
func
(
b
*
nfsBuilder
)
SetUpAt
(
dir
string
)
error
{
func
(
b
*
nfsBuilder
)
SetUpAt
(
dir
string
)
error
{
mountpoint
,
err
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
glog
.
V
(
4
)
.
Infof
(
"NFS mount set up: %s %v %v"
,
dir
,
mountpoi
nt
,
err
)
glog
.
V
(
4
)
.
Infof
(
"NFS mount set up: %s %v %v"
,
dir
,
!
notM
nt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
return
nil
return
nil
}
}
os
.
MkdirAll
(
dir
,
0750
)
os
.
MkdirAll
(
dir
,
0750
)
...
@@ -160,22 +160,22 @@ func (b *nfsBuilder) SetUpAt(dir string) error {
...
@@ -160,22 +160,22 @@ func (b *nfsBuilder) SetUpAt(dir string) error {
}
}
err
=
b
.
mounter
.
Mount
(
source
,
dir
,
"nfs"
,
options
)
err
=
b
.
mounter
.
Mount
(
source
,
dir
,
"nfs"
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
mountpoint
,
mntErr
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"Is
Mountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"Is
LikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
if
mntErr
=
b
.
mounter
.
Unmount
(
dir
);
mntErr
!=
nil
{
if
mntErr
=
b
.
mounter
.
Unmount
(
dir
);
mntErr
!=
nil
{
glog
.
Errorf
(
"Failed to unmount: %v"
,
mntErr
)
glog
.
Errorf
(
"Failed to unmount: %v"
,
mntErr
)
return
err
return
err
}
}
mountpoint
,
mntErr
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"Is
Mountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"Is
LikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
// This is very odd, we don't expect it. We'll try again next sync loop.
// This is very odd, we don't expect it. We'll try again next sync loop.
glog
.
Errorf
(
"%s is still mounted, despite call to unmount(). Will try again next sync loop."
,
dir
)
glog
.
Errorf
(
"%s is still mounted, despite call to unmount(). Will try again next sync loop."
,
dir
)
return
err
return
err
...
@@ -208,12 +208,12 @@ func (c *nfsCleaner) TearDown() error {
...
@@ -208,12 +208,12 @@ func (c *nfsCleaner) TearDown() error {
}
}
func
(
c
*
nfsCleaner
)
TearDownAt
(
dir
string
)
error
{
func
(
c
*
nfsCleaner
)
TearDownAt
(
dir
string
)
error
{
mountpoint
,
err
:=
c
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error checking IsMountPoint: %v"
,
err
)
glog
.
Errorf
(
"Error checking Is
LikelyNot
MountPoint: %v"
,
err
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
return
os
.
Remove
(
dir
)
return
os
.
Remove
(
dir
)
}
}
...
@@ -221,12 +221,12 @@ func (c *nfsCleaner) TearDownAt(dir string) error {
...
@@ -221,12 +221,12 @@ func (c *nfsCleaner) TearDownAt(dir string) error {
glog
.
Errorf
(
"Unmounting failed: %v"
,
err
)
glog
.
Errorf
(
"Unmounting failed: %v"
,
err
)
return
err
return
err
}
}
mountpoint
,
mntErr
:=
c
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"Is
Mountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"Is
LikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
mntErr
return
mntErr
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/volume/rbd/disk_manager.go
View file @
b05cab0b
...
@@ -42,13 +42,13 @@ type diskManager interface {
...
@@ -42,13 +42,13 @@ type diskManager interface {
func
diskSetUp
(
manager
diskManager
,
b
rbdBuilder
,
volPath
string
,
mounter
mount
.
Interface
)
error
{
func
diskSetUp
(
manager
diskManager
,
b
rbdBuilder
,
volPath
string
,
mounter
mount
.
Interface
)
error
{
globalPDPath
:=
manager
.
MakeGlobalPDName
(
*
b
.
rbd
)
globalPDPath
:=
manager
.
MakeGlobalPDName
(
*
b
.
rbd
)
// TODO: handle failed mounts here.
// TODO: handle failed mounts here.
mountpoint
,
err
:=
mounter
.
Is
MountPoint
(
volPath
)
notMnt
,
err
:=
mounter
.
IsLikelyNot
MountPoint
(
volPath
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
glog
.
Errorf
(
"cannot validate mountpoint: %s"
,
volPath
)
glog
.
Errorf
(
"cannot validate mountpoint: %s"
,
volPath
)
return
err
return
err
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
return
nil
return
nil
}
}
if
err
:=
manager
.
AttachDisk
(
b
);
err
!=
nil
{
if
err
:=
manager
.
AttachDisk
(
b
);
err
!=
nil
{
...
@@ -75,12 +75,12 @@ func diskSetUp(manager diskManager, b rbdBuilder, volPath string, mounter mount.
...
@@ -75,12 +75,12 @@ func diskSetUp(manager diskManager, b rbdBuilder, volPath string, mounter mount.
// utility to tear down a disk based filesystem
// utility to tear down a disk based filesystem
func
diskTearDown
(
manager
diskManager
,
c
rbdCleaner
,
volPath
string
,
mounter
mount
.
Interface
)
error
{
func
diskTearDown
(
manager
diskManager
,
c
rbdCleaner
,
volPath
string
,
mounter
mount
.
Interface
)
error
{
mountpoint
,
err
:=
mounter
.
Is
MountPoint
(
volPath
)
notMnt
,
err
:=
mounter
.
IsLikelyNot
MountPoint
(
volPath
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"cannot validate mountpoint %s"
,
volPath
)
glog
.
Errorf
(
"cannot validate mountpoint %s"
,
volPath
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
return
os
.
Remove
(
volPath
)
return
os
.
Remove
(
volPath
)
}
}
...
@@ -103,12 +103,12 @@ func diskTearDown(manager diskManager, c rbdCleaner, volPath string, mounter mou
...
@@ -103,12 +103,12 @@ func diskTearDown(manager diskManager, c rbdCleaner, volPath string, mounter mou
}
}
}
}
mountpoint
,
mntErr
:=
mounter
.
Is
MountPoint
(
volPath
)
notMnt
,
mntErr
:=
mounter
.
IsLikelyNot
MountPoint
(
volPath
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"
isMountp
oint check failed: %v"
,
mntErr
)
glog
.
Errorf
(
"
IsLikelyNotMountP
oint check failed: %v"
,
mntErr
)
return
err
return
err
}
}
if
!
mountpoi
nt
{
if
notM
nt
{
if
err
:=
os
.
Remove
(
volPath
);
err
!=
nil
{
if
err
:=
os
.
Remove
(
volPath
);
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/volume/rbd/rbd_util.go
View file @
b05cab0b
...
@@ -215,12 +215,12 @@ func (util *RBDUtil) AttachDisk(b rbdBuilder) error {
...
@@ -215,12 +215,12 @@ func (util *RBDUtil) AttachDisk(b rbdBuilder) error {
}
}
// mount it
// mount it
globalPDPath
:=
b
.
manager
.
MakeGlobalPDName
(
*
b
.
rbd
)
globalPDPath
:=
b
.
manager
.
MakeGlobalPDName
(
*
b
.
rbd
)
mountpoint
,
err
:=
b
.
mounter
.
Is
MountPoint
(
globalPDPath
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
globalPDPath
)
// in the first time, the path shouldn't exist and IsMountPoint is expected to get NotExist
// in the first time, the path shouldn't exist and Is
LikelyNot
MountPoint is expected to get NotExist
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
return
fmt
.
Errorf
(
"rbd: %s failed to check mountpoint"
,
globalPDPath
)
return
fmt
.
Errorf
(
"rbd: %s failed to check mountpoint"
,
globalPDPath
)
}
}
if
mountpoi
nt
{
if
!
notM
nt
{
return
nil
return
nil
}
}
...
...
pkg/volume/secret/secret.go
View file @
b05cab0b
...
@@ -111,7 +111,7 @@ func (b *secretVolumeBuilder) getMetaDir() string {
...
@@ -111,7 +111,7 @@ func (b *secretVolumeBuilder) getMetaDir() string {
}
}
func
(
b
*
secretVolumeBuilder
)
SetUpAt
(
dir
string
)
error
{
func
(
b
*
secretVolumeBuilder
)
SetUpAt
(
dir
string
)
error
{
isMnt
,
err
:=
b
.
mounter
.
Is
MountPoint
(
dir
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNot
MountPoint
(
dir
)
// Getting an os.IsNotExist err from is a contingency; the directory
// Getting an os.IsNotExist err from is a contingency; the directory
// may not exist yet, in which case, setup should run.
// may not exist yet, in which case, setup should run.
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
...
@@ -120,7 +120,7 @@ func (b *secretVolumeBuilder) SetUpAt(dir string) error {
...
@@ -120,7 +120,7 @@ func (b *secretVolumeBuilder) SetUpAt(dir string) error {
// If the plugin readiness file is present for this volume and
// If the plugin readiness file is present for this volume and
// the setup dir is a mountpoint, this volume is already ready.
// the setup dir is a mountpoint, this volume is already ready.
if
volumeutil
.
IsReady
(
b
.
getMetaDir
())
&&
is
Mnt
{
if
volumeutil
.
IsReady
(
b
.
getMetaDir
())
&&
!
not
Mnt
{
return
nil
return
nil
}
}
...
...
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