Skip to content

Commit

Permalink
Merge pull request #56 from javacruft/bug/2043083
Browse files Browse the repository at this point in the history
resize: check whether storage node exist
  • Loading branch information
hemanthnakkina authored Nov 17, 2023
2 parents 6f34360 + 7b8c9d4 commit aaa548d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sunbeam-python/sunbeam/commands/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def determine_target_topology(client: Client) -> str:
return topology


def compute_ha_scale(topology: str) -> int:
if topology == "single":
def compute_ha_scale(topology: str, control_nodes: int) -> int:
if topology == "single" or control_nodes < 3:
return 1
return 3

Expand Down Expand Up @@ -324,16 +324,22 @@ def run(self, status: Optional[Status] = None) -> Result:
tf_vars = read_config(client, self._CONFIG)
control_nodes = client.cluster.list_nodes_by_role("control")
storage_nodes = client.cluster.list_nodes_by_role("storage")
# NOTE(jamespage)
# When dedicated control nodes are used, ceph is not enabled during
# bootstrap - however storage nodes may be added later so re-assess
tf_vars.update(
{
"ha-scale": compute_ha_scale(topology),
"ha-scale": compute_ha_scale(topology, len(control_nodes)),
"os-api-scale": compute_os_api_scale(topology, len(control_nodes)),
"ingress-scale": compute_ingress_scale(topology, len(control_nodes)),
"ceph-osd-replication-count": compute_ceph_replica_scale(
topology, len(storage_nodes)
),
"enable-ceph": len(storage_nodes) > 0,
"ceph-offer-url": f"{CONTROLLER_MODEL}.{MICROCEPH_APPLICATION}",
}
)

update_config(client, self._CONFIG, tf_vars)
self.update_status(status, "scaling services")
self.tfhelper.write_tfvars(tf_vars)
Expand Down
61 changes: 61 additions & 0 deletions sunbeam-python/tests/unit/sunbeam/commands/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
DeployControlPlaneStep,
PatchLoadBalancerServicesStep,
ResizeControlPlaneStep,
compute_ceph_replica_scale,
compute_ha_scale,
compute_ingress_scale,
compute_os_api_scale,
)
from sunbeam.commands.terraform import TerraformException
from sunbeam.jobs.common import ResultType
Expand Down Expand Up @@ -341,3 +345,60 @@ def test_run(self):
METALLB_ANNOTATION
]
assert annotation == "fake-ip"


@pytest.mark.parametrize(
"topology,control_nodes,scale",
[
("single", 1, 1),
("multi", 2, 1),
("multi", 3, 3),
("multi", 9, 3),
("large", 9, 3),
],
)
def test_compute_ha_scale(topology, control_nodes, scale):
assert compute_ha_scale(topology, control_nodes) == scale


@pytest.mark.parametrize(
"topology,control_nodes,scale",
[
("single", 1, 1),
("multi", 2, 2),
("multi", 3, 3),
("multi", 9, 3),
("large", 4, 6),
("large", 9, 7),
],
)
def test_compute_os_api_scale(topology, control_nodes, scale):
assert compute_os_api_scale(topology, control_nodes) == scale


@pytest.mark.parametrize(
"topology,control_nodes,scale",
[
("single", 1, 1),
("multi", 2, 2),
("multi", 3, 3),
("multi", 9, 9),
("large", 4, 4),
("large", 9, 9),
],
)
def test_compute_ingress_scale(topology, control_nodes, scale):
assert compute_ingress_scale(topology, control_nodes) == scale


@pytest.mark.parametrize(
"topology,storage_nodes,scale",
[
("single", 1, 1),
("multi", 1, 1),
("multi", 9, 3),
("multi", 2, 2),
],
)
def test_compute_ceph_replica_scale(topology, storage_nodes, scale):
assert compute_ceph_replica_scale(topology, storage_nodes) == scale

0 comments on commit aaa548d

Please sign in to comment.