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

csi: fix volume updating behavior #18588

Merged
merged 1 commit into from
Sep 26, 2023
Merged

csi: fix volume updating behavior #18588

merged 1 commit into from
Sep 26, 2023

Conversation

gulducat
Copy link
Member

fix for part of: c6dbba7 (specifically around here)
which allowed updating volumes while in use,
because CSI expand may occur while in use.
but it mistakenly stopped copying other
important values that may be updated
whether in use or not.

this moves some of the in-use validation to
happen during Merge(), before writing to state,
leaving UpsertCSIVolume with only minimal final
sanity-checking.

fix for part of: c6dbba7
which allowed updating volumes while in use,
because CSI expand may occur while in use.
but it mistakenly stopped copying other
important values that may be updated
whether in use or not.

this moves some of the in-use validation to
happen during Merge(), before writing to state,
leaving UpsertCSIVolume with only minimal final
sanity-checking.
@gulducat gulducat added the backport/1.6.x backport to 1.6.x release line label Sep 26, 2023
Comment on lines -2431 to -2438

// Update fields that are safe to change while volume is being used.
if err := old.UpdateSafeFields(v); err != nil {
return fmt.Errorf("unable to update in-use volume: %w", err)
}
v = old
v.ModifyIndex = index

Copy link
Member

Choose a reason for hiding this comment

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

It looks like we've moved the logic we wanted here into Merge, but then don't we need to add the call to Merge here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nah, we validate and build up new CSIVolume(s) in the register/create flows via reconcileVolume -> Merge prior to UpsertCSIVolume here. Validation should always happen before getting this far, so "store this in state please" (this upsert method) only handles writing state (and a couple remaining validations above that I opted not to touch).

Copy link
Member Author

Choose a reason for hiding this comment

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

It's that v = old line on 2436 that made any updating necessary here (via UpdateSafeFields), but that was the source of other intended updates not getting saved. Without v = old, old is used only for some last-minute sanity-checking, then the already-merged-earlier volume provided by the caller is what gets committed to state.

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM!

@gulducat gulducat merged commit 9b74e11 into main Sep 26, 2023
23 checks passed
@gulducat gulducat deleted the csi-fix-volume-updates branch September 26, 2023 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.6.x backport to 1.6.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants