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
11d1289a
Commit
11d1289a
authored
Apr 22, 2016
by
Scott Creeley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add volume and mount logging
parent
10211f4d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
13 deletions
+41
-13
mount_linux.go
pkg/util/mount/mount_linux.go
+9
-1
aws_ebs.go
pkg/volume/aws_ebs/aws_ebs.go
+11
-4
cinder.go
pkg/volume/cinder/cinder.go
+3
-1
flexvolume.go
pkg/volume/flexvolume/flexvolume.go
+10
-6
gce_pd.go
pkg/volume/gce_pd/gce_pd.go
+6
-0
rbd.go
pkg/volume/rbd/rbd.go
+2
-1
No files found.
pkg/util/mount/mount_linux.go
View file @
11d1289a
...
@@ -107,7 +107,8 @@ func doMount(source string, target string, fstype string, options []string) erro
...
@@ -107,7 +107,8 @@ func doMount(source string, target string, fstype string, options []string) erro
command
:=
exec
.
Command
(
"mount"
,
mountArgs
...
)
command
:=
exec
.
Command
(
"mount"
,
mountArgs
...
)
output
,
err
:=
command
.
CombinedOutput
()
output
,
err
:=
command
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Mount failed: %v
\n
Mounting arguments: %s %s %s %v
\n
Output: %s
\n
"
,
glog
.
Errorf
(
"Mount failed: %v
\n
Mounting arguments: %s %s %s %v
\n
Output: %s
\n
"
,
err
,
source
,
target
,
fstype
,
options
,
string
(
output
))
return
fmt
.
Errorf
(
"mount failed: %v
\n
Mounting arguments: %s %s %s %v
\n
Output: %s
\n
"
,
err
,
source
,
target
,
fstype
,
options
,
string
(
output
))
err
,
source
,
target
,
fstype
,
options
,
string
(
output
))
}
}
return
err
return
err
...
@@ -299,6 +300,7 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
...
@@ -299,6 +300,7 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
options
=
append
(
options
,
"defaults"
)
options
=
append
(
options
,
"defaults"
)
// Run fsck on the disk to fix repairable issues
// Run fsck on the disk to fix repairable issues
glog
.
V
(
4
)
.
Infof
(
"Checking for issues with fsck on disk: %s"
,
source
)
args
:=
[]
string
{
"-a"
,
source
}
args
:=
[]
string
{
"-a"
,
source
}
cmd
:=
mounter
.
Runner
.
Command
(
"fsck"
,
args
...
)
cmd
:=
mounter
.
Runner
.
Command
(
"fsck"
,
args
...
)
out
,
err
:=
cmd
.
CombinedOutput
()
out
,
err
:=
cmd
.
CombinedOutput
()
...
@@ -317,6 +319,7 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
...
@@ -317,6 +319,7 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
}
}
// Try to mount the disk
// Try to mount the disk
glog
.
V
(
4
)
.
Infof
(
"Attempting to mount disk: %s %s %s"
,
fstype
,
source
,
target
)
err
=
mounter
.
Interface
.
Mount
(
source
,
target
,
fstype
,
options
)
err
=
mounter
.
Interface
.
Mount
(
source
,
target
,
fstype
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
// It is possible that this disk is not formatted. Double check using diskLooksUnformatted
// It is possible that this disk is not formatted. Double check using diskLooksUnformatted
...
@@ -331,12 +334,15 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
...
@@ -331,12 +334,15 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
if
fstype
==
"ext4"
||
fstype
==
"ext3"
{
if
fstype
==
"ext4"
||
fstype
==
"ext3"
{
args
=
[]
string
{
"-E"
,
"lazy_itable_init=0,lazy_journal_init=0"
,
"-F"
,
source
}
args
=
[]
string
{
"-E"
,
"lazy_itable_init=0,lazy_journal_init=0"
,
"-F"
,
source
}
}
}
glog
.
Infof
(
"Disk %q appears to be unformatted, attempting to format as type: %q with options: %v"
,
source
,
fstype
,
args
)
cmd
:=
mounter
.
Runner
.
Command
(
"mkfs."
+
fstype
,
args
...
)
cmd
:=
mounter
.
Runner
.
Command
(
"mkfs."
+
fstype
,
args
...
)
_
,
err
:=
cmd
.
CombinedOutput
()
_
,
err
:=
cmd
.
CombinedOutput
()
if
err
==
nil
{
if
err
==
nil
{
// the disk has been formatted successfully try to mount it again.
// the disk has been formatted successfully try to mount it again.
glog
.
Infof
(
"Disk successfully formatted (mkfs): %s - %s %s"
,
fstype
,
source
,
target
)
return
mounter
.
Interface
.
Mount
(
source
,
target
,
fstype
,
options
)
return
mounter
.
Interface
.
Mount
(
source
,
target
,
fstype
,
options
)
}
}
glog
.
Errorf
(
"format of disk %q failed: type:(%q) target:(%q) options:(%q)error:(%v)"
,
source
,
fstype
,
target
,
options
,
err
)
return
err
return
err
}
}
}
}
...
@@ -347,6 +353,7 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
...
@@ -347,6 +353,7 @@ func (mounter *SafeFormatAndMount) formatAndMount(source string, target string,
func
(
mounter
*
SafeFormatAndMount
)
diskLooksUnformatted
(
disk
string
)
(
bool
,
error
)
{
func
(
mounter
*
SafeFormatAndMount
)
diskLooksUnformatted
(
disk
string
)
(
bool
,
error
)
{
args
:=
[]
string
{
"-nd"
,
"-o"
,
"FSTYPE"
,
disk
}
args
:=
[]
string
{
"-nd"
,
"-o"
,
"FSTYPE"
,
disk
}
cmd
:=
mounter
.
Runner
.
Command
(
"lsblk"
,
args
...
)
cmd
:=
mounter
.
Runner
.
Command
(
"lsblk"
,
args
...
)
glog
.
V
(
4
)
.
Infof
(
"Attempting to determine if disk %q is formatted using lsblk with args: (%v)"
,
disk
,
args
)
dataOut
,
err
:=
cmd
.
CombinedOutput
()
dataOut
,
err
:=
cmd
.
CombinedOutput
()
output
:=
strings
.
TrimSpace
(
string
(
dataOut
))
output
:=
strings
.
TrimSpace
(
string
(
dataOut
))
...
@@ -354,6 +361,7 @@ func (mounter *SafeFormatAndMount) diskLooksUnformatted(disk string) (bool, erro
...
@@ -354,6 +361,7 @@ func (mounter *SafeFormatAndMount) diskLooksUnformatted(disk string) (bool, erro
// an error if so.
// an error if so.
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Could not determine if disk %q is formatted (%v)"
,
disk
,
err
)
return
false
,
err
return
false
,
err
}
}
...
...
pkg/volume/aws_ebs/aws_ebs.go
View file @
11d1289a
...
@@ -147,6 +147,7 @@ func (plugin *awsElasticBlockStorePlugin) NewDeleter(spec *volume.Spec) (volume.
...
@@ -147,6 +147,7 @@ func (plugin *awsElasticBlockStorePlugin) NewDeleter(spec *volume.Spec) (volume.
func
(
plugin
*
awsElasticBlockStorePlugin
)
newDeleterInternal
(
spec
*
volume
.
Spec
,
manager
ebsManager
)
(
volume
.
Deleter
,
error
)
{
func
(
plugin
*
awsElasticBlockStorePlugin
)
newDeleterInternal
(
spec
*
volume
.
Spec
,
manager
ebsManager
)
(
volume
.
Deleter
,
error
)
{
if
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
AWSElasticBlockStore
==
nil
{
if
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
AWSElasticBlockStore
==
nil
{
glog
.
Errorf
(
"spec.PersistentVolumeSource.AWSElasticBlockStore is nil"
)
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.AWSElasticBlockStore is nil"
)
return
nil
,
fmt
.
Errorf
(
"spec.PersistentVolumeSource.AWSElasticBlockStore is nil"
)
}
}
return
&
awsElasticBlockStoreDeleter
{
return
&
awsElasticBlockStoreDeleter
{
...
@@ -242,6 +243,7 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
...
@@ -242,6 +243,7 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
glog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v"
,
dir
,
!
notMnt
,
err
)
glog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v"
,
dir
,
!
notMnt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
glog
.
Errorf
(
"cannot validate mount point: %s %v"
,
dir
,
err
)
return
err
return
err
}
}
if
!
notMnt
{
if
!
notMnt
{
...
@@ -263,17 +265,17 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
...
@@ -263,17 +265,17 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
if
err
!=
nil
{
if
err
!=
nil
{
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed
: %v"
,
mntErr
)
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed
for %s: %v"
,
dir
,
mntErr
)
return
err
return
err
}
}
if
!
notMnt
{
if
!
notMnt
{
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 %s: %v"
,
dir
,
mntErr
)
return
err
return
err
}
}
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
if
mntErr
!=
nil
{
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed
: %v"
,
mntErr
)
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed
for %s: %v"
,
dir
,
mntErr
)
return
err
return
err
}
}
if
!
notMnt
{
if
!
notMnt
{
...
@@ -283,6 +285,7 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
...
@@ -283,6 +285,7 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
}
}
}
}
os
.
Remove
(
dir
)
os
.
Remove
(
dir
)
glog
.
Errorf
(
"Mount of disk %s failed: %v"
,
dir
,
err
)
return
err
return
err
}
}
...
@@ -290,6 +293,7 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
...
@@ -290,6 +293,7 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
volume
.
SetVolumeOwnership
(
b
,
fsGroup
)
volume
.
SetVolumeOwnership
(
b
,
fsGroup
)
}
}
glog
.
V
(
4
)
.
Infof
(
"Successfully mounted %s"
,
dir
)
return
nil
return
nil
}
}
...
@@ -305,10 +309,12 @@ func getVolumeIDFromGlobalMount(host volume.VolumeHost, globalPath string) (stri
...
@@ -305,10 +309,12 @@ func getVolumeIDFromGlobalMount(host volume.VolumeHost, globalPath string) (stri
basePath
:=
path
.
Join
(
host
.
GetPluginDir
(
awsElasticBlockStorePluginName
),
"mounts"
)
basePath
:=
path
.
Join
(
host
.
GetPluginDir
(
awsElasticBlockStorePluginName
),
"mounts"
)
rel
,
err
:=
filepath
.
Rel
(
basePath
,
globalPath
)
rel
,
err
:=
filepath
.
Rel
(
basePath
,
globalPath
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to get volume id from global mount %s - %v"
,
globalPath
,
err
)
return
""
,
err
return
""
,
err
}
}
if
strings
.
Contains
(
rel
,
"../"
)
{
if
strings
.
Contains
(
rel
,
"../"
)
{
return
""
,
fmt
.
Errorf
(
"Unexpected mount path: "
+
globalPath
)
glog
.
Errorf
(
"Unexpected mount path: %s"
,
globalPath
)
return
""
,
fmt
.
Errorf
(
"unexpected mount path: "
+
globalPath
)
}
}
// Reverse the :// replacement done in makeGlobalPDPath
// Reverse the :// replacement done in makeGlobalPDPath
volumeID
:=
rel
volumeID
:=
rel
...
@@ -391,6 +397,7 @@ var _ volume.Provisioner = &awsElasticBlockStoreProvisioner{}
...
@@ -391,6 +397,7 @@ var _ volume.Provisioner = &awsElasticBlockStoreProvisioner{}
func
(
c
*
awsElasticBlockStoreProvisioner
)
Provision
()
(
*
api
.
PersistentVolume
,
error
)
{
func
(
c
*
awsElasticBlockStoreProvisioner
)
Provision
()
(
*
api
.
PersistentVolume
,
error
)
{
volumeID
,
sizeGB
,
labels
,
err
:=
c
.
manager
.
CreateVolume
(
c
)
volumeID
,
sizeGB
,
labels
,
err
:=
c
.
manager
.
CreateVolume
(
c
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Provision failed: %v"
,
err
)
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/volume/cinder/cinder.go
View file @
11d1289a
...
@@ -277,7 +277,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -277,7 +277,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
// TODO: handle failed mounts here.
// TODO: handle failed mounts here.
notmnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
notmnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
glog
.
V
(
4
)
.
Infof
(
"IsLikelyNotMountPoint failed: %v"
,
err
)
glog
.
Errorf
(
"Cannot validate mount point: %s %v"
,
dir
,
err
)
return
err
return
err
}
}
if
!
notmnt
{
if
!
notmnt
{
...
@@ -299,6 +299,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -299,6 +299,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
}
// Perform a bind mount to the full path to allow duplicate mounts of the same PD.
// Perform a bind mount to the full path to allow duplicate mounts of the same PD.
glog
.
V
(
4
)
.
Infof
(
"Attempting to mount cinder volume %s to %s with options %v"
,
b
.
pdName
,
dir
,
options
)
err
=
b
.
mounter
.
Mount
(
globalPDPath
,
dir
,
""
,
options
)
err
=
b
.
mounter
.
Mount
(
globalPDPath
,
dir
,
""
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
4
)
.
Infof
(
"Mount failed: %v"
,
err
)
glog
.
V
(
4
)
.
Infof
(
"Mount failed: %v"
,
err
)
...
@@ -326,6 +327,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -326,6 +327,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
os
.
Remove
(
dir
)
os
.
Remove
(
dir
)
// TODO: we should really eject the attach/detach out into its own control loop.
// TODO: we should really eject the attach/detach out into its own control loop.
detachDiskLogError
(
b
.
cinderVolume
)
detachDiskLogError
(
b
.
cinderVolume
)
glog
.
Errorf
(
"Failed to mount %s: %v"
,
dir
,
err
)
return
err
return
err
}
}
...
...
pkg/volume/flexvolume/flexvolume.go
View file @
11d1289a
...
@@ -265,7 +265,7 @@ func (f *flexVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -265,7 +265,7 @@ func (f *flexVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
notmnt
,
err
:=
f
.
blockDeviceMounter
.
IsLikelyNotMountPoint
(
dir
)
notmnt
,
err
:=
f
.
blockDeviceMounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
glog
.
Errorf
(
"Cannot validate mount
point: %s"
,
di
r
)
glog
.
Errorf
(
"Cannot validate mount
point: %s %v"
,
dir
,
er
r
)
return
err
return
err
}
}
if
!
notmnt
{
if
!
notmnt
{
...
@@ -290,18 +290,20 @@ func (f *flexVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -290,18 +290,20 @@ func (f *flexVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
f
.
options
[
optionKeySecret
+
"/"
+
name
]
=
secret
f
.
options
[
optionKeySecret
+
"/"
+
name
]
=
secret
}
}
glog
.
V
(
4
)
.
Infof
(
"attempting to attach volume: %s with options %v"
,
f
.
volName
,
f
.
options
)
device
,
err
:=
f
.
manager
.
attach
(
f
)
device
,
err
:=
f
.
manager
.
attach
(
f
)
if
err
!=
nil
{
if
err
!=
nil
{
if
!
isCmdNotSupportedErr
(
err
)
{
if
!
isCmdNotSupportedErr
(
err
)
{
glog
.
Errorf
(
"
F
ailed to attach volume: %s"
,
f
.
volName
)
glog
.
Errorf
(
"
f
ailed to attach volume: %s"
,
f
.
volName
)
return
err
return
err
}
}
// Attach not supported or required. Continue to mount.
// Attach not supported or required. Continue to mount.
}
}
glog
.
V
(
4
)
.
Infof
(
"attempting to mount volume: %s"
,
f
.
volName
)
if
err
:=
f
.
manager
.
mount
(
f
,
device
,
dir
);
err
!=
nil
{
if
err
:=
f
.
manager
.
mount
(
f
,
device
,
dir
);
err
!=
nil
{
if
!
isCmdNotSupportedErr
(
err
)
{
if
!
isCmdNotSupportedErr
(
err
)
{
glog
.
Errorf
(
"
F
ailed to mount volume: %s"
,
f
.
volName
)
glog
.
Errorf
(
"
f
ailed to mount volume: %s"
,
f
.
volName
)
return
err
return
err
}
}
options
:=
make
([]
string
,
0
)
options
:=
make
([]
string
,
0
)
...
@@ -318,13 +320,15 @@ func (f *flexVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -318,13 +320,15 @@ func (f *flexVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
os
.
MkdirAll
(
dir
,
0750
)
os
.
MkdirAll
(
dir
,
0750
)
// Mount not supported by driver. Use core mounting logic.
// Mount not supported by driver. Use core mounting logic.
glog
.
V
(
4
)
.
Infof
(
"attempting to mount the volume: %s to device: %s"
,
f
.
volName
,
device
)
err
=
f
.
blockDeviceMounter
.
Mount
(
string
(
device
),
dir
,
f
.
fsType
,
options
)
err
=
f
.
blockDeviceMounter
.
Mount
(
string
(
device
),
dir
,
f
.
fsType
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"
Failed to mount the volume: %s, device: %s, error: %s"
,
f
.
volName
,
device
,
err
.
Error
()
)
glog
.
Errorf
(
"
failed to mount the volume: %s to device: %s, error: %v"
,
f
.
volName
,
device
,
err
)
return
err
return
err
}
}
}
}
glog
.
V
(
4
)
.
Infof
(
"Successfully mounted volume: %s on device: %s"
,
f
.
volName
,
device
)
return
nil
return
nil
}
}
...
@@ -370,7 +374,7 @@ func (f *flexVolumeUnmounter) TearDownAt(dir string) error {
...
@@ -370,7 +374,7 @@ func (f *flexVolumeUnmounter) TearDownAt(dir string) error {
}
}
// Unmount not supported by the driver. Use core unmount logic.
// Unmount not supported by the driver. Use core unmount logic.
if
err
:=
f
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
if
err
:=
f
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
glog
.
Errorf
(
"Failed to unmount volume: %s, error: %
s"
,
dir
,
err
.
Error
()
)
glog
.
Errorf
(
"Failed to unmount volume: %s, error: %
v"
,
dir
,
err
)
return
err
return
err
}
}
}
}
...
@@ -378,7 +382,7 @@ func (f *flexVolumeUnmounter) TearDownAt(dir string) error {
...
@@ -378,7 +382,7 @@ func (f *flexVolumeUnmounter) TearDownAt(dir string) error {
if
refCount
==
1
{
if
refCount
==
1
{
if
err
:=
f
.
manager
.
detach
(
f
,
device
);
err
!=
nil
{
if
err
:=
f
.
manager
.
detach
(
f
,
device
);
err
!=
nil
{
if
!
isCmdNotSupportedErr
(
err
)
{
if
!
isCmdNotSupportedErr
(
err
)
{
glog
.
Errorf
(
"Failed to teardown volume: %s, error: %
s"
,
dir
,
err
.
Error
()
)
glog
.
Errorf
(
"Failed to teardown volume: %s, error: %
v"
,
dir
,
err
)
return
err
return
err
}
}
// Teardown not supported by driver. Unmount is good enough.
// Teardown not supported by driver. Unmount is good enough.
...
...
pkg/volume/gce_pd/gce_pd.go
View file @
11d1289a
...
@@ -234,6 +234,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -234,6 +234,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
glog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v, pd name %v readOnly %v"
,
dir
,
!
notMnt
,
err
,
b
.
pdName
,
b
.
readOnly
)
glog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v, pd name %v readOnly %v"
,
dir
,
!
notMnt
,
err
,
b
.
pdName
,
b
.
readOnly
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
glog
.
Errorf
(
"cannot validate mount point: %s %v"
,
dir
,
err
)
return
err
return
err
}
}
if
!
notMnt
{
if
!
notMnt
{
...
@@ -241,6 +242,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -241,6 +242,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
}
}
if
err
:=
os
.
MkdirAll
(
dir
,
0750
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
dir
,
0750
);
err
!=
nil
{
glog
.
Errorf
(
"mkdir failed on disk %s (%v)"
,
dir
,
err
)
return
err
return
err
}
}
...
@@ -251,6 +253,8 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -251,6 +253,8 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
}
}
globalPDPath
:=
makeGlobalPDName
(
b
.
plugin
.
host
,
b
.
pdName
)
globalPDPath
:=
makeGlobalPDName
(
b
.
plugin
.
host
,
b
.
pdName
)
glog
.
V
(
4
)
.
Infof
(
"attempting to mount %s"
,
dir
)
err
=
b
.
mounter
.
Mount
(
globalPDPath
,
dir
,
""
,
options
)
err
=
b
.
mounter
.
Mount
(
globalPDPath
,
dir
,
""
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
notMnt
,
mntErr
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
...
@@ -275,6 +279,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -275,6 +279,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
}
}
}
}
os
.
Remove
(
dir
)
os
.
Remove
(
dir
)
glog
.
Errorf
(
"Mount of disk %s failed: %v"
,
dir
,
err
)
return
err
return
err
}
}
...
@@ -282,6 +287,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
...
@@ -282,6 +287,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
volume
.
SetVolumeOwnership
(
b
,
fsGroup
)
volume
.
SetVolumeOwnership
(
b
,
fsGroup
)
}
}
glog
.
V
(
4
)
.
Infof
(
"Successfully mounted %s"
,
dir
)
return
nil
return
nil
}
}
...
...
pkg/volume/rbd/rbd.go
View file @
11d1289a
...
@@ -210,9 +210,10 @@ func (b *rbdMounter) SetUp(fsGroup *int64) error {
...
@@ -210,9 +210,10 @@ func (b *rbdMounter) SetUp(fsGroup *int64) error {
func
(
b
*
rbdMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
rbdMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
// diskSetUp checks mountpoints and prevent repeated calls
// diskSetUp checks mountpoints and prevent repeated calls
glog
.
V
(
4
)
.
Infof
(
"rbd: attempting to SetUp and mount %s"
,
dir
)
err
:=
diskSetUp
(
b
.
manager
,
*
b
,
dir
,
b
.
mounter
,
fsGroup
)
err
:=
diskSetUp
(
b
.
manager
,
*
b
,
dir
,
b
.
mounter
,
fsGroup
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"rbd: failed to setup
"
)
glog
.
Errorf
(
"rbd: failed to setup
mount %s %v"
,
dir
,
err
)
}
}
return
err
return
err
}
}
...
...
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