From 622acbc136f6907f89b16f5cc6b572f81951eaac Mon Sep 17 00:00:00 2001 From: Yaguang Tang Date: Tue, 27 Oct 2026 02:54:24 +0800 Subject: [PATCH] fix(ceph): skip Rook roles without Ceph storage (#4398) Signed-off-by: Yaguang Tang --- doc/source/deploy/storage.rst | 4 ++ playbooks/openstack.yml | 3 ++ plugins/filter/storage.py | 26 ++++++++++++ ...without-ceph-storage-bb05bb2300365030.yaml | 3 ++ tests/unit/plugins/filter/test_storage.py | 41 +++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 releasenotes/notes/skip-rook-ceph-without-ceph-storage-bb05bb2300365030.yaml diff --git a/doc/source/deploy/storage.rst b/doc/source/deploy/storage.rst index 862767f0..df84c305 100644 --- a/doc/source/deploy/storage.rst +++ b/doc/source/deploy/storage.rst @@ -42,6 +42,10 @@ You can override any part of the configuration by setting the built-in defaults using a recursive merge, so you only need to specify the parts you want to change. +Atmosphere deploys the Rook Ceph roles only when the resolved storage +configuration contains an RBD-backed Ceph entry. Configurations with no +Ceph storage skip those roles. + The built-in defaults are equivalent to: .. code-block:: yaml diff --git a/playbooks/openstack.yml b/playbooks/openstack.yml index 871875e3..717fd07b 100644 --- a/playbooks/openstack.yml +++ b/playbooks/openstack.yml @@ -38,14 +38,17 @@ - barbican - role: rook_ceph + when: _atmosphere_storage_config | vexxhost.atmosphere.storage_uses_ceph tags: - rook-ceph - role: rook_ceph_cluster + when: _atmosphere_storage_config | vexxhost.atmosphere.storage_uses_ceph tags: - rook-ceph-cluster - role: ceph_provisioners + when: _atmosphere_storage_config | vexxhost.atmosphere.storage_uses_ceph tags: - ceph-provisioners diff --git a/plugins/filter/storage.py b/plugins/filter/storage.py index 1dc99648..24027111 100644 --- a/plugins/filter/storage.py +++ b/plugins/filter/storage.py @@ -702,6 +702,31 @@ def _parse(raw: Any) -> StorageConfig: return StorageConfig.model_validate(raw) +def storage_uses_ceph(raw: Any) -> bool: + """Return whether a storage configuration requires Ceph.""" + + storage = _parse(raw) + images = storage.images + volumes = storage.volumes + + return any( + ( + images is not None + and any( + isinstance(backend, ImageBackendRbd) + for backend in images.backends.values() + ), + volumes is not None + and any( + isinstance(backend, (VolumeBackendRbd, VolumeBackendRbdEc)) + for backend in volumes.backends.values() + ), + isinstance(storage.backup, BackupBackendRbd), + isinstance(storage.ephemeral, EphemeralBackendRbd), + ) + ) + + def storage_to_cinder_helm_values(raw: Any) -> HelmValues: """Derive Cinder Helm values from atmosphere_storage.""" @@ -897,6 +922,7 @@ def storage_to_ceph_provisioners_helm_values(raw: Any) -> HelmValues: class FilterModule(object): def filters(self) -> dict[str, Any]: return { + "storage_uses_ceph": storage_uses_ceph, "storage_to_cinder_helm_values": storage_to_cinder_helm_values, "storage_to_glance_helm_values": storage_to_glance_helm_values, "storage_to_nova_helm_values": storage_to_nova_helm_values, diff --git a/releasenotes/notes/skip-rook-ceph-without-ceph-storage-bb05bb2300365030.yaml b/releasenotes/notes/skip-rook-ceph-without-ceph-storage-bb05bb2300365030.yaml new file mode 100644 index 00000000..418d098b --- /dev/null +++ b/releasenotes/notes/skip-rook-ceph-without-ceph-storage-bb05bb2300365030.yaml @@ -0,0 +1,3 @@ +fixes: + - | + Non-Ceph storage configurations now skip the Rook Ceph roles. diff --git a/tests/unit/plugins/filter/test_storage.py b/tests/unit/plugins/filter/test_storage.py index 5008dd34..79807098 100644 --- a/tests/unit/plugins/filter/test_storage.py +++ b/tests/unit/plugins/filter/test_storage.py @@ -10,6 +10,7 @@ from ansible_collections.vexxhost.atmosphere.plugins.filter.storage import ( storage_to_glance_helm_values, storage_to_libvirt_helm_values, storage_to_nova_helm_values, + storage_uses_ceph, ) from pydantic import ValidationError @@ -1393,11 +1394,51 @@ class TestStorageToCephProvisionersHelmValues: ) +class TestStorageUsesCeph: + @pytest.mark.parametrize( + "storage, expected", + [ + ({}, False), + (DEFAULT_STORAGE, True), + ({"images": DEFAULT_STORAGE["images"]}, True), + ( + { + "volumes": { + "default": "rbd-ec", + "backends": {"rbd-ec": _EC_BACKEND}, + } + }, + True, + ), + ({"backup": DEFAULT_STORAGE["backup"]}, True), + ({"ephemeral": DEFAULT_STORAGE["ephemeral"]}, True), + ( + { + "images": { + "default": "cinder", + "backends": {"cinder": {"type": "cinder"}}, + }, + "volumes": { + "default": "powerstore", + "backends": {"powerstore": _POWERSTORE_BACKEND}, + }, + "backup": {"type": "none"}, + "ephemeral": {"type": "local"}, + }, + False, + ), + ], + ) + def test_detects_rbd_storage(self, storage, expected): + assert storage_uses_ceph(storage) is expected + + class TestFilterModule: def test_returns_all_filters(self): fm = FilterModule() filters = fm.filters() assert set(filters.keys()) == { + "storage_uses_ceph", "storage_to_cinder_helm_values", "storage_to_glance_helm_values", "storage_to_nova_helm_values",