Skip to content

mgr/dashboard: add RBD image diff (changed-blocks) API endpoint - #71388

Open
dicode-nl wants to merge 3 commits into
ceph:mainfrom
dicode-nl:wip-rbd-dashboard-image-diff
Open

mgr/dashboard: add RBD image diff (changed-blocks) API endpoint#71388
dicode-nl wants to merge 3 commits into
ceph:mainfrom
dicode-nl:wip-rbd-dashboard-image-diff

Conversation

@dicode-nl

@dicode-nl dicode-nl commented Aug 27, 2026

Copy link
Copy Markdown

Description

Adds 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.

This is the changed-block primitive that backup/DR tooling needs for
changed-block tracking (CBT). Today it is only reachable through the
rbd CLI / librbd; there is no way to obtain a diff over the REST API.

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.

openapi.yaml was regenerated with tox -e openapi-fix; the large diff
is the usual PyYAML &idNNN anchor renumbering caused by inserting a new
path earlier in the document — no other endpoints changed.

Tests: added RbdServiceTest.test_image_diff and
test_image_diff_length_is_clamped_to_image_size.
Documentation: endpoint self-documented via EndpointDoc + openapi.yaml.

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)

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>
@github-actions

Copy link
Copy Markdown

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 ci-approved to allow Jenkins CI jobs to run.

Copilot AI 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.

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}/diff controller endpoint with EndpointDoc metadata and permission gating.
  • Regenerate openapi.yaml and 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.

Comment thread src/pybind/mgr/dashboard/controllers/rbd.py Outdated
Comment thread src/pybind/mgr/dashboard/services/rbd.py Outdated
dicode-nl and others added 2 commits August 28, 2026 09:10
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
dicode-nl force-pushed the wip-rbd-dashboard-image-diff branch from dd271f8 to af02f17 Compare August 28, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

2 participants