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

Some minor cleanup to 'guess_worker_impl' #598

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
26 changes: 12 additions & 14 deletions src/scriptworker/cot/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,36 +347,34 @@ def guess_worker_impl(link):
CoTError: on inability to determine the worker implementation

"""
worker_impls = []
worker_impls = set()
task = link.task
name = link.name
errors = []

if task["payload"].get("image"):
worker_impls.append("docker-worker")
if task["provisionerId"] in link.context.config["scriptworker_provisioners"]:
worker_impls.append("scriptworker")
# XXX while deprecated, "scriptworker-prov-v1" is still around for mac signing
if get_provisioner_id(task) == "scriptworker-prov-v1":
worker_impls.append("scriptworker")
worker_impls.add("docker-worker")
if get_provisioner_id(task) in link.context.config["scriptworker_provisioners"]:
worker_impls.add("scriptworker")
if task["payload"].get("mounts") is not None:
worker_impls.append("generic-worker")
worker_impls.add("generic-worker")
if task["payload"].get("osGroups") is not None:
worker_impls.append("generic-worker")
worker_impls.add("generic-worker")
if task.get("tags", {}).get("worker-implementation", {}):
worker_impls.append(task["tags"]["worker-implementation"])
worker_impls.add(task["tags"]["worker-implementation"])

for scope in task["scopes"]:
if scope.startswith("docker-worker:"):
worker_impls.append("docker-worker")
worker_impls.add("docker-worker")

if not worker_impls:
errors.append("guess_worker_impl: can't find a worker_impl for {}!\n{}".format(name, task))
if len(set(worker_impls)) > 1:
if len(worker_impls) > 1:
errors.append("guess_worker_impl: too many matches for {}: {}!\n{}".format(name, set(worker_impls), task))
raise_on_errors(errors)
log.debug("{} {} is {}".format(name, link.task_id, worker_impls[0]))
return worker_impls[0]
impl = worker_impls.pop()
log.debug("{} {} is {}".format(name, link.task_id, impl))
return impl


# get_valid_worker_impls {{{1
Expand Down