util: return correct status code for VolumeGroupSnapshot

Fix status codes that are returned for Get/Delete RPC calls
for VolumeGroup/VolumeGroupSnapshot.

Signed-off-by: Nikhil-Ladha <nikhilladha1999@gmail.com>
(cherry picked from commit 18a62ec9de)
This commit is contained in:
Nikhil-Ladha
2024-12-16 10:51:18 +05:30
committed by mergify[bot]
parent 09e298197e
commit e7f5b8a28f
8 changed files with 62 additions and 13 deletions

View File

@ -195,7 +195,7 @@ func (vs *VolumeGroupServer) DeleteVolumeGroup(
vg, err := mgr.GetVolumeGroupByID(ctx, req.GetVolumeGroupId())
if err != nil {
if errors.Is(err, group.ErrRBDGroupNotFound) {
log.DebugLog(ctx, "VolumeGroup %q doesn't exists", req.GetVolumeGroupId())
log.ErrorLog(ctx, "VolumeGroup %q doesn't exists", req.GetVolumeGroupId())
return &volumegroup.DeleteVolumeGroupResponse{}, nil
}
@ -433,9 +433,19 @@ func (vs *VolumeGroupServer) ControllerGetVolumeGroup(
// resolve the volume group
vg, err := mgr.GetVolumeGroupByID(ctx, req.GetVolumeGroupId())
if err != nil {
if errors.Is(err, group.ErrRBDGroupNotFound) {
log.ErrorLog(ctx, "VolumeGroup %q doesn't exists", req.GetVolumeGroupId())
return nil, status.Errorf(
codes.NotFound,
"could not find volume group %q: %s",
req.GetVolumeGroupId(),
err.Error())
}
return nil, status.Errorf(
codes.NotFound,
"could not find volume group %q: %s",
codes.Internal,
"could not fetch volume group %q: %s",
req.GetVolumeGroupId(),
err.Error())
}