Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins/sct): Support SCT runner for resources table #540

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe here name=payload.get("name") or 'sct-runner'?

)
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
Loading