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
@ -621,6 +621,11 @@ func isCephMgrSupported(ctx context.Context, clusterID string, err error) bool {
|
||||
// ensureImageCleanup finds image in trash and if found removes it
|
||||
// from trash.
|
||||
func (ri *rbdImage) ensureImageCleanup(ctx context.Context) error {
|
||||
err := ri.openIoctx()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
trashInfoList, err := librbd.GetTrashList(ri.ioctx)
|
||||
if err != nil {
|
||||
log.ErrorLog(ctx, "failed to list images in trash: %v", err)
|
||||
|
Reference in New Issue
Block a user