Backport of CSI: track node claim before staging to prevent interleaved unstage into release/1.7.x #20610
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport
This PR is auto-generated from #20550 to be assessed for backporting due to the inclusion of the label backport/1.7.x.
The below text is copied from the body of the original PR.
The CSI hook for each allocation that claims a volume runs concurrently. If a call to
MountVolume
happens at the same time as a call toUnmountVolume
for the same volume, it's possible for the second alloc to detect the volume has already been staged, then for the original alloc to unpublish and unstage it, only for the second alloc to then attempt to publish a volume that's been unstaged.The usage tracker on the volume manager was intended to prevent this behavior but the call to claim the volume was made only after staging and publishing was complete. Move the call to claim the volume for the usage tracker to the top of the
MountVolume
workflow to prevent it from being unstaged until all consuming allocations have calledUnmountVolume
.Fixes: #20424
Note this PR currently contains everything in #20532 because they'd otherwise conflict. Once that's been merged I'll rebase on main and take this out of draft. The actual changes are in c01986bDoneOverview of commits