@@ -78,7 +78,7 @@ func (sp *subpath) PrepareSafeSubpath(subPath Subpath) (newHostPath string, clea
78
78
return newHostPath , cleanupAction , err
79
79
}
80
80
81
- // This implementation is shared between Linux and NsEnter
81
+ // safeOpenSubPath opens subpath and returns its fd.
82
82
func safeOpenSubPath (mounter mount.Interface , subpath Subpath ) (int , error ) {
83
83
if ! mount .PathWithinBase (subpath .Path , subpath .VolumePath ) {
84
84
return - 1 , fmt .Errorf ("subpath %q not within volume path %q" , subpath .Path , subpath .VolumePath )
@@ -92,11 +92,6 @@ func safeOpenSubPath(mounter mount.Interface, subpath Subpath) (int, error) {
92
92
93
93
// prepareSubpathTarget creates target for bind-mount of subpath. It returns
94
94
// "true" when the target already exists and something is mounted there.
95
- // Given Subpath must have all paths with already resolved symlinks and with
96
- // paths relevant to kubelet (when it runs in a container).
97
- // This function is called also by NsEnterMounter. It works because
98
- // /var/lib/kubelet is mounted from the host into the container with Kubelet as
99
- // /var/lib/kubelet too.
100
95
func prepareSubpathTarget (mounter mount.Interface , subpath Subpath ) (bool , string , error ) {
101
96
// Early check for already bind-mounted subpath.
102
97
bindPathTarget := getSubpathBindTarget (subpath )
@@ -237,7 +232,7 @@ func doBindSubPath(mounter mount.Interface, subpath Subpath) (hostPath string, e
237
232
return bindPathTarget , nil
238
233
}
239
234
240
- // This implementation is shared between Linux and NsEnter
235
+ // doCleanSubPaths tears down the subpath bind mounts for a pod
241
236
func doCleanSubPaths (mounter mount.Interface , podDir string , volumeName string ) error {
242
237
// scan /var/lib/kubelet/pods/<uid>/volume-subpaths/<volume>/*
243
238
subPathDir := filepath .Join (podDir , containerSubPathDirectoryName , volumeName )
@@ -372,9 +367,7 @@ func removeEmptyDirs(baseDir, endDir string) error {
372
367
return nil
373
368
}
374
369
375
- // This implementation is shared between Linux and NsEnterMounter. Both pathname
376
- // and base must be either already resolved symlinks or thet will be resolved in
377
- // kubelet's mount namespace (in case it runs containerized).
370
+ // doSafeMakeDir creates a directory at pathname, but only if it is within base.
378
371
func doSafeMakeDir (pathname string , base string , perm os.FileMode ) error {
379
372
klog .V (4 ).Infof ("Creating directory %q within base %q" , pathname , base )
380
373
@@ -523,7 +516,6 @@ func findExistingPrefix(base, pathname string) (string, []string, error) {
523
516
return pathname , []string {}, nil
524
517
}
525
518
526
- // This implementation is shared between Linux and NsEnterMounter
527
519
// Open path and return its fd.
528
520
// Symlinks are disallowed (pathname must already resolve symlinks),
529
521
// and the path must be within the base directory.
0 commit comments