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
check volume directories instead of mounts for cleanupOrphanedPodDirs #84206
check volume directories instead of mounts for cleanupOrphanedPodDirs #84206
Conversation
I'm looking into build error, when I run |
3f0cd3c
to
c7dd1a9
Compare
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.
A small readability comment from me - otherwise, defer to @jsafrane and the folks who work with volumes more :)
pkg/kubelet/kubelet_pods.go
Outdated
@@ -917,7 +917,7 @@ func (kl *Kubelet) PodResourcesAreReclaimed(pod *v1.Pod, status v1.PodStatus) bo | |||
klog.V(3).Infof("Pod %q is terminated, but some containers have not been cleaned up: %s", format.Pod(pod), statusStr) | |||
return false | |||
} | |||
if kl.podVolumesExist(pod.UID) && !kl.keepTerminatedPodVolumes { | |||
if kl.podVolumesExist(pod.UID, false) && !kl.keepTerminatedPodVolumes { |
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.
Nit: Can we do
checkVolumePaths := false
kl.podVolumesExist(pod.UID, checkVolumePaths)
otherwise, it can be difficult to know what the false
means here.
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.
I added parameter name as a comment for podVolumesExist
call. Thanks!
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.
Thanks for working with me on this small nit :)
This may just be my opinion, but I feel like the comment offers less advantages than the variable name (i.e. is less explicit). Are there advantages to using a comment over a variable that I'm missing?
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.
My IDE(goland) uses similar approach to show the parameter names of the function variables and I see similar usages in kubernetes code base, using an additional variable seems little noisy to me, so I choose adding comment.
But I agree, using variable can be more explicit, I'm neutral, I'll add additional variable instead of comment.
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.
Fixed
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.
Ah gotcha - maybe part of this is that I'm using vim haha :) Anyway, thanks!+
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.
Will let @jsafrane or someone else on sig-storage sign off :)
/test pull-kubernetes-node-e2e-containerd |
c7dd1a9
to
2c1769b
Compare
/cc @cofyc |
2c1769b
to
66edee8
Compare
/test pull-kubernetes-verify |
I am not sure I understand the PR. If we expect that all volume plugins remove their directories in their |
Other callers of But |
Now we assume (in I see you want be on the safe side and it's probably correct at this stage of 1.17, but should we have the same assumption everywhere in the end? /lgtm |
I think so, this's first suggestion of @cofyc. I think we are not confident about to depending the cleanup behavior of plugins in terms of removing directories but currently these methods already depend the cleanup behavior of plugins in terms of unmounting directories. May be @msau42 or @cofyc can express better than me. |
/assign @vishh |
66edee8
to
42fa439
Compare
Hey @jingxu97 I have rebased this PR, PTAL. |
/test pull-kubernetes-bazel-test |
@mucahitkurt sorry for the delay. I think the main logic here is changing the ordering of checking things. There are three types of checking for pod volumes existence, check in-memory cache, check disk directories, and check whether each dir is a mount point or not.
All these checking are used in a number of difference places. Here clearupOrphanedPodDirs, this function is being called by HandlePodCleanups, and its comment mentioned
You might check the issue #31272 to see how we removed the check 3 getMountedVolumePathListFromDisk due to hung issue caused by nfs. However, I think I accidentally introduced this back again here by adding the check of mounted points in podVolumesExist. So the fix here I suggest, instead of calling podVolumesExist, call the following checks
Pls let me know if you have questions about the comments. Thanks! |
0c7105d
to
01deec5
Compare
I keep the new function I replaced the Do you have any concern with the new function?
|
@mucahitkurt Thanks for the update. The function looks good to me. The only thing is the naming, podVolumePathsExist and podVolumesExist, they are too close so it is a little bit hard to understand what's the difference. I am not good at naming either, just a suggestion, e.g., podVolumePathsExist --> podVolumePathsExistInCacheOrDisk |
01deec5
to
d190c9c
Compare
@jingxu97 I renamed with your suggestions, I don't have better alternatives. |
/test pull-kubernetes-e2e-gce-ubuntu-containerd |
pkg/kubelet/kubelet_pods.go
Outdated
@@ -1962,7 +1962,7 @@ func (kl *Kubelet) cleanupOrphanedPodCgroups(pcm cm.PodContainerManager, cgroupP | |||
// parent croup. If the volumes still exist, reduce the cpu shares for any | |||
// process in the cgroup to the minimum value while we wait. if the kubelet | |||
// is configured to keep terminated volumes, we will delete the cgroup and not block. | |||
if podVolumesExist := kl.podVolumesExist(uid); podVolumesExist && !kl.keepTerminatedPodVolumes { | |||
if podVolumesExist := kl.podMountedVolumesExistInCacheOrDisk(uid); podVolumesExist && !kl.keepTerminatedPodVolumes { |
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.
actually here cleanupOrphanedPodCgroups,I think it should be similar to cleanupOrphanedPod, so using podVolumePathsExistInCacheOrDisk. ?
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.
I changed this one to kl. kl.podVolumePathsExistInCacheOrDisk
.
Right now no usage remain for the function kl.podVolumesExist
or with the new name kl.podMountedVolumesExistInCacheOrDisk
. Should I delete this function and all related test codes?
…pOrphanedPodDirs, cleanupOrphanedPodCgroups and PodResourcesAreReclaimed check in-memory cache whether volumes are still mounted and check disk directory for the volume paths instead of mounted volumes check Signed-off-by: Mucahit Kurt <mucahitkurt@gmail.com>
d190c9c
to
6748570
Compare
/test pull-kubernetes-e2e-gce-ubuntu-containerd |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: derekwaynecarr, jsafrane, mucahitkurt 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 |
/retest |
1 similar comment
/retest |
What type of PR is this?
/kind cleanup
/sig storage
What this PR does / why we need it:
Related comment; #72346 (comment)
Change
podVolumesExist
to check volume directories instead of mounted volumes when it's called fromKubelet.cleanupOrphanedPodDirs
. BecausegetMountedVolumePathListFromDisk
does not always produce correct results for mounted volumes andKubelet.cleanupOrphanedPodDirs
already usedgetPodVolumePathListFromDisk
.Which issue(s) this PR fixes:
Related issue #72346
Related issue is quite evolved to fix all
podVolumesExist
method usage, but we may think this PR a fix for the issue #72346 and allpodVolumesExist
usage may be fixed within the scope of issue #72347Special notes for your reviewer:
Does this PR introduce a user-facing change?:
cc @msau42 @cofyc