Skip to content

Commit

Permalink
mgr/dashboard:delete image fail on dashboard while it has some protec…
Browse files Browse the repository at this point in the history
…ted snapshots

Fixes:  https://tracker.ceph.com/issues/62047
Signed-off-by: teng jie tengjie5@asiainfo.com
  • Loading branch information
tengjie5 committed Aug 9, 2023
1 parent 9851734 commit fdf8607
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/pybind/mgr/dashboard/services/rbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cherrypy
import rados
import rbd
import time

from .. import mgr
from ..exceptions import DashboardException
Expand Down Expand Up @@ -630,9 +631,16 @@ def delete(cls, image_spec):

image = RbdService.get_image(image_spec)
snapshots = image['snapshots']
for snap in snapshots:
RbdSnapshotService.remove_snapshot(image_spec, snap['name'], snap['is_protected'])

if len(snapshots) > 0:
count = 0
for snap in snapshots:
RbdSnapshotService.remove_snapshot(image_spec, snap['name'], snap['is_protected'])
while True:
image = RbdService.get_image(image_spec)
if len(image['snapshots']) <1 or count >30:
break;
time.sleep(1)
count += 1
rbd_inst = rbd.RBD()
return rbd_call(pool_name, namespace, rbd_inst.remove, image_name)

Expand Down

0 comments on commit fdf8607

Please sign in to comment.