Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .coveragerc

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
check-poetry:
Expand Down
Empty file added changelog.d/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions changelog.d/20250611_120003_jb_PL_133453_rbd_whole_object.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. A new scriv changelog fragment.

- Fix whole object detection (PL-133453)
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ version = "literal: pyproject.toml: tool.poetry.version"
entry_title_template = "{% if version %}{{ version }} {% endif %}({{ date.strftime('%Y-%m-%d') }})"
categories = ""


[tool.pytest.ini_options]
addopts = "--timeout=30 --tb=native --cov=src --cov-report=html --cov-config=pyproject.toml src -r w"
markers = "slow: This is a non-unit test and thus is not run by default. Use ``-m slow`` to run these, or ``-m 1`` to run all tests."
log_level = "NOTSET"
asyncio_mode = "auto"
filterwarnings = [ "ignore::DeprecationWarning:telnetlib3.*:" ]

[tool.coverage.run]
branch = true
omit = [ "*/tests/*" ]

[tool.poetry]
name = "backy"
version = "2.5.4.dev0"
Expand Down Expand Up @@ -59,7 +71,7 @@ pre-commit = "^3.3.3"
pytest = "^7.4.0"
pytest-asyncio = "^0.21.1"
pytest-cache = "^1.0"
pytest-cov = "^4.1.0"
pytest-cov = "^6.1.0"
pytest-flake8 = "^1.1.1"
pytest-timeout = "^2.1.0"
scriv = "^1.3.1"
Expand Down
9 changes: 0 additions & 9 deletions pytest.ini

This file was deleted.

15 changes: 1 addition & 14 deletions src/backy/sources/ceph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
from subprocess import PIPE, run


def detect_whole_object_support():
result = run(
["rbd", "help", "export-diff"], stdout=PIPE, stderr=PIPE, check=True
)
return "--whole-object" in result.stdout.decode("ascii")


try:
CEPH_RBD_SUPPORTS_WHOLE_OBJECT_DIFF = detect_whole_object_support()
except Exception:
CEPH_RBD_SUPPORTS_WHOLE_OBJECT_DIFF = False
# Make this a package.
9 changes: 6 additions & 3 deletions src/backy/sources/ceph/rbd.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import contextlib
import functools
import json
import subprocess
from typing import IO, Iterator, cast

from structlog.stdlib import BoundLogger

import backy.sources.ceph

from ...ext_deps import RBD
from ...utils import CHUNK_SIZE
from .diff import RBDDiffV1
Expand Down Expand Up @@ -66,6 +65,10 @@ def _rbd_stream(self, cmd: list[str]) -> Iterator[IO[bytes]]:
if rc:
raise subprocess.CalledProcessError(rc, proc.args)

@functools.cached_property
def _supports_whole_object(self):
return "--whole-object" in self._rbd(["help", "export-diff"])

def exists(self, snapspec):
try:
return self._rbd(["info", snapspec], format="json")
Expand Down Expand Up @@ -134,7 +137,7 @@ def snap_rm(self, image):

@contextlib.contextmanager
def export_diff(self, new: str, old: str) -> Iterator[RBDDiffV1]:
if backy.sources.ceph.CEPH_RBD_SUPPORTS_WHOLE_OBJECT_DIFF:
if self._supports_whole_object:
EXPORT_WHOLE_OBJECT = ["--whole-object"]
else:
EXPORT_WHOLE_OBJECT = []
Expand Down
6 changes: 1 addition & 5 deletions src/backy/sources/ceph/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import pytest

import backy.sources.ceph
from backy.sources.ceph.rbd import RBDClient


Expand Down Expand Up @@ -242,11 +241,8 @@ def unmap(self, device):

@pytest.fixture(params=[CephJewelCLI, CephLuminousCLI, CephNautilusCLI])
def rbdclient(request, tmpdir, monkeypatch, log):
monkeypatch.setattr(
backy.sources.ceph, "CEPH_RBD_SUPPORTS_WHOLE_OBJECT_DIFF", True
)

client = RBDClient(log)
client._supports_whole_object = True
client._ceph_cli = request.param(tmpdir)

return client
Loading