mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-26 15:00:19 +00:00
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>
(cherry picked from commit c7d54ab776
)
This commit is contained in:
parent
8fcb438794
commit
09e298197e
@ -18,10 +18,12 @@ package rbd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"github.com/ceph/ceph-csi/internal/rbd"
|
"github.com/ceph/ceph-csi/internal/rbd"
|
||||||
|
"github.com/ceph/ceph-csi/internal/rbd/group"
|
||||||
"github.com/ceph/ceph-csi/internal/rbd/types"
|
"github.com/ceph/ceph-csi/internal/rbd/types"
|
||||||
"github.com/ceph/ceph-csi/internal/util/log"
|
"github.com/ceph/ceph-csi/internal/util/log"
|
||||||
|
|
||||||
@ -192,9 +194,15 @@ func (vs *VolumeGroupServer) DeleteVolumeGroup(
|
|||||||
// resolve the volume group
|
// resolve the volume group
|
||||||
vg, err := mgr.GetVolumeGroupByID(ctx, req.GetVolumeGroupId())
|
vg, err := mgr.GetVolumeGroupByID(ctx, req.GetVolumeGroupId())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, group.ErrRBDGroupNotFound) {
|
||||||
|
log.DebugLog(ctx, "VolumeGroup %q doesn't exists", req.GetVolumeGroupId())
|
||||||
|
|
||||||
|
return &volumegroup.DeleteVolumeGroupResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
return nil, status.Errorf(
|
return nil, status.Errorf(
|
||||||
codes.NotFound,
|
codes.Internal,
|
||||||
"could not find volume group %q: %s",
|
"could not fetch volume group %q: %s",
|
||||||
req.GetVolumeGroupId(),
|
req.GetVolumeGroupId(),
|
||||||
err.Error())
|
err.Error())
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,12 @@ func (cvg *commonVolumeGroup) getVolumeGroupAttributes(ctx context.Context) (*jo
|
|||||||
attrs = &journal.VolumeGroupAttributes{}
|
attrs = &journal.VolumeGroupAttributes{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if attrs.GroupName == "" || attrs.CreationTime == nil {
|
||||||
|
log.ErrorLog(ctx, "volume group with id %v not found", cvg.id)
|
||||||
|
|
||||||
|
return nil, ErrRBDGroupNotFound
|
||||||
|
}
|
||||||
|
|
||||||
cvg.requestName = attrs.RequestName
|
cvg.requestName = attrs.RequestName
|
||||||
cvg.name = attrs.GroupName
|
cvg.name = attrs.GroupName
|
||||||
cvg.creationTime = attrs.CreationTime
|
cvg.creationTime = attrs.CreationTime
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/ceph/go-ceph/rados"
|
"github.com/ceph/go-ceph/rados"
|
||||||
|
librados "github.com/ceph/go-ceph/rados"
|
||||||
librbd "github.com/ceph/go-ceph/rbd"
|
librbd "github.com/ceph/go-ceph/rbd"
|
||||||
"github.com/container-storage-interface/spec/lib/go/csi"
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||||
"github.com/csi-addons/spec/lib/go/volumegroup"
|
"github.com/csi-addons/spec/lib/go/volumegroup"
|
||||||
@ -31,7 +32,10 @@ import (
|
|||||||
"github.com/ceph/ceph-csi/internal/util/log"
|
"github.com/ceph/ceph-csi/internal/util/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrRBDGroupNotConnected = errors.New("RBD group is not connected")
|
var (
|
||||||
|
ErrRBDGroupNotConnected = fmt.Errorf("%w: RBD group is not connected", librados.ErrNotConnected)
|
||||||
|
ErrRBDGroupNotFound = fmt.Errorf("%w: RBD group not found", librbd.ErrNotFound)
|
||||||
|
)
|
||||||
|
|
||||||
// volumeGroup handles all requests for 'rbd group' operations.
|
// volumeGroup handles all requests for 'rbd group' operations.
|
||||||
type volumeGroup struct {
|
type volumeGroup struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user