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
do not remove volume dir when saveVolumeData fails #89464
Conversation
Hi @fankangbest. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
@fankangbest thanks for the PR. I think this requires more careful fix because the fix proposed here will leave orphan pod directories when mount fails. See - #72346 for more details. |
/assign @gnufied |
pkg/volume/csi/csi_plugin.go
Outdated
return nil, errors.New(log("failed to save volume info data: %v", err)) | ||
errMsg := log("failed to save volume info data: %v", err) | ||
klog.Error(errMsg) | ||
return nil, errors.New(errMsg) |
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.
sorry for taking time on this but rather than dropping this check altogether can we simple call the implementation of removeMountDir
which should be relatively safe because it only removes data file and then removes with directory without ever calling os.RemoveAll
?
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.
RemoveAll may delete data in the mountpoint, and it is unexpected. I think it is safe to call removeMountDir here because removeMountDir won't delete data.
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.
Yes - can you update this PR to use removeMountDir
?
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.
Sure, I will update the code and do a further test.
return err | ||
errMsg := log("failed to save volume info data: %v", err) | ||
klog.Error(errMsg) | ||
return errors.New(errMsg) |
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.
similar comment as below
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.
removeMountDir() will be called in defer func 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.
correct me if I am wrong but the defer function is not installed yet and hence will not be called when the function returns from 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.
@fankangbest Can you please address this comment? I am happy to have unit test merged later on but we need this fixed before we can merge this.
dec810f
to
ecd7f96
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fankangbest The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
ecd7f96
to
ddda214
Compare
ddda214
to
f8c5159
Compare
@fankangbest: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@fankangbest can we also add some unit tests that exercise the scenario? |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
If saveVolumeData() fails,all data in the volume dir is removed. This will happen when the disk is readonly and the volume is a remote disk.
There is no need to remove all in volume dir. When saveVolumeData fails, just log an error is enough because kubelet will retry to write volDataFileName next time.
Which issue(s) this PR fixes:
Fixes #89281
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: