Skip to content
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

Dont remove volumes when saveVolumeData fails #96021

Merged
merged 3 commits into from Feb 5, 2021

Conversation

huffmanca
Copy link
Contributor

@huffmanca huffmanca commented Oct 29, 2020

What type of PR is this?

/kind bug

What this PR does / why we need it:
This is a continuation of #89464 . It incorporates that author's commit while also adjusting the location of the defer() function to correctly remove.

Which issue(s) this PR fixes:
Fixes # #89281

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

All data is no longer automatically deleted when a failure is detected during creation of the volume data file on a CSI volume. Now only the data file and volume path is removed.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 29, 2020
@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 29, 2020
@huffmanca
Copy link
Contributor Author

/retest

@huffmanca huffmanca changed the title Dont remove volume Dont remove volumes when saveVolumeData fails Oct 29, 2020
@huffmanca
Copy link
Contributor Author

/assign gnufied

if err := saveVolumeData(dataDir, volDataFileName, volData); err != nil {
if removeErr := os.RemoveAll(dataDir); removeErr != nil {
klog.Error(log("failed to remove dir after error [%s]: %v", dataDir, removeErr))
err = saveVolumeData(dataDir, volDataFileName, volData)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do same thing in this file for other places where saveVolumeData is being called followed up by os.RemoveAll? This applies to NewBlockVolumeMapper call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this directory same or different than the one used in MountDevice?

Copy link
Contributor Author

@huffmanca huffmanca Jan 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As best I can tell from testing with the hostpath driver, these appear to be different directories:

  • csi_plugin: created path successfully [/var/lib/kubelet/pods/103bb9c7-0a9f-4958-bb6a-8d05f64420f5/volumes/kubernetes.io~csi/pvc-21228cc8-5669-4c0d-bbdc-d7b4e19dfb79]
  • csi_attacher: created target path successfully [/var/lib/kubelet/plugins/kubernetes.io/csi/pv/pvc-22c63cbf-4e2c-4ca6-b269-d5e44a1f3718/globalmount]

@gnufied
Copy link
Member

gnufied commented Nov 5, 2020

@huffmanca have we tried unit testing this stuff? it might be difficult but worth giving it a shot I think.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 30, 2020
defer func() {
// Only if there was an error and volume operation was considered
// finished, we should remove the directory.
if err != nil && volumetypes.IsOperationFinishedError(err) {
// clean up metadata
klog.Errorf(log("attacher.MountDevice failed: %v", err))
if err := removeMountDir(c.plugin, deviceMountPath); err != nil {
if err := os.RemoveAll(dataDir); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't using os.RemoveAll opposite of what we set out to fix? This means if - saving the volDataFileName fails then we will still end up calling rm -rf on entire data directory?

@huffmanca
Copy link
Contributor Author

/retest

1 similar comment
@huffmanca
Copy link
Contributor Author

/retest

@gnufied
Copy link
Member

gnufied commented Jan 20, 2021

/triage accepted
/lgtm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jan 20, 2021
@gnufied
Copy link
Member

gnufied commented Jan 20, 2021

/priority-important-soon

@gnufied
Copy link
Member

gnufied commented Jan 20, 2021

@huffmanca can you add a release-note plz? I think this is important enough of a change that should be covered in release notes.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Jan 20, 2021
@msau42
Copy link
Member

msau42 commented Feb 4, 2021

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: huffmanca, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 4, 2021
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit f5fb1c9 into kubernetes:master Feb 5, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Feb 5, 2021
k8s-ci-robot added a commit that referenced this pull request Mar 12, 2021
…021-upstream-release-1.20

Automated cherry pick of #96021: Dont remove volumes when saveVolumeData fails
k8s-ci-robot added a commit that referenced this pull request Mar 13, 2021
…021-upstream-release-1.18

Automated cherry pick of #96021 upstream release 1.18
k8s-ci-robot added a commit that referenced this pull request Mar 13, 2021
…021-upstream-release-1.19

Automated cherry pick of #96021 upstream release 1.19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants