Skip to content

Commit 24f2d77

Browse files
committed
rbd: return group not found error for Get,Delete RPC calls
We should return NotFound status if the group doesn't exists for ControllerGetVolumeGroup RPC call. And, an empty/OK response for DeleteVolumeGroup if the group doesn't exists Signed-off-by: Nikhil-Ladha <nikhilladha1999@gmail.com>
1 parent 7731a91 commit 24f2d77

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

internal/csi-addons/rbd/volumegroup.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"slices"
2323

2424
"github.com/ceph/ceph-csi/internal/rbd"
25+
"github.com/ceph/ceph-csi/internal/rbd/group"
2526
"github.com/ceph/ceph-csi/internal/rbd/types"
2627
"github.com/ceph/ceph-csi/internal/util/log"
2728

@@ -192,6 +193,10 @@ func (vs *VolumeGroupServer) DeleteVolumeGroup(
192193
// resolve the volume group
193194
vg, err := mgr.GetVolumeGroupByID(ctx, req.GetVolumeGroupId())
194195
if err != nil {
196+
if err == group.ErrRBDGroupNotFound {
197+
log.DebugLog(ctx, "VolumeGroup %q doesn't exists", req.GetVolumeGroupId())
198+
return &volumegroup.DeleteVolumeGroupResponse{}, nil
199+
}
195200
return nil, status.Errorf(
196201
codes.NotFound,
197202
"could not find volume group %q: %s",

internal/rbd/group/volume_group.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ import (
3131
"github.com/ceph/ceph-csi/internal/util/log"
3232
)
3333

34-
var ErrRBDGroupNotConnected = errors.New("RBD group is not connected")
34+
var (
35+
ErrRBDGroupNotConnected = errors.New("RBD group is not connected")
36+
ErrRBDGroupNotFound = errors.New("RBD group not found")
37+
)
3538

3639
// volumeGroup handles all requests for 'rbd group' operations.
3740
type volumeGroup struct {
@@ -82,6 +85,11 @@ func GetVolumeGroup(
8285
return nil, fmt.Errorf("failed to get volume attributes for id %q: %w", vg, err)
8386
}
8487

88+
if attrs.GroupName == "" || attrs.CreationTime == nil {
89+
log.ErrorLog(ctx, "volume group with id %v not found", id)
90+
return nil, ErrRBDGroupNotFound
91+
}
92+
8593
var volumes []types.Volume
8694
// it is needed to free the previously allocated volumes
8795
defer func() {

0 commit comments

Comments
 (0)