Skip to content

Commit

Permalink
api: check version for start_rq
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Sep 3, 2021
1 parent 78367cc commit bd717f6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mpcontribs-api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ def start(program):
prefix = "com.amazonaws.ecs"
cluster = labels[f"{prefix}.cluster"].split("/", 1)[1]
family = labels[f"{prefix}.task-definition-family"]
version = labels[f"{prefix}.task-definition-version"]
tasks = client.list_tasks(cluster=cluster, family=family).get("taskArns", [])
print("TASKS", tasks)
# TODO check version of each task
start_rq = len(tasks) == 1 # this task included in metadata response
version = int(labels[f"{prefix}.task-definition-version"])
task_arns = client.list_tasks(cluster=cluster, family=family).get("taskArns", [])
tasks = client.describe_tasks(cluster=cluster, tasks=task_arns).get("tasks", [])
ntasks = 0

for task in tasks:
v = int(task["taskDefinitionArn"].rsplit(":", 1)[1])
ntasks += int(v == version)

start_rq = ntasks == 1 # this task included in metadata response
print(f"TASKS {ntasks}/{len(tasks)} -> START RQ {start_rq}")

if start_rq:
for program in ["worker", "scheduler"]:
Expand Down

0 comments on commit bd717f6

Please sign in to comment.