diff --git a/kubemarine/core/cluster.py b/kubemarine/core/cluster.py index 9d76f63a6..633361872 100755 --- a/kubemarine/core/cluster.py +++ b/kubemarine/core/cluster.py @@ -563,7 +563,7 @@ def check_nodes_accessibility(self, skip_check_iaas: bool = True) -> None: return if procedure == 'remove_node': - group = self.make_group_from_roles(['control-plane', 'balancer']) + group = self.get_unchanged_nodes().having_roles(['control-plane', 'balancer']) else: group = self.make_group_from_roles(['control-plane', 'balancer']).include_group(self.get_new_nodes_or_self()) diff --git a/test/unit/core/test_flow.py b/test/unit/core/test_flow.py index 6d6bead6f..f9da9de55 100755 --- a/test/unit/core/test_flow.py +++ b/test/unit/core/test_flow.py @@ -414,6 +414,24 @@ def test_any_removed_node_can_be_offline(self): # no exception should occur flow.run_tasks(res, tasks) + def test_remove_control_plane_if_offline(self): + inventory = demo.generate_inventory(**demo.FULLHA_KEEPALIVED) + online_hosts = [node["address"] for node in inventory["nodes"]] + control_planes = [i for i, node in enumerate(inventory["nodes"]) if 'control-plane' in node['roles']] + + i = control_planes[0] + online_hosts.remove(inventory["nodes"][i]["address"]) + procedure_inventory = demo.generate_procedure_inventory('remove_node') + procedure_inventory["nodes"] = [{"name": inventory["nodes"][i]["name"]}] + + self._stub_detect_nodes_context(inventory, online_hosts, []) + context = demo.create_silent_context(['fake_path.yaml'], procedure='remove_node') + res = demo.FakeResources(context, inventory, procedure_inventory=procedure_inventory, + fake_shell=self.light_fake_shell) + + # no exception should occur — offline control-plane being removed must not block the procedure + flow.run_tasks(res, tasks) + def test_remove_node_if_worker_offline(self): inventory = demo.generate_inventory(**demo.FULLHA_KEEPALIVED) online_hosts = [node["address"] for node in inventory["nodes"]]