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
f6a0359c
Commit
f6a0359c
authored
Dec 12, 2018
by
oleksiys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CSI volume unmount and cleanup logic
parent
d582682b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
27 deletions
+3
-27
csi_mounter.go
pkg/volume/csi/csi_mounter.go
+3
-27
No files found.
pkg/volume/csi/csi_mounter.go
View file @
f6a0359c
...
@@ -33,7 +33,6 @@ import (
...
@@ -33,7 +33,6 @@ import (
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/features"
kstrings
"k8s.io/kubernetes/pkg/util/strings"
kstrings
"k8s.io/kubernetes/pkg/util/strings"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util"
)
)
//TODO (vladimirvivien) move this in a central loc later
//TODO (vladimirvivien) move this in a central loc later
...
@@ -289,20 +288,6 @@ func (c *csiMountMgr) TearDown() error {
...
@@ -289,20 +288,6 @@ func (c *csiMountMgr) TearDown() error {
func
(
c
*
csiMountMgr
)
TearDownAt
(
dir
string
)
error
{
func
(
c
*
csiMountMgr
)
TearDownAt
(
dir
string
)
error
{
klog
.
V
(
4
)
.
Infof
(
log
(
"Unmounter.TearDown(%s)"
,
dir
))
klog
.
V
(
4
)
.
Infof
(
log
(
"Unmounter.TearDown(%s)"
,
dir
))
// is dir even mounted ?
// TODO (vladimirvivien) this check may not work for an emptyDir or local storage
// see https://github.com/kubernetes/kubernetes/pull/56836#discussion_r155834524
mounted
,
err
:=
isDirMounted
(
c
.
plugin
,
dir
)
if
err
!=
nil
{
klog
.
Error
(
log
(
"unmounter.Teardown failed while checking mount status for dir [%s]: %v"
,
dir
,
err
))
return
err
}
if
!
mounted
{
klog
.
V
(
4
)
.
Info
(
log
(
"unmounter.Teardown skipping unmount, dir not mounted [%s]"
,
dir
))
return
nil
}
volID
:=
c
.
volumeID
volID
:=
c
.
volumeID
csi
:=
c
.
csiClient
csi
:=
c
.
csiClient
...
@@ -319,7 +304,7 @@ func (c *csiMountMgr) TearDownAt(dir string) error {
...
@@ -319,7 +304,7 @@ func (c *csiMountMgr) TearDownAt(dir string) error {
klog
.
Error
(
log
(
"mounter.TearDownAt failed to clean mount dir [%s]: %v"
,
dir
,
err
))
klog
.
Error
(
log
(
"mounter.TearDownAt failed to clean mount dir [%s]: %v"
,
dir
,
err
))
return
err
return
err
}
}
klog
.
V
(
4
)
.
Infof
(
log
(
"mounte.TearDownAt successfully unmounted dir [%s]"
,
dir
))
klog
.
V
(
4
)
.
Infof
(
log
(
"mounte
r
.TearDownAt successfully unmounted dir [%s]"
,
dir
))
return
nil
return
nil
}
}
...
@@ -375,21 +360,12 @@ func isDirMounted(plug *csiPlugin, dir string) (bool, error) {
...
@@ -375,21 +360,12 @@ func isDirMounted(plug *csiPlugin, dir string) (bool, error) {
// removeMountDir cleans the mount dir when dir is not mounted and removed the volume data file in dir
// removeMountDir cleans the mount dir when dir is not mounted and removed the volume data file in dir
func
removeMountDir
(
plug
*
csiPlugin
,
mountPath
string
)
error
{
func
removeMountDir
(
plug
*
csiPlugin
,
mountPath
string
)
error
{
klog
.
V
(
4
)
.
Info
(
log
(
"removing mount path [%s]"
,
mountPath
))
klog
.
V
(
4
)
.
Info
(
log
(
"removing mount path [%s]"
,
mountPath
))
if
pathExists
,
pathErr
:=
util
.
PathExists
(
mountPath
);
pathErr
!=
nil
{
klog
.
Error
(
log
(
"failed while checking mount path stat [%s]"
,
pathErr
))
return
pathErr
}
else
if
!
pathExists
{
klog
.
Warning
(
log
(
"skipping mount dir removal, path does not exist [%v]"
,
mountPath
))
return
nil
}
mounter
:=
plug
.
host
.
GetMounter
(
plug
.
GetPluginName
())
mnt
,
err
:=
isDirMounted
(
plug
,
mountPath
)
notMnt
,
err
:=
mounter
.
IsLikelyNotMountPoint
(
mountPath
)
if
err
!=
nil
{
if
err
!=
nil
{
klog
.
Error
(
log
(
"mount dir removal failed [%s]: %v"
,
mountPath
,
err
))
return
err
return
err
}
}
if
notM
nt
{
if
!
m
nt
{
klog
.
V
(
4
)
.
Info
(
log
(
"dir not mounted, deleting it [%s]"
,
mountPath
))
klog
.
V
(
4
)
.
Info
(
log
(
"dir not mounted, deleting it [%s]"
,
mountPath
))
if
err
:=
os
.
Remove
(
mountPath
);
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
if
err
:=
os
.
Remove
(
mountPath
);
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
klog
.
Error
(
log
(
"failed to remove dir [%s]: %v"
,
mountPath
,
err
))
klog
.
Error
(
log
(
"failed to remove dir [%s]: %v"
,
mountPath
,
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