From 0a432b9c8ee0706533008c96a5221e160747aa02 Mon Sep 17 00:00:00 2001 From: Nikhil-Ladha Date: Fri, 30 May 2025 11:31:26 +0530 Subject: [PATCH] rbd: skip comparing volumes in a group if new group is created While calling CreateVolumeGroup RPC, if a new group is being created we can skip comparing volumes in a group because it is redundant. Signed-off-by: Nikhil-Ladha (cherry picked from commit 2217e5cc35564a19f990fbaed98dd3289b6fc89d) --- internal/csi-addons/rbd/volumegroup.go | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/csi-addons/rbd/volumegroup.go b/internal/csi-addons/rbd/volumegroup.go index 1e5e19417..cdf71861b 100644 --- a/internal/csi-addons/rbd/volumegroup.go +++ b/internal/csi-addons/rbd/volumegroup.go @@ -178,22 +178,22 @@ func (vs *VolumeGroupServer) CreateVolumeGroup( } log.DebugLog(ctx, "existing volume group %q has been resolved: %+v", groupName, vg) - } - // TODO: check the number of volumes in the vg, it needs to be empty, or match len(volumes) - matches, err := mgr.CompareVolumesInGroup(ctx, volumes, vg) - if err != nil { - return nil, status.Errorf( - codes.Internal, - "failed to compare %d volumes with volume group %q: %s", - len(volumes), - groupName, - err.Error()) - } else if !matches { - return nil, status.Errorf( - codes.Internal, - "volume group %q does not match with requested volumes", - groupName) + // verify that all the volumes are part of the existing volume group + matches, err := mgr.CompareVolumesInGroup(ctx, volumes, vg) + if err != nil { + return nil, status.Errorf( + codes.Internal, + "failed to compare %d volumes with volume group %q: %s", + len(volumes), + groupName, + err.Error()) + } else if !matches { + return nil, status.Errorf( + codes.Internal, + "volume group %q does not match with requested volumes", + groupName) + } } vols, err := vg.ListVolumes(ctx)