Skip to content

Commit

Permalink
lxd: Use storagePoolVolumeUpdateUsers' revert hook
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Hershberger <[email protected]>
  • Loading branch information
MggMuggins committed Dec 20, 2024
1 parent 2064793 commit be43aa7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lxd/storage_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1878,11 +1878,13 @@ func storagePoolVolumeTypePostRename(s *state.State, r *http.Request, poolName s
defer revert.Fail()

// Update devices using the volume in instances and profiles.
err = storagePoolVolumeUpdateUsers(s, projectName, pool.Name(), vol, pool.Name(), &newVol)
cleanup, err := storagePoolVolumeUpdateUsers(s, projectName, pool.Name(), vol, pool.Name(), &newVol)
if err != nil {
return response.SmartError(err)
}

revert.Add(cleanup)

// Use an empty operation for this sync response to pass the requestor
op := &operations.Operation{}
op.SetRequestor(r)
Expand Down Expand Up @@ -1919,14 +1921,12 @@ func storagePoolVolumeTypePostMove(s *state.State, r *http.Request, poolName str
defer revert.Fail()

// Update devices using the volume in instances and profiles.
err = storagePoolVolumeUpdateUsers(s, requestProjectName, pool.Name(), vol, newPool.Name(), &newVol)
cleanup, err := storagePoolVolumeUpdateUsers(s, requestProjectName, pool.Name(), vol, newPool.Name(), &newVol)
if err != nil {
return err
}

revert.Add(func() {
_ = storagePoolVolumeUpdateUsers(s, projectName, newPool.Name(), &newVol, pool.Name(), vol)
})
revert.Add(cleanup)

// Provide empty description and nil config to instruct CreateCustomVolumeFromCopy to copy it
// from source volume.
Expand Down

0 comments on commit be43aa7

Please sign in to comment.