mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: make VolumeGroup Create/Delete/AddVolume/RemoveVolume idempotent
Add extra error checking to make sure trying to create an existing volume group does not result in a failure. The same counts for deleting a non-existing volume group, and adding/removing volumes to/from the volume group. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
382d70893d
commit
4acffb5548
@ -237,16 +237,9 @@ func (mgr *rbdManager) CreateVolumeGroup(ctx context.Context, name string) (type
|
||||
}
|
||||
}()
|
||||
|
||||
// check if the volume group exists in the backend
|
||||
existingName, err := vg.GetName(ctx)
|
||||
err = vg.Create(ctx)
|
||||
if err != nil {
|
||||
// the volume group does not exist yet
|
||||
err = vg.Create(ctx, vgName)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create volume group %q: %w", name, err)
|
||||
}
|
||||
} else if existingName != vgName {
|
||||
return nil, fmt.Errorf("volume group id %q has a name mismatch, expected %q, not %q", name, vgName, existingName)
|
||||
return nil, fmt.Errorf("failed to create volume group %q: %w", name, err)
|
||||
}
|
||||
|
||||
return vg, nil
|
||||
|
Reference in New Issue
Block a user