fix(ceph): skip Rook roles without Ceph storage (#4398)
Signed-off-by: Yaguang Tang <yaguang.tang@vexxhost.com>
This commit is contained in:
1 parent
e465056274
commit
622acbc136
5 files changed
+77
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fixes:
|
||||
- |
|
||||
Non-Ceph storage configurations now skip the Rook Ceph roles.
|
||||
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user