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
15d44a64
Commit
15d44a64
authored
Dec 27, 2018
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update doCleanSubpaths to use UnmountMountPoint
parent
002a4e33
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 @
15d44a64
...
...
@@ -891,15 +891,22 @@ func doCleanSubPaths(mounter Interface, podDir string, volumeName string) error
// scan /var/lib/kubelet/pods/<uid>/volume-subpaths/<volume>/<container name>/*
fullContainerDirPath
:=
filepath
.
Join
(
subPathDir
,
containerDir
.
Name
())
subPaths
,
err
:=
ioutil
.
ReadDir
(
fullContainerDirPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error reading %s: %s"
,
fullContainerDirPath
,
err
)
}
for
_
,
subPath
:=
range
subPaths
{
if
err
=
doCleanSubPath
(
mounter
,
fullContainerDirPath
,
subPath
.
Name
());
err
!=
nil
{
err
=
filepath
.
Walk
(
fullContainerDirPath
,
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
path
==
fullContainerDirPath
{
// Skip top level directory
return
nil
}
// pass through errors and let doCleanSubPath handle them
if
err
=
doCleanSubPath
(
mounter
,
fullContainerDirPath
,
filepath
.
Base
(
path
));
err
!=
nil
{
return
err
}
return
nil
})
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error processing %s: %s"
,
fullContainerDirPath
,
err
)
}
// Whole container has been processed, remove its directory.
if
err
:=
os
.
Remove
(
fullContainerDirPath
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error deleting %s: %s"
,
fullContainerDirPath
,
err
)
...
...
@@ -926,21 +933,11 @@ func doCleanSubPath(mounter Interface, fullContainerDirPath, subPathIndex string
// process /var/lib/kubelet/pods/<uid>/volume-subpaths/<volume>/<container name>/<subPathName>
klog
.
V
(
4
)
.
Infof
(
"Cleaning up subpath mounts for subpath %v"
,
subPathIndex
)
fullSubPath
:=
filepath
.
Join
(
fullContainerDirPath
,
subPathIndex
)
notMnt
,
err
:=
IsNotMountPoint
(
mounter
,
fullSubPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error checking %s for mount: %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
)
if
err
:=
UnmountMountPoint
(
fullSubPath
,
mounter
,
true
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error unmounting %s: %s"
,
fullSubPath
,
err
)
}
klog
.
V
(
5
)
.
Infof
(
"Removed %s"
,
fullSubPath
)
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