mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-23 23:00:19 +00:00
cleanup: prevent panic in cleanUpSnapshot
While cleaning up snapshots, not all object may exist after a partial
provisioning attempt. In case objects are missing, do not try to delete
them.
Fixes: #2192
Signed-off-by: Niels de Vos <ndevos@redhat.com>
(cherry picked from commit 0ee0c12027
)
This commit is contained in:
parent
d8d46575a1
commit
14e5a5cfa2
@ -61,21 +61,29 @@ func createRBDClone(ctx context.Context, parentVol, cloneRbdVol *rbdVolume, snap
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cleanUpSnapshot removes the RBD-snapshot (rbdSnap) from the RBD-image
|
||||||
|
// (parentVol) and deletes the RBD-image rbdVol.
|
||||||
func cleanUpSnapshot(ctx context.Context, parentVol *rbdVolume, rbdSnap *rbdSnapshot, rbdVol *rbdVolume, cr *util.Credentials) error {
|
func cleanUpSnapshot(ctx context.Context, parentVol *rbdVolume, rbdSnap *rbdSnapshot, rbdVol *rbdVolume, cr *util.Credentials) error {
|
||||||
err := parentVol.deleteSnapshot(ctx, rbdSnap)
|
if parentVol != nil && rbdSnap != nil {
|
||||||
if err != nil {
|
err := parentVol.deleteSnapshot(ctx, rbdSnap)
|
||||||
if !errors.Is(err, ErrSnapNotFound) {
|
if err != nil {
|
||||||
util.ErrorLog(ctx, "failed to delete snapshot: %v", err)
|
if !errors.Is(err, ErrSnapNotFound) {
|
||||||
return err
|
util.ErrorLog(ctx, "failed to delete snapshot %q: %v", rbdSnap, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = deleteImage(ctx, rbdVol, cr)
|
|
||||||
if err != nil {
|
if rbdVol != nil {
|
||||||
if !errors.Is(err, ErrImageNotFound) {
|
err := deleteImage(ctx, rbdVol, cr)
|
||||||
util.ErrorLog(ctx, "failed to delete rbd image: %s/%s with error: %v", rbdVol.Pool, rbdVol.VolName, err)
|
if err != nil {
|
||||||
return err
|
if !errors.Is(err, ErrImageNotFound) {
|
||||||
|
util.ErrorLog(ctx, "failed to delete rbd image %q with error: %v", rbdVol, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user