Skip to content

librbd: allow cloning from non-user snapshots - #57954

Merged
idryomov merged 10 commits into
ceph:mainfrom
idryomov:wip-64662
Jun 13, 2024
Merged

idryomov merged 10 commits into
ceph:mainfrom
idryomov:wip-64662

Conversation

@idryomov

Copy link
Copy Markdown
Contributor

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

@ajarr ajarr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR looks good.

Why was snap ID chosen over snap name to specify the non-user snapshot to clone from?

@idryomov

Copy link
Copy Markdown
Contributor Author

Pushing a fixup for ceph api:

FAIL: test_clone (tasks.mgr.dashboard.test_rbd.RbdTest)
...
2024-06-11 09:08:40,762.762 INFO:__main__:Traceback (most recent call last):
2024-06-11 09:08:40,762.762 INFO:__main__:  File "/home/jenkins-build/build/workspace/ceph-api/qa/tasks/mgr/dashboard/helper.py", line 483, in assertSchema
2024-06-11 09:08:40,763.763 INFO:__main__:    return _validate_json(data, schema)
2024-06-11 09:08:40,763.763 INFO:__main__:  File "/home/jenkins-build/build/workspace/ceph-api/qa/tasks/mgr/dashboard/helper.py", line 711, in _validate_json
2024-06-11 09:08:40,763.763 INFO:__main__:    result = all(
2024-06-11 09:08:40,763.763 INFO:__main__:  File "/home/jenkins-build/build/workspace/ceph-api/qa/tasks/mgr/dashboard/helper.py", line 712, in 
2024-06-11 09:08:40,763.763 INFO:__main__:    _validate_json(val[key], sub_schema, path + [key])
2024-06-11 09:08:40,763.763 INFO:__main__:  File "/home/jenkins-build/build/workspace/ceph-api/qa/tasks/mgr/dashboard/helper.py", line 710, in _validate_json
2024-06-11 09:08:40,763.763 INFO:__main__:    raise _ValError('unknown keys: {}'.format(unknown_keys), path)
2024-06-11 09:08:40,763.763 INFO:__main__:tasks.mgr.dashboard.helper._ValError: In `input['parent']`: unknown keys: {'image_id', 'trash', 'pool_id', 'snap_id', 'snap_namespace_type'}

@idryomov
idryomov requested a review from a team as a code owner June 11, 2024 21:23
@idryomov
idryomov requested review from aaSharma14 and afreen23 and removed request for a team June 11, 2024 21:23
@idryomov

idryomov commented Jun 11, 2024 •

Copy link
Copy Markdown
Contributor Author

Why was snap ID chosen over snap name to specify the non-user snapshot to clone from?

The snap name by itself can be ambiguous. Each non-user snapshot type forms its own namespace -- see rbd snap ls --all output in the commit message of the last commit for an example.

The alternative to taking a snap ID would be to take an additional snap_namespace argument, but there is no precedent for that in the public API.

@idryomov
idryomov force-pushed the wip-64662 branch 2 times, most recently from 420070c to d9d4371 Compare June 12, 2024 10:10
@idryomov

Copy link
Copy Markdown
Contributor Author

jenkins test api

@idryomov

Copy link
Copy Markdown
Contributor Author

jenkins test dashboard

@idryomov

Copy link
Copy Markdown
Contributor Author

jenkins test dashboard

@idryomov

Copy link
Copy Markdown
Contributor Author

jenkins test make check

idryomov added 6 commits June 13, 2024 14:08
With an error check for p_snap_name, it doesn't make much sense to
crash if "either p_id or p_name" contract is violated.  Replace the
assert with a similar error check.

Signed-off-by: Ilya Dryomov <[email protected]>
Propagate everything there is in rbd_linked_image_spec_t and
rbd_snap_spec_t structures returned by the C API.

Signed-off-by: Ilya Dryomov <[email protected]>
Allow cloning from non-user snapshots -- namely snapshots in group
and mirror namespaces.  The motivation is to provide a building block
for cloning new groups from group snapshots ("rbd group snap create").
Otherwise, group snapshots as they are today can be used only for
rolling back the group as a whole, which is very limiting.

While at it, there doesn't seem to be anything wrong with making it
possible to clone from mirror snapshots as well.

Snapshots in a trash namespace can't be cloned from since they are
considered to be deleted.

Cloning from non-user snapshots is limited to clone v2 just because
protecting/unprotecting is limited to snapshots in a user namespace.
This happens to simplify some invariants.

Fixes: https://tracker.ceph.com/issues/64662
Signed-off-by: Ilya Dryomov <[email protected]>
Make it clear that these are pool IDs, referring to the same pool(s) as
parent/child_pool_name fields.

Signed-off-by: Ilya Dryomov <[email protected]>
Make ARGUMENT_MODIFIER_DEST synonymous to ARGUMENT_MODIFIER_NONE as
there is no use case for a destination snap ID for now.

Signed-off-by: Ilya Dryomov <[email protected]>
idryomov added 4 commits June 13, 2024 14:08
Enable cloning from non-user snapshots via the CLI.

Signed-off-by: Ilya Dryomov <[email protected]>
The intent of "rbd ls | grep -v clone" was probably to check that an
image with the name "clone" shows up in rbd2 pool and not in rbd pool.
However, it's very far from that -- "grep -v clone" would succeed
regardless because of an image with the name "test1" in rbd pool.

Signed-off-by: Ilya Dryomov <[email protected]>
The existing rbd_snap_get_trash_namespace() API returns only the
original name of the deleted snapshot, omitting its namespace type.
While non-user snapshots have distinctive names, there is nothing
preventing the user from creating user snapshots with identical names
(i.e. starting with ".group" or ".mirror" prefix).  After cloning from
non-user snapshots is allowed, it's possible for such user snapshots to
get mixed up with non-user snapshots in the trash, so let's provide
means for disambiguation.

Signed-off-by: Ilya Dryomov <[email protected]>
Before (snap 22 comes from "rbd group snap create", snap 23 created
manually with "rbd snap create"):

SNAPID  NAME                                  SIZE   PROTECTED  TIMESTAMP                 NAMESPACE
    21  f7cfdcfe-5f71-40e4-be82-3fb0e7caf2aa  1 GiB             Mon Jun 10 09:23:40 2024  trash (mysnap)
    22  bd67397f-32cb-48fe-b1ac-ef6f02319239  1 GiB             Mon Jun 10 09:26:06 2024  trash (.group.2_1491b049b556_1497bf66f586)
    23  27a5f053-8431-428e-ab33-be9d8b6cf51e  1 GiB             Mon Jun 10 09:28:30 2024  trash (.group.2_1491b049b556_1497bf66f586)

After:

SNAPID  NAME                                  SIZE   PROTECTED  TIMESTAMP                 NAMESPACE
    21  f7cfdcfe-5f71-40e4-be82-3fb0e7caf2aa  1 GiB             Mon Jun 10 09:23:40 2024  trash (user mysnap)
    22  bd67397f-32cb-48fe-b1ac-ef6f02319239  1 GiB             Mon Jun 10 09:26:06 2024  trash (group .group.2_1491b049b556_1497bf66f586)
    23  27a5f053-8431-428e-ab33-be9d8b6cf51e  1 GiB             Mon Jun 10 09:28:30 2024  trash (user .group.2_1491b049b556_1497bf66f586)

Signed-off-by: Ilya Dryomov <[email protected]>
@idryomov

Copy link
Copy Markdown
Contributor Author

Added release notes (had to rebase to resolve a conflict in PendingReleaseNotes).

@idryomov

Copy link
Copy Markdown
Contributor Author

@afreen23 or @aaSharma14 I'd appreciate your ack for changes to qa/tasks/mgr/dashboard/test_rbd.py here.

@idryomov
idryomov merged commit 2b6ed5b into ceph:main Jun 13, 2024
@idryomov
idryomov deleted the wip-64662 branch June 13, 2024 17:11
@agarwal-mudit

Copy link
Copy Markdown

cc @nixpanic @Madhu-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants