From 4bacfc1cf4d8586ec7d6f0f9fc47da7a25423f17 Mon Sep 17 00:00:00 2001 From: Guillaume Boutry Date: Thu, 15 Feb 2024 01:23:32 +0100 Subject: [PATCH] Always use 3 replicas for ceph pools Always use 3 replicas for ceph pools. this will create waste when number of OSDs < 3 but there's no satisfactory solution at the moment to ensure ceph pool creation. --- sunbeam-python/sunbeam/commands/openstack.py | 19 ++----------------- .../unit/sunbeam/commands/test_openstack.py | 14 -------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/sunbeam-python/sunbeam/commands/openstack.py b/sunbeam-python/sunbeam/commands/openstack.py index c1e97650..b0e46b43 100644 --- a/sunbeam-python/sunbeam/commands/openstack.py +++ b/sunbeam-python/sunbeam/commands/openstack.py @@ -117,17 +117,6 @@ def compute_ingress_scale(topology: str, control_nodes: int) -> int: return control_nodes -def compute_ceph_replica_scale(osds: int) -> int: - return min(osds, 3) - - -async def _get_number_of_osds(jhelper: JujuHelper) -> int: - """Fetch the number of osds from the microceph application""" - leader = await jhelper.get_leader_unit(microceph.APPLICATION, microceph.MODEL) - osds, _ = await microceph.list_disks(jhelper, microceph.MODEL, leader) - return len(osds) - - class DeployControlPlaneStep(BaseStep, JujuStepHelper): """Deploy OpenStack using Terraform cloud""" @@ -159,9 +148,7 @@ def get_storage_tfvars(self) -> dict: tfvars = {} storage_nodes = self.client.cluster.list_nodes_by_role("storage") if storage_nodes: - tfvars["ceph-osd-replication-count"] = compute_ceph_replica_scale( - run_sync(_get_number_of_osds(self.jhelper)) - ) + tfvars["ceph-osd-replication-count"] = 3 tfvars["enable-ceph"] = True tfvars["ceph-offer-url"] = f"{CONTROLLER_MODEL}.{microceph.APPLICATION}" else: @@ -335,9 +322,7 @@ def run(self, status: Optional[Status] = None) -> Result: "ingress-scale": compute_ingress_scale(topology, len(control_nodes)), "enable-ceph": len(storage_nodes) > 0, "ceph-offer-url": f"{CONTROLLER_MODEL}.{microceph.APPLICATION}", - "ceph-osd-replication-count": compute_ceph_replica_scale( - run_sync(_get_number_of_osds(self.jhelper)) - ), + "ceph-osd-replication-count": 3, } self.update_status(status, "scaling services") diff --git a/sunbeam-python/tests/unit/sunbeam/commands/test_openstack.py b/sunbeam-python/tests/unit/sunbeam/commands/test_openstack.py index 7a904f4d..d005226b 100644 --- a/sunbeam-python/tests/unit/sunbeam/commands/test_openstack.py +++ b/sunbeam-python/tests/unit/sunbeam/commands/test_openstack.py @@ -25,7 +25,6 @@ PatchLoadBalancerServicesStep, ReapplyOpenStackTerraformPlanStep, ResizeControlPlaneStep, - compute_ceph_replica_scale, compute_ha_scale, compute_ingress_scale, compute_os_api_scale, @@ -413,19 +412,6 @@ def test_compute_ingress_scale(topology, control_nodes, scale): assert compute_ingress_scale(topology, control_nodes) == scale -@pytest.mark.parametrize( - "osds,scale", - [ - (1, 1), - (1, 1), - (9, 3), - (2, 2), - ], -) -def test_compute_ceph_replica_scale(osds, scale): - assert compute_ceph_replica_scale(osds) == scale - - class TestReapplyOpenStackTerraformPlanStep(unittest.TestCase): def __init__(self, methodName: str = "runTest") -> None: super().__init__(methodName)