Skip to content

Commit 3e117e5

Browse files
fix terminate for REST
REST's terminate did not pass the floating ip list. Now it is passed as well. #709
1 parent 26ca73b commit 3e117e5

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

bibigrid/core/actions/terminate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def write_cluster_state(state):
2929
yaml.safe_dump(data=state, stream=cluster_info_file)
3030

3131

32-
def terminate(cluster_id, providers, log, floating_ip_ids, debug=False, assume_yes=False):
32+
def terminate(cluster_id, providers, floating_ip_ids, log, debug=False, assume_yes=False):
3333
"""
3434
Goes through all providers and gets info of all servers which name contains cluster ID.
3535
It then checks if any resources are reserved, but not used and frees them that were hold by the cluster.

bibigrid/core/startup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,8 @@ def run_action(action, configurations, config_input, cluster_id, debug):
144144
LOG.info("Action terminate selected")
145145
exit_state = terminate.terminate(cluster_id=cluster_id, providers=providers,
146146
floating_ip_ids=configuration_handler.get_list_by_key(
147-
configurations=configurations,key="floatingIpId"),
148-
log=LOG,
149-
debug=debug)
147+
configurations=configurations, key="floatingIpId"),
148+
log=LOG, debug=debug)
150149
case 'ide':
151150
LOG.info("Action ide selected")
152151
exit_state = ide.ide(cluster_id, providers[0], configurations[0], LOG)

bibigrid/core/startup_rest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ async def terminate_cluster(cluster_id: str,
193193

194194
try:
195195
providers = provider_handler.get_providers(configurations, log)
196-
thread = threading.Thread(target=terminate.terminate, args=(cluster_id, providers, log))
196+
thread = threading.Thread(target=terminate.terminate,
197+
args=(cluster_id, providers, configuration_handler.get_list_by_key(
198+
configurations=configurations, key="floatingIpId"), log))
197199
thread.start()
198200
return JSONResponse(content={"message": "Termination successfully requested."}, status_code=202)
199201
except Exception as exc: # pylint: disable=broad-except

tests/unit_tests/test_terminate_cluster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_terminate(self, mock_output, mock_local):
3030
provider.list_volumes([{"name": "bibigrid-master-i950vaoqzfbwpnq-tmp-0"}])
3131
provider.delete_security_group.return_value = True
3232
provider.delete_application_credentials.return_value = True
33-
terminate.terminate(str(cluster_id), [provider], startup.LOG, [None], False, True)
33+
terminate.terminate(str(cluster_id), [provider], [None], startup.LOG, False, True)
3434
provider.delete_server.assert_called_with(21, delete_ips=True)
3535
provider.delete_keypair.assert_called_with(KEY_NAME.format(cluster_id=cluster_id))
3636
mock_output.assert_called_with(cluster_server_state=[provider.delete_server.return_value],
@@ -57,7 +57,7 @@ def test_terminate_delete_ip_false(self, mock_output, mock_local):
5757
provider.list_volumes([{"name": "bibigrid-master-i950vaoqzfbwpnq-tmp-0"}])
5858
provider.delete_security_group.return_value = True
5959
provider.delete_application_credentials.return_value = True
60-
terminate.terminate(str(cluster_id), [provider], startup.LOG, ["123"], False, True)
60+
terminate.terminate(str(cluster_id), [provider], ["123"], startup.LOG, False, True)
6161
provider.delete_server.assert_called_with(21, delete_ips=False)
6262

6363
@patch("bibigrid.core.actions.terminate.delete_local_keypairs")
@@ -70,7 +70,7 @@ def test_terminate_none(self, _, mock_local):
7070
provider.list_servers.return_value = [
7171
{"name": master_identifier(cluster_id=str(cluster_id + 1)), "id": 21}]
7272
provider.delete_keypair.return_value = False
73-
terminate.terminate(str(cluster_id), [provider], startup.LOG, [None], False, True)
73+
terminate.terminate(str(cluster_id), [provider], [None], startup.LOG, False, True)
7474
provider.delete_server.assert_not_called()
7575
provider.delete_keypair.assert_called_with(
7676
KEY_NAME.format(cluster_id=str(cluster_id))) # since keypair is not called

0 commit comments

Comments
 (0)