mgr/dashboard: add RBD image diff (changed-blocks) API endpoint - #71388
Open
dicode-nl wants to merge 3 commits into
Open
mgr/dashboard: add RBD image diff (changed-blocks) API endpoint#71388dicode-nl wants to merge 3 commits into
dicode-nl wants to merge 3 commits into
Conversation
Add GET /api/block/image/{image_spec}/diff, exposing librbd's
diff_iterate2 through the dashboard REST API. Given an optional
from_snapshot and a target snapshot_name (or the live image), it
returns the changed extents ({offset, length, exists}) of an RBD
image -- the primitive that backup tools need for changed-block
tracking (CBT).
The parameters mirror `rbd diff`: from_snapshot, snapshot_name,
offset, length and whole_object (object-map/fast-diff based; coarser,
but avoids scanning object data). The endpoint opens the image
read-only and never mutates cluster state.
Signed-off-by: dicode <info@dicode.nl>
|
Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Ceph Dashboard REST API endpoint to expose RBD changed-block (diff) information needed for changed-block tracking (CBT) workflows, backed by librbd diff iteration and returned as {offset, length, exists} extents.
Changes:
- Add
RbdService.image_diff()to compute changed extents for an image region between an optional source snapshot and a target snapshot/live image. - Add
GET /api/block/image/{image_spec}/diffcontroller endpoint withEndpointDocmetadata and permission gating. - Regenerate
openapi.yamland add unit tests covering basic diff output plus length clamping.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/pybind/mgr/dashboard/controllers/rbd.py | Adds the new diff() REST endpoint and response schema for RBD image diffs. |
| src/pybind/mgr/dashboard/services/rbd.py | Implements RbdService.image_diff() wrapping RBD diff iteration and clamping logic. |
| src/pybind/mgr/dashboard/tests/test_rbd_service.py | Adds unit tests for image_diff() behavior and length clamping. |
| src/pybind/mgr/dashboard/openapi.yaml | Documents the new API path, parameters, and response schema; includes regenerated anchor renumbering. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: dicode <info@dicode.nl>
The RBD image diff endpoint cast its query parameters with int()/ str_to_bool() directly, so empty (allowEmptyValue) or non-integer input raised a ValueError that surfaced as an unhandled HTTP 500. Normalize empty strings to None and translate parse failures into a DashboardException (HTTP 400) with a clear error code and message. Signed-off-by: dicode <info@dicode.nl>
dicode-nl
force-pushed
the
wip-rbd-dashboard-image-diff
branch
from
August 28, 2026 07:11
dd271f8 to
af02f17
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
GET /api/block/image/{image_spec}/diff, exposinglibrbd'sdiff_iterate2through the dashboard REST API. Given an optionalfrom_snapshotand a targetsnapshot_name(or the live image), itreturns the changed extents (
{offset, length, exists}) of an RBD image.This is the changed-block primitive that backup/DR tooling needs for
changed-block tracking (CBT). Today it is only reachable through the
rbdCLI /librbd; there is no way to obtain a diff over the REST API.The parameters mirror
rbd diff:from_snapshot,snapshot_name,offset,lengthandwhole_object(object-map/fast-diff based;coarser, but avoids scanning object data). The endpoint opens the image
read-only and never mutates cluster state.
openapi.yamlwas regenerated withtox -e openapi-fix; the large diffis the usual PyYAML
&idNNNanchor renumbering caused by inserting a newpath earlier in the document — no other endpoints changed.
Tests: added
RbdServiceTest.test_image_diffandtest_image_diff_length_is_clamped_to_image_size.Documentation: endpoint self-documented via
EndpointDoc+openapi.yaml.Checklist