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

Fix race condition between external-resizer and kubelet #123055

Merged
merged 1 commit into from Feb 1, 2024

Conversation

gnufied
Copy link
Member

@gnufied gnufied commented Jan 31, 2024

This fixes the race condition that could happen because resize controller just finished volume expansion and has only finished marking PV and yet to mark PVC.

The workaround proposed here should not be necessary once RecoverVolumeExpansionFailure goes GA/beta.

#117871

Fix error when trying to expand a volume that does not require node expansion

This fixes the race condition that could happen because
resize controller just finished volume expansiona and has only
finished marking PV and yet to mark PVC.

The workaround proposed here should not be necessary once
RecoverVolumeExpansionFailure goes GA/beta.
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/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 Jan 31, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gnufied

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

@gnufied
Copy link
Member Author

gnufied commented Jan 31, 2024

/sig storage
/triage accepted

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. sig/storage Categorizes an issue or PR as relevant to SIG Storage. triage/accepted Indicates an issue or PR is ready to be actively worked on. area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/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. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 31, 2024
@gnufied
Copy link
Member Author

gnufied commented Jan 31, 2024

/kind bug

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Jan 31, 2024
@xing-yang
Copy link
Contributor

cc @akankshapanse

@nixpanic
Copy link
Contributor

nixpanic commented Feb 1, 2024

The PR looks good to me, but I wonder why there is no check (I might have missed that) on the CSI spec NodeServiceCapability EXPAND_VOLUME type. I expect that such a check nicely prevents #117871 from happening, although probably not the race from #115294...

@akankshapanse
Copy link
Contributor

@gnufied It seems the fix done here is not resolving the exact issue #115294. In current fix, we are not checking for node_expansion_required value returned from the response of ControllerExpandVolume operation. Please point me to the code if this is not the case.

In case of #115294, we have ControllerExpand as well as NodeExpand capability supported at CSI driver but for raw block volumes, NodeExpand is not required and hence the call to it needs to be skipped.
@xing-yang Please correct me if wrong.

@bart0sh bart0sh added this to Triage in SIG Node PR Triage Feb 1, 2024
@gnufied
Copy link
Member Author

gnufied commented Feb 1, 2024

@akankshapanse https://github.com/kubernetes-csi/external-resizer/blob/master/pkg/controller/controller.go#L461 Is where we are checking for return value from ControllerExpandVolume, but the problem is - there could be race between kubelet and external-resizer and hence kubelet can decide to node-expand the volume even though, external-resizer is going to mark entire expansion operation as finished.

A proper fix for this issue requires additional state on PVC and hence we will need RecoverFromVolumeExpansionFailure feature.

If your driver has both ControllerExpandVolume and NodeExpandVolume capability and it is indeed true, your driver may still receive NodeExpandVolume calls for raw block volumes. But once RecoverFromVolumeExpansionFailure feature is enabled, then that should not happen. For now - I will recommend, handling that extraneous NodeExpandVolume call in your driver and returning success immediately because nothing needs to be done on the node side.

@gnufied
Copy link
Member Author

gnufied commented Feb 1, 2024

The PR looks good to me, but I wonder why there is no check (I might have missed that) on the CSI spec NodeServiceCapability EXPAND_VOLUME type.

That is the same capability we are using in this PR to return early, so we are using that feature.

@gnufied
Copy link
Member Author

gnufied commented Feb 1, 2024

Updated the wording about #115294 not getting really fixed here.

@jsafrane
Copy link
Member

jsafrane commented Feb 1, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 1, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: b7c9024540bb807ff762bbe6fbc3010c4773df72

@bart0sh bart0sh moved this from Triage to Done in SIG Node PR Triage Feb 1, 2024
@xing-yang
Copy link
Contributor

@akankshapanse I see that @gnufied has answered your question. It is due to the race between kubelet and external-resizer.

@k8s-ci-robot k8s-ci-robot merged commit 440f11d into kubernetes:master Feb 1, 2024
18 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Feb 1, 2024
@gnufied
Copy link
Member Author

gnufied commented Feb 1, 2024

/cherry-pick release-1.29

@saschagrunert
Copy link
Member

We do not need a CP for 1.27, right?

k8s-ci-robot added a commit that referenced this pull request Mar 1, 2024
…055-upstream-release-1.29

Automated cherry pick of #123055: Fix race condition between external-resizer and kubelet
k8s-ci-robot added a commit that referenced this pull request Mar 1, 2024
…055-upstream-release-1.28

Automated cherry pick of #123055: Fix race condition between external-resizer and kubelet
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. area/kubelet 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/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants