From c403acdcb18e045de346ae79e60f21fe43440298 Mon Sep 17 00:00:00 2001 From: Alexey Kartashov Date: Mon, 16 Dec 2024 14:28:12 +0100 Subject: [PATCH] fix(plugins/sct): Support SCT runner for resources table This commit adds logic to add SCT runner to the resource table and also adds client support for its name. Additionally, it adds a workaround for older client versions, where SCT runner will be submitted without a name. Fixes scylladb/scylla-cluster-tests#9543 --- argus/backend/plugins/sct/controller.py | 3 ++- argus/backend/plugins/sct/service.py | 12 +++++++++--- argus/client/sct/client.py | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/argus/backend/plugins/sct/controller.py b/argus/backend/plugins/sct/controller.py index f0ee3e70..b5581ce9 100644 --- a/argus/backend/plugins/sct/controller.py +++ b/argus/backend/plugins/sct/controller.py @@ -40,7 +40,8 @@ def sct_set_runner(run_id: str): public_ip=payload["public_ip"], private_ip=payload["private_ip"], region=payload["region"], - backend=payload["backend"] + backend=payload["backend"], + name=payload.get("name") ) return { "status": "ok", diff --git a/argus/backend/plugins/sct/service.py b/argus/backend/plugins/sct/service.py index e38ac6f9..c1aaf6f0 100644 --- a/argus/backend/plugins/sct/service.py +++ b/argus/backend/plugins/sct/service.py @@ -74,15 +74,18 @@ def submit_packages(run_id: str, packages: list[dict]) -> str: @staticmethod - def set_sct_runner(run_id: str, public_ip: str, private_ip: str, region: str, backend: str): + def set_sct_runner(run_id: str, public_ip: str, private_ip: str, region: str, backend: str, name: str = None): try: run: SCTTestRun = SCTTestRun.get(id=run_id) - run.sct_runner_host = CloudInstanceDetails( + details = CloudInstanceDetails( public_ip=public_ip, private_ip=private_ip, provider=backend, region=region, ) + run.sct_runner_host = details + resource = CloudResource(name=name or "sct-runner", resource_type="sct-runner", instance_info=details) + run.allocated_resources.append(resource) run.save() except SCTTestRun.DoesNotExist as exception: LOGGER.error("Run %s not found for SCTTestRun", run_id) @@ -312,7 +315,10 @@ def update_resource(run_id: str, resource_name: str, update_data: ResourceUpdate def terminate_resource(run_id: str, resource_name: str, reason: str) -> str: try: run: SCTTestRun = SCTTestRun.get(id=run_id) - resource = next(res for res in run.get_resources() if res.name == resource_name) + if "sct-runner" in resource_name: # FIXME: Temp solution until sct-runner name is propagated on submit + resource = next(res for res in run.get_resources() if "sct-runner" in res.name) + else: + resource = next(res for res in run.get_resources() if res.name == resource_name) resource.get_instance_info().termination_reason = reason resource.get_instance_info().termination_time = int(time()) resource.state = ResourceState.TERMINATED.value diff --git a/argus/client/sct/client.py b/argus/client/sct/client.py index c1f2f557..803c13bf 100644 --- a/argus/client/sct/client.py +++ b/argus/client/sct/client.py @@ -56,7 +56,7 @@ def set_sct_run_status(self, new_status: TestStatus) -> None: response = super().set_status(run_type=self.test_type, run_id=self.run_id, new_status=new_status) self.check_response(response) - def set_sct_runner(self, public_ip: str, private_ip: str, region: str, backend: str) -> None: + def set_sct_runner(self, public_ip: str, private_ip: str, region: str, backend: str, name: str = None) -> None: """ Sets runner information for an SCT run. """ @@ -69,6 +69,7 @@ def set_sct_runner(self, public_ip: str, private_ip: str, region: str, backend: "private_ip": private_ip, "region": region, "backend": backend, + "name": name, } ) self.check_response(response)