Skip to content

Commit

Permalink
fix(plugins/sct): Support SCT runner for resources table
Browse files Browse the repository at this point in the history
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
  • Loading branch information
k0machi committed Dec 16, 2024
1 parent 420b826 commit c403acd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion argus/backend/plugins/sct/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 9 additions & 3 deletions argus/backend/plugins/sct/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion argus/client/sct/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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)
Expand Down

0 comments on commit c403acd

Please sign in to comment.