-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use UnmountMountPoint util to clean up subpaths #71804
Conversation
/assign @jsafrane |
pkg/util/mount/mount_linux.go
Outdated
} else if IsCorruptedMnt(err) { | ||
return true, err | ||
} else { | ||
// TODO: MSAU: should unknown err return pathExists=true for safety? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original function returned false. I think it should actually return true otherwise we may return cleanup success for unknown errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it back to original for now. I see util/file/FileExists also returns false for all errors.
pkg/util/mount/mount_linux.go
Outdated
// PathExists returns true if the specified path exists. | ||
// TODO: MSAU this is not a good name | ||
func PathExists(path string, mounter Interface) (bool, error) { | ||
_, err := mounter.ExistsPath(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may not work for containerized kubelet because it would cause the path to be checked based on the host, not inside the kubelet container.
I will change it back to os.Stat(). I will need to figure out a different way to unit test this.
1492086
to
13852f5
Compare
13852f5
to
d337701
Compare
Still todo:
|
d337701
to
4abcc08
Compare
9dbb523
to
24526e8
Compare
cffda7c
to
7a4f906
Compare
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jingxu97, msau42 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test pull-kubernetes-integration |
/retest |
klog.V(4).Infof("%q is unmounted, deleting the directory", mountPath) | ||
return os.Remove(mountPath) | ||
} | ||
return fmt.Errorf("Failed to unmount path %v", mountPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message here seems inaccurate : the path is likely mount point
…-upstream-release-1.13 Automated cherry pick of #71804: Move unmount volume util from pkg/volume/util to
…-upstream-release-1.12 Automated cherry pick of #71804: Move unmount volume util from pkg/volume/util to
…-upstream-release-1.11 Automated cherry pick of #71804: Move unmount volume util from pkg/volume/util to
return fmt.Errorf("Failed to unmount path %v", mountPath) | ||
} | ||
|
||
// TODO: clean this up to use pkg/util/file/FileExists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more than one version of FileExists:
pkg/kubelet/kubeletconfig/util/files/files.go
vendor/golang.org/x/tools/go/buildutil/util.go
I wonder which one we should use.
What type of PR is this?
/kind bug
What this PR does / why we need it:
UnmountMountPoint is a wrapper util that handles corrupt and stale mounts. Cleaning subpaths mounts should use the util instead of directly calling Unmount.
Which issue(s) this PR fixes:
Fixes #71584
Special notes for your reviewer:
To make this small for backporting, I've tried to do the minimum changes required and will look into refactoring/cleanup afterwards.
Does this PR introduce a user-facing change?: