Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mgr/dashboard: exclude cloned-deleted RBD snaps #57151

Merged
merged 1 commit into from
May 2, 2024

Conversation

epuertat
Copy link
Member

@epuertat epuertat commented Apr 30, 2024

Fixes: https://tracker.ceph.com/issues/65698

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@epuertat epuertat requested a review from a team as a code owner April 30, 2024 08:53
@epuertat epuertat requested review from nizamial09 and Pegonzal and removed request for a team April 30, 2024 08:53
@epuertat epuertat requested a review from idryomov April 30, 2024 08:56
@epuertat
Copy link
Member Author

Manually tested, and it works:
image

@idryomov I remember you said that, besides setting ceph osd set-require-min-compat-client mimic --yes-i-really-mean-it, there was another way to trigger this behaviour. But I couldn't find it: the RBD image format was v2 already, and I don't see any option in rbd snap create and rbd clone for this.

@@ -360,6 +360,10 @@ def _rbd_image(cls, ioctx, pool_name, namespace, image_name, # pylint: disable=
# snapshots
stat['snapshots'] = []
for snap in img.list_snaps():
# Skip trash snapshots (cloned-and-then-deleted format v2 snapshots)
if snap['namespace'] == rbd.RBD_SNAP_NAMESPACE_TYPE_TRASH:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yesterday I said that

Hiding these snapshots such that there is no trace of them at all is probably not a good idea

but, going by the screenshot, this appears to do exactly that... How about:

  • skipping img.is_protected_snap() call in this case, just like it's skipped in case of snapshot-based mirroring
  • replacing img.set_snap(snap['name']) call with img.set_snap_by_id(snap['id'])

I'm wondering if img.list_children() would "just work" in that case -- displaying such a snapshot and its children is much better than hiding all of that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • skipping img.is_protected_snap() call in this case, just like it's skipped in case of snapshot-based mirroring

If I'm reading this right, snap['is_protected'] is left to be None in case snapshot-based mirroring. This could be improved -- since only regular user snapshots can be protected, I'd write it as follows:

snap['is_protected'] = False
if snap['namespace'] == rbd.RBD_SNAP_NAMESPACE_TYPE_USER:
    snap['is_protected'] = img.is_protected_snap(snap['name'])

This would cover all types of snapshots in a generic way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiding these snapshots such that there is no trace of them at all is probably not a good idea

Yup, @idryomov, I knew, but given this should be backported ASAP to all active releases I wanted:

  • A minimal/portable change (no changes to the API),
  • Something that matches the default output of rbd snap ls.

If I don't do this way, whenever a user deletes a snapshot with clones, they'll continue seeing that snapshot. I'd rather display the deleted snapshot in the Trash section:

image

But rbd trash only works for images, right?

BTW, (CC @nizamial09) IMHO the /api/block/{image} endpoint tries to do too many things (iterate through all snapshots and children, calculate the real Image usage with diff_iterate()), which results in a very heavyweight endpoint. We should probably add endpoints for the snapshots (/api/block/{image}/snapshot) and a new query param (minimal=<bool>) to retrieve only the basic RBD Image info.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW @idryomov I'll apply this snippet you shared. Thanks!:

snap['is_protected'] = False
if snap['namespace'] == rbd.RBD_SNAP_NAMESPACE_TYPE_USER:
    snap['is_protected'] = img.is_protected_snap(snap['name'])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiding these snapshots such that there is no trace of them at all is probably not a good idea

Yup, @idryomov, I knew, but given this should be backported ASAP to all active releases I wanted:

  • A minimal/portable change (no changes to the API),

By the change to the API, are you referring to adding a parameter which would be driven by a toggle in the GUI corresponding to --all flag in the CLI?

  • Something that matches the default output of rbd snap ls.

I'm not convinced that having rbd snap ls hide such snapshots by default was a good idea... So much so that I wouldn't suggest replicating it.

Also, note that the behavior with this PR as is wouldn't be equivalent to rbd snap ls output: rbd snap ls hides all but RBD_SNAP_NAMESPACE_TYPE_USER snapshots, whereas here only RBD_SNAP_NAMESPACE_TYPE_TRASH snapshots are hidden.

But rbd trash only works for images, right?

Yes -- despite the fact that the term "trash" is used in both cases, rbd trash in the Windows trash bin sense (meaning that items can be moved to the trash and later restored or removed for good) works only for images. I don't see how snapshots of an image that hasn't been moved to the trash could be displayed in the Trash section as it exists today.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @idryomov! I tried implementing the listing of all snapshots, and .set_snap_by_id() worked ok, but it didn't work with the .diff_iterate() method. I'll leave it this way, in order to speed up this fix.

@idryomov
Copy link
Contributor

idryomov commented Apr 30, 2024

@idryomov I remember you said that, besides setting ceph osd set-require-min-compat-client mimic --yes-i-really-mean-it, there was another way to trigger this behaviour.

The other way to do it globally is to set rbd_default_clone_format config option to 2.

There is also a way to do it on a per-clone basis, but it's currently not exposed in our Python bindings: https://tracker.ceph.com/issues/65624. I'll get that fixed ASAP.

Fixes: https://tracker.ceph.com/issues/65698
Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
@nizamial09 nizamial09 merged commit 79967fb into ceph:main May 2, 2024
12 of 13 checks passed
@nizamial09 nizamial09 deleted the fix-65698-main branch May 2, 2024 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
3 participants