-
Notifications
You must be signed in to change notification settings - Fork 934
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
Add reverter to disk device update & test #14703
base: main
Are you sure you want to change the base?
Add reverter to disk device update & test #14703
Conversation
So that the old ones are still around for use in a reverter Signed-off-by: Wesley Hershberger <[email protected]>
storagePoolVolumeUpdateUsers is used in two places, one of which does not currently use a reverter. If that update fails, the instances/profiles could be left in an inconsistent state. This pushes the reverter inside the function, so that it is safe to call without needing a reverter. My hunch is that this is also slightly less slow in case of failure. Signed-off-by: Wesley Hershberger <[email protected]>
The function now reverts itself Signed-off-by: Wesley Hershberger <[email protected]>
Ensure that renaming local storage volumes in a clustered context doesn't break horribly. This features is clearly not a thoroughly planned semantic corner. We should consider removing it entirely. Signed-off-by: Wesley Hershberger <[email protected]>
b4567c0
to
0c554c7
Compare
revert.Add(func() { | ||
err := inst.Update(dbInst, false) | ||
if err != nil { | ||
logger.Error("Failed to revert instance update", logger.Ctx{ |
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.
nit: we tend to keep these on one line please
|
||
err := doProfileUpdate(s, p, profile.Name, profileID, &profile, original) | ||
if err != nil { | ||
logger.Error("Failed reverting profile update", logger.Ctx{ |
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.
nit: lets keep this on one line for grep/search ability. Thanks
@@ -1924,10 +1924,6 @@ func storagePoolVolumeTypePostMove(s *state.State, r *http.Request, poolName str | |||
return err | |||
} | |||
|
|||
revert.Add(func() { |
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.
the downside with this approach is that now if any subsequent function fails, like newPool.CreateCustomVolumeFromCopy
or pool.DeleteCustomVolume
the updated volume users wont get reverted.
Suggest instead that you keep your updated implementation, but update storagePoolVolumeUpdateUsers
to return a revert.Hook
(like clusterInitMember
).
That way the contract can be that storagePoolVolumeUpdateUsers
will deal with its own reverts if it returns a non-nil error, but if it returns a nil error then it will also return a revert.Hook that can be added to the outer reverter to be undone if a subsequent step fails.
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.
and storagePoolVolumeTypePostRename
can then benefit from that approach to and use an outer reverter too.
This makes
storagePoolVolumeUpdateUsers
safe to call without using a reverter.This also adds a few tests around renaming attached local custom storage volumes in a clustered context. As we've discussed previously (#14681), updating disk devices in profiles isn't necessarily sound. These tests give me a little more confidence that updates behave sanely for local storage volumes in a cluster.
We should consider eliminating this feature altogether and simply making it a hard error to rename a custom storage volume while it is referred to by any disk device.