mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
rbd: validate IOContext before getting the list of trashed images
`ensureImageCleanup()` can cause a panic when an image was deleted, but the journal still contained a reference. By opening the IOContext before using, an error may be returned instead of a panic when using a `nil` or freed IOContext. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
9267210da4
commit
d33e6b14fe
@ -881,9 +881,9 @@ func (cs *ControllerServer) checkErrAndUndoReserve(
|
||||
}
|
||||
|
||||
if errors.Is(err, ErrImageNotFound) {
|
||||
err = rbdVol.ensureImageCleanup(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
notFoundErr := rbdVol.ensureImageCleanup(ctx)
|
||||
if notFoundErr != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to cleanup image %q: %v", rbdVol, notFoundErr)
|
||||
}
|
||||
} else {
|
||||
// All errors other than ErrImageNotFound should return an error back to the caller
|
||||
@ -1538,11 +1538,6 @@ func cleanUpImageAndSnapReservation(ctx context.Context, rbdSnap *rbdSnapshot, c
|
||||
}
|
||||
defer rbdVol.Destroy(ctx)
|
||||
|
||||
err = rbdVol.openIoctx()
|
||||
if err != nil {
|
||||
return status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
// cleanup the image from trash if the error is image not found.
|
||||
err = rbdVol.ensureImageCleanup(ctx)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user