mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rbd: check if an image is part of a group before adding it
A RBD image can only be part of a single group. While an image is added to a group, check if the image is already part of a group, and return an error in case it is. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
4acffb5548
commit
f9ab14e826
@ -356,12 +356,6 @@ func (vg *volumeGroup) Delete(ctx context.Context) error {
|
||||
func (vg *volumeGroup) AddVolume(ctx context.Context, vol types.Volume) error {
|
||||
err := vol.AddToGroup(ctx, vg)
|
||||
if err != nil {
|
||||
// rados.ErrObjectExists does not match the rbd error (there is no EEXISTS error)
|
||||
if errors.Is(rados.ErrObjectExists, err) || strings.Contains(err.Error(), "ret=-17") {
|
||||
log.DebugLog(ctx, "volume %q is already part of volume group %q: %v", vol, vg, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
return fmt.Errorf("failed to add volume %q to volume group %q: %w", vol, vg, err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user