mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
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>
This commit is contained in:
committed by
mergify[bot]
parent
ca1ccdd9bf
commit
18a62ec9de
@ -61,6 +61,9 @@ var (
|
||||
|
||||
// ErrQuiesceInProgress is returned when quiesce operation is in progress.
|
||||
ErrQuiesceInProgress = coreError.New("quiesce operation is in progress")
|
||||
|
||||
// ErrGroupNotFound is returned when volume group snapshot is not found in the backend.
|
||||
ErrGroupNotFound = coreError.New("volume group snapshot not found")
|
||||
)
|
||||
|
||||
// IsCloneRetryError returns true if the clone error is pending,in-progress
|
||||
|
@ -721,12 +721,16 @@ func (cs *ControllerServer) DeleteVolumeGroupSnapshot(ctx context.Context,
|
||||
|
||||
vgo, vgsi, err := store.NewVolumeGroupOptionsFromID(ctx, req.GetGroupSnapshotId(), cr)
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed to get volume group options: %v", err)
|
||||
err = extractDeleteVolumeGroupError(err)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
if !errors.Is(err, cerrors.ErrGroupNotFound) {
|
||||
log.ErrorLog(ctx, "failed to get volume group options: %v", err)
|
||||
err = extractDeleteVolumeGroupError(err)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
log.ErrorLog(ctx, "VolumeGroupSnapshot %q doesn't exists", req.GetGroupSnapshotId())
|
||||
|
||||
return &csi.DeleteVolumeGroupSnapshotResponse{}, nil
|
||||
}
|
||||
vgo.Destroy()
|
||||
|
@ -172,6 +172,12 @@ func NewVolumeGroupOptionsFromID(
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if groupAttributes.GroupName == "" {
|
||||
log.ErrorLog(ctx, "volume group snapshot with id %v not found", volumeGroupSnapshotID)
|
||||
|
||||
return nil, nil, cerrors.ErrGroupNotFound
|
||||
}
|
||||
|
||||
vgs.RequestName = groupAttributes.RequestName
|
||||
vgs.FsVolumeGroupSnapshotName = groupAttributes.GroupName
|
||||
vgs.VolumeGroupSnapshotID = volumeGroupSnapshotID
|
||||
|
Reference in New Issue
Block a user