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
99a3b4da
Commit
99a3b4da
authored
Dec 27, 2018
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update doCleanSubpaths to use UnmountMountPoint
parent
a2742e76
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
20 deletions
+17
-20
mount_linux.go
pkg/util/mount/mount_linux.go
+17
-20
No files found.
pkg/util/mount/mount_linux.go
View file @
99a3b4da
...
@@ -890,15 +890,22 @@ func doCleanSubPaths(mounter Interface, podDir string, volumeName string) error
...
@@ -890,15 +890,22 @@ func doCleanSubPaths(mounter Interface, podDir string, volumeName string) error
// scan /var/lib/kubelet/pods/<uid>/volume-subpaths/<volume>/<container name>/*
// scan /var/lib/kubelet/pods/<uid>/volume-subpaths/<volume>/<container name>/*
fullContainerDirPath
:=
filepath
.
Join
(
subPathDir
,
containerDir
.
Name
())
fullContainerDirPath
:=
filepath
.
Join
(
subPathDir
,
containerDir
.
Name
())
subPaths
,
err
:=
ioutil
.
ReadDir
(
fullContainerDirPath
)
err
=
filepath
.
Walk
(
fullContainerDirPath
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
err
!=
nil
{
if
path
==
fullContainerDirPath
{
return
fmt
.
Errorf
(
"error reading %s: %s"
,
fullContainerDirPath
,
err
)
// Skip top level directory
}
return
nil
for
_
,
subPath
:=
range
subPaths
{
}
if
err
=
doCleanSubPath
(
mounter
,
fullContainerDirPath
,
subPath
.
Name
());
err
!=
nil
{
// pass through errors and let doCleanSubPath handle them
if
err
=
doCleanSubPath
(
mounter
,
fullContainerDirPath
,
filepath
.
Base
(
path
));
err
!=
nil
{
return
err
return
err
}
}
return
nil
})
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error processing %s: %s"
,
fullContainerDirPath
,
err
)
}
}
// Whole container has been processed, remove its directory.
// Whole container has been processed, remove its directory.
if
err
:=
os
.
Remove
(
fullContainerDirPath
);
err
!=
nil
{
if
err
:=
os
.
Remove
(
fullContainerDirPath
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error deleting %s: %s"
,
fullContainerDirPath
,
err
)
return
fmt
.
Errorf
(
"error deleting %s: %s"
,
fullContainerDirPath
,
err
)
...
@@ -925,21 +932,11 @@ func doCleanSubPath(mounter Interface, fullContainerDirPath, subPathIndex string
...
@@ -925,21 +932,11 @@ func doCleanSubPath(mounter Interface, fullContainerDirPath, subPathIndex string
// process /var/lib/kubelet/pods/<uid>/volume-subpaths/<volume>/<container name>/<subPathName>
// process /var/lib/kubelet/pods/<uid>/volume-subpaths/<volume>/<container name>/<subPathName>
klog
.
V
(
4
)
.
Infof
(
"Cleaning up subpath mounts for subpath %v"
,
subPathIndex
)
klog
.
V
(
4
)
.
Infof
(
"Cleaning up subpath mounts for subpath %v"
,
subPathIndex
)
fullSubPath
:=
filepath
.
Join
(
fullContainerDirPath
,
subPathIndex
)
fullSubPath
:=
filepath
.
Join
(
fullContainerDirPath
,
subPathIndex
)
notMnt
,
err
:=
IsNotMountPoint
(
mounter
,
fullSubPath
)
if
err
!=
nil
{
if
err
:=
UnmountMountPoint
(
fullSubPath
,
mounter
,
true
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error checking %s for mount: %s"
,
fullSubPath
,
err
)
return
fmt
.
Errorf
(
"error unmounting %s: %s"
,
fullSubPath
,
err
)
}
// Unmount it
if
!
notMnt
{
if
err
=
mounter
.
Unmount
(
fullSubPath
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error unmounting %s: %s"
,
fullSubPath
,
err
)
}
klog
.
V
(
5
)
.
Infof
(
"Unmounted %s"
,
fullSubPath
)
}
// Remove it *non*-recursively, just in case there were some hiccups.
if
err
=
os
.
Remove
(
fullSubPath
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error deleting %s: %s"
,
fullSubPath
,
err
)
}
}
klog
.
V
(
5
)
.
Infof
(
"Removed %s"
,
fullSubPath
)
klog
.
V
(
5
)
.
Infof
(
"Removed %s"
,
fullSubPath
)
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