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
c14d47df
Commit
c14d47df
authored
Dec 19, 2016
by
rkouj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use common unmount util func for TearDownAt()
parent
def80227
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
24 additions
and
214 deletions
+24
-214
aws_ebs.go
pkg/volume/aws_ebs/aws_ebs.go
+2
-27
BUILD
pkg/volume/azure_file/BUILD
+1
-0
azure_file.go
pkg/volume/azure_file/azure_file.go
+2
-25
BUILD
pkg/volume/cephfs/BUILD
+1
-0
cephfs.go
pkg/volume/cephfs/cephfs.go
+3
-27
BUILD
pkg/volume/flocker/BUILD
+1
-0
flocker.go
pkg/volume/flocker/flocker.go
+2
-19
gce_pd.go
pkg/volume/gce_pd/gce_pd.go
+2
-19
glusterfs.go
pkg/volume/glusterfs/glusterfs.go
+2
-28
BUILD
pkg/volume/nfs/BUILD
+1
-0
nfs.go
pkg/volume/nfs/nfs.go
+2
-25
photon_pd.go
pkg/volume/photon_pd/photon_pd.go
+2
-23
util.go
pkg/volume/util/util.go
+1
-1
vsphere_volume.go
pkg/volume/vsphere_volume/vsphere_volume.go
+2
-20
No files found.
pkg/volume/aws_ebs/aws_ebs.go
View file @
c14d47df
...
...
@@ -33,6 +33,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -393,33 +394,7 @@ func (c *awsElasticBlockStoreUnmounter) TearDown() error {
// Unmounts the bind mount
func
(
c
*
awsElasticBlockStoreUnmounter
)
TearDownAt
(
dir
string
)
error
{
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error checking if mountpoint "
,
dir
,
": "
,
err
)
return
err
}
if
notMnt
{
glog
.
V
(
2
)
.
Info
(
"Not mountpoint, deleting"
)
return
os
.
Remove
(
dir
)
}
// Unmount the bind-mount inside this pod
if
err
:=
c
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error unmounting dir "
,
dir
,
": "
,
err
)
return
err
}
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed: %v"
,
mntErr
)
return
err
}
if
notMnt
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
glog
.
V
(
2
)
.
Info
(
"Error removing mountpoint "
,
dir
,
": "
,
err
)
return
err
}
}
return
nil
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
type
awsElasticBlockStoreDeleter
struct
{
...
...
pkg/volume/azure_file/BUILD
View file @
c14d47df
...
...
@@ -23,6 +23,7 @@ go_library(
"//pkg/util/mount:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/util:go_default_library",
"//vendor:github.com/golang/glog",
],
)
...
...
pkg/volume/azure_file/azure_file.go
View file @
c14d47df
...
...
@@ -27,6 +27,7 @@ import (
"k8s.io/kubernetes/pkg/volume"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/volume/util"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -240,31 +241,7 @@ func (c *azureFileUnmounter) TearDown() error {
}
func
(
c
*
azureFileUnmounter
)
TearDownAt
(
dir
string
)
error
{
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
{
glog
.
Errorf
(
"Error checking IsLikelyNotMountPoint: %v"
,
err
)
return
err
}
if
notMnt
{
return
os
.
Remove
(
dir
)
}
if
err
:=
c
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
glog
.
Errorf
(
"Unmounting failed: %v"
,
err
)
return
err
}
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed: %v"
,
mntErr
)
return
mntErr
}
if
notMnt
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
return
err
}
}
return
nil
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
func
getVolumeSource
(
...
...
pkg/volume/cephfs/BUILD
View file @
c14d47df
...
...
@@ -22,6 +22,7 @@ go_library(
"//pkg/util/mount:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/util:go_default_library",
"//vendor:github.com/golang/glog",
],
)
...
...
pkg/volume/cephfs/cephfs.go
View file @
c14d47df
...
...
@@ -28,6 +28,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -227,7 +228,7 @@ func (cephfsVolume *cephfsMounter) SetUpAt(dir string, fsGroup *int64) error {
}
// cleanup upon failure
cephfsVolume
.
cleanup
(
di
r
)
util
.
UnmountPath
(
dir
,
cephfsVolume
.
mounte
r
)
// return error
return
err
}
...
...
@@ -245,7 +246,7 @@ func (cephfsVolume *cephfsUnmounter) TearDown() error {
// TearDownAt unmounts the bind mount
func
(
cephfsVolume
*
cephfsUnmounter
)
TearDownAt
(
dir
string
)
error
{
return
cephfsVolume
.
cleanup
(
di
r
)
return
util
.
UnmountPath
(
dir
,
cephfsVolume
.
mounte
r
)
}
// GatePath creates global mount path
...
...
@@ -254,31 +255,6 @@ func (cephfsVolume *cephfs) GetPath() string {
return
cephfsVolume
.
plugin
.
host
.
GetPodVolumeDir
(
cephfsVolume
.
podUID
,
utilstrings
.
EscapeQualifiedNameForDisk
(
name
),
cephfsVolume
.
volName
)
}
func
(
cephfsVolume
*
cephfs
)
cleanup
(
dir
string
)
error
{
noMnt
,
err
:=
cephfsVolume
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
return
fmt
.
Errorf
(
"CephFS: Error checking IsLikelyNotMountPoint: %v"
,
err
)
}
if
noMnt
{
return
os
.
RemoveAll
(
dir
)
}
if
err
:=
cephfsVolume
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"CephFS: Unmounting failed: %v"
,
err
)
}
noMnt
,
mntErr
:=
cephfsVolume
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
return
fmt
.
Errorf
(
"CephFS: IsMountpoint check failed: %v"
,
mntErr
)
}
if
noMnt
{
if
err
:=
os
.
RemoveAll
(
dir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"CephFS: removeAll %s/%v"
,
dir
,
err
)
}
}
return
nil
}
func
(
cephfsVolume
*
cephfs
)
execMount
(
mountpoint
string
)
error
{
// cephfs mount option
ceph_opt
:=
""
...
...
pkg/volume/flocker/BUILD
View file @
c14d47df
...
...
@@ -26,6 +26,7 @@ go_library(
"//pkg/util/rand:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/util:go_default_library",
"//vendor:github.com/clusterhq/flocker-go",
"//vendor:github.com/golang/glog",
],
...
...
pkg/volume/flocker/flocker.go
View file @
c14d47df
...
...
@@ -31,6 +31,7 @@ import (
"k8s.io/kubernetes/pkg/volume"
flockerapi
"github.com/clusterhq/flocker-go"
"k8s.io/kubernetes/pkg/volume/util"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -421,25 +422,7 @@ func (c *flockerVolumeUnmounter) TearDown() error {
// TearDownAt unmounts the bind mount
func
(
c
*
flockerVolumeUnmounter
)
TearDownAt
(
dir
string
)
error
{
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
{
return
err
}
if
notMnt
{
return
os
.
Remove
(
dir
)
}
if
err
:=
c
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
return
err
}
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
glog
.
Errorf
(
"isLikelyNotMountPoint check failed: %v"
,
mntErr
)
return
err
}
if
notMnt
{
return
os
.
Remove
(
dir
)
}
return
fmt
.
Errorf
(
"Failed to unmount volume dir"
)
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
func
(
plugin
*
flockerPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
...
...
pkg/volume/gce_pd/gce_pd.go
View file @
c14d47df
...
...
@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -339,25 +340,7 @@ func (c *gcePersistentDiskUnmounter) TearDown() error {
// TearDownAt unmounts the bind mount
func
(
c
*
gcePersistentDiskUnmounter
)
TearDownAt
(
dir
string
)
error
{
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
{
return
err
}
if
notMnt
{
return
os
.
Remove
(
dir
)
}
if
err
:=
c
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
return
err
}
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed: %v"
,
mntErr
)
return
err
}
if
notMnt
{
return
os
.
Remove
(
dir
)
}
return
fmt
.
Errorf
(
"Failed to unmount volume dir"
)
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
type
gcePersistentDiskDeleter
struct
{
...
...
pkg/volume/glusterfs/glusterfs.go
View file @
c14d47df
...
...
@@ -257,8 +257,7 @@ func (b *glusterfsMounter) SetUpAt(dir string, fsGroup *int64) error {
}
// Cleanup upon failure.
c
:=
&
glusterfsUnmounter
{
b
.
glusterfs
}
c
.
cleanup
(
dir
)
volutil
.
UnmountPath
(
dir
,
b
.
mounter
)
return
err
}
...
...
@@ -278,32 +277,7 @@ func (c *glusterfsUnmounter) TearDown() error {
}
func
(
c
*
glusterfsUnmounter
)
TearDownAt
(
dir
string
)
error
{
return
c
.
cleanup
(
dir
)
}
func
(
c
*
glusterfsUnmounter
)
cleanup
(
dir
string
)
error
{
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"glusterfs: Error checking IsLikelyNotMountPoint: %v"
,
err
)
}
if
notMnt
{
return
os
.
RemoveAll
(
dir
)
}
if
err
:=
c
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"glusterfs: Unmounting failed: %v"
,
err
)
}
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
return
fmt
.
Errorf
(
"glusterfs: IsLikelyNotMountPoint check failed: %v"
,
mntErr
)
}
if
notMnt
{
if
err
:=
os
.
RemoveAll
(
dir
);
err
!=
nil
{
return
fmt
.
Errorf
(
"glusterfs: RemoveAll failed: %v"
,
err
)
}
}
return
nil
return
volutil
.
UnmountPath
(
dir
,
c
.
mounter
)
}
func
(
b
*
glusterfsMounter
)
setUpAtInternal
(
dir
string
)
error
{
...
...
pkg/volume/nfs/BUILD
View file @
c14d47df
...
...
@@ -23,6 +23,7 @@ go_library(
"//pkg/util/mount:go_default_library",
"//pkg/util/strings:go_default_library",
"//pkg/volume:go_default_library",
"//pkg/volume/util:go_default_library",
"//vendor:github.com/golang/glog",
],
)
...
...
pkg/volume/nfs/nfs.go
View file @
c14d47df
...
...
@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -270,31 +271,7 @@ func (c *nfsUnmounter) TearDown() error {
}
func
(
c
*
nfsUnmounter
)
TearDownAt
(
dir
string
)
error
{
notMnt
,
err
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
{
glog
.
Errorf
(
"Error checking IsLikelyNotMountPoint: %v"
,
err
)
return
err
}
if
notMnt
{
return
os
.
Remove
(
dir
)
}
if
err
:=
c
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
glog
.
Errorf
(
"Unmounting failed: %v"
,
err
)
return
err
}
notMnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed: %v"
,
mntErr
)
return
mntErr
}
if
notMnt
{
if
err
:=
os
.
Remove
(
dir
);
err
!=
nil
{
return
err
}
}
return
nil
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
func
newRecycler
(
pvName
string
,
spec
*
volume
.
Spec
,
eventRecorder
volume
.
RecycleEventRecorder
,
host
volume
.
VolumeHost
,
volumeConfig
volume
.
VolumeConfig
)
(
volume
.
Recycler
,
error
)
{
...
...
pkg/volume/photon_pd/photon_pd.go
View file @
c14d47df
...
...
@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -264,29 +265,7 @@ func (c *photonPersistentDiskUnmounter) TearDown() error {
// Unmounts the bind mount, and detaches the disk only if the PD
// resource was the last reference to that disk on the kubelet.
func
(
c
*
photonPersistentDiskUnmounter
)
TearDownAt
(
dir
string
)
error
{
glog
.
V
(
4
)
.
Infof
(
"Photon Controller Volume TearDown of %s"
,
dir
)
notmnt
,
err
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
{
return
err
}
if
notmnt
{
return
os
.
Remove
(
dir
)
}
if
err
:=
c
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
glog
.
Errorf
(
"Unmount failed: %v"
,
err
)
return
err
}
notmnt
,
mntErr
:=
c
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed: %v"
,
mntErr
)
return
err
}
if
notmnt
{
return
os
.
Remove
(
dir
)
}
return
fmt
.
Errorf
(
"Failed to unmount volume dir"
)
return
util
.
UnmountPath
(
dir
,
c
.
mounter
)
}
func
makeGlobalPDPath
(
host
volume
.
VolumeHost
,
devName
string
)
string
{
...
...
pkg/volume/util/util.go
View file @
c14d47df
...
...
@@ -98,7 +98,7 @@ func UnmountPath(mountPath string, mounter mount.Interface) error {
glog
.
V
(
4
)
.
Infof
(
"%q is unmounted, deleting the directory"
,
mountPath
)
return
os
.
Remove
(
mountPath
)
}
return
nil
return
fmt
.
Errorf
(
"Failed to unmount path %v"
,
mountPath
)
}
// PathExists returns true if the specified path exists.
...
...
pkg/volume/vsphere_volume/vsphere_volume.go
View file @
c14d47df
...
...
@@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
utilstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
// This is the primary entrypoint for volume plugins.
...
...
@@ -262,26 +263,7 @@ func (v *vsphereVolumeUnmounter) TearDown() error {
// Unmounts the bind mount, and detaches the disk only if the PD
// resource was the last reference to that disk on the kubelet.
func
(
v
*
vsphereVolumeUnmounter
)
TearDownAt
(
dir
string
)
error
{
glog
.
V
(
5
)
.
Infof
(
"vSphere Volume TearDown of %s"
,
dir
)
notMnt
,
err
:=
v
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
err
!=
nil
{
return
err
}
if
notMnt
{
return
os
.
Remove
(
dir
)
}
if
err
:=
v
.
mounter
.
Unmount
(
dir
);
err
!=
nil
{
return
err
}
notMnt
,
mntErr
:=
v
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
if
mntErr
!=
nil
{
glog
.
Errorf
(
"IsLikelyNotMountPoint check failed: %v"
,
mntErr
)
return
err
}
if
notMnt
{
return
os
.
Remove
(
dir
)
}
return
fmt
.
Errorf
(
"Failed to unmount volume dir"
)
return
util
.
UnmountPath
(
dir
,
v
.
mounter
)
}
func
makeGlobalPDPath
(
host
volume
.
VolumeHost
,
devName
string
)
string
{
...
...
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