Closed Bug 1278999 Opened 8 years ago Closed 8 years ago

taskcluster/taskgraph/kind/legacy.py should not assume task.payload.artifacts is a dictionary

Categories

(Taskcluster :: Services, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: pmoore, Assigned: pmoore)

References

Details

Attachments

(1 file, 2 obsolete files)

In docker worker, task.payload.artifacts is a dictionary.

In generic worker, it is a list.

This needs to be cleaned up separately, but for now we should allow for both forms to exist, until generic worker aligns, or until tasks are migrated from generic worker -> taskcluster worker.
Attached patch bug1278999_gecko_v1.patch (obsolete) — Splinter Review
Hey Wander,

Could you take a look at this (simple) fix, as dustin is on PTO for the next days?

Thanks!
Pete
Assignee: nobody → pmoore
Status: NEW → ASSIGNED
Attachment #8761514 - Flags: review?(wcosta)
Comment on attachment 8761514 [details] [diff] [review]
bug1278999_gecko_v1.patch

Review of attachment 8761514 [details] [diff] [review]:
-----------------------------------------------------------------

::: taskcluster/taskgraph/kind/legacy.py
@@ +210,5 @@
> +    except:
> +        # generic worker
> +        values = artifacts
> +
> +    for artifact in values:

How about:

if hasattr(artifacts, "values"):
   artifacts = artifacts.values()
(In reply to Wander Lairson Costa [:wcosta] from comment #2)
> Comment on attachment 8761514 [details] [diff] [review]
> bug1278999_gecko_v1.patch
> 
> Review of attachment 8761514 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: taskcluster/taskgraph/kind/legacy.py
> @@ +210,5 @@
> > +    except:
> > +        # generic worker
> > +        values = artifacts
> > +
> > +    for artifact in values:
> 
> How about:
> 
> if hasattr(artifacts, "values"):
>    artifacts = artifacts.values()

It is an interesting suggestion, many thanks for diving into this.

The only thing I don't like about the alternative suggestion is that it can be misleading at a glance. First artifacts is assigned in line 203:

artifacts = task_def['payload']['artifacts']

and then later, it gets "moved" to artifacts.values() a few lines further down. So a cursory glance at the code you might think that artifacts was task_def['payload']['artifacts'] without spotting it got moved on a couple of lines later. With my version, there is an intermediate variable, so you can't make this mistake. Also you clearly see from the comments the two forks the code can take - 1 route for generic worker, and 1 route for docker worker. It just feels more readable, although I see your version is more concise.
Comment on attachment 8761514 [details] [diff] [review]
bug1278999_gecko_v1.patch

Review of attachment 8761514 [details] [diff] [review]:
-----------------------------------------------------------------

::: taskcluster/taskgraph/kind/legacy.py
@@ +206,5 @@
>  
> +    try:
> +        # docker worker
> +        values = artifacts.values()
> +    except:

"except:" catches everything, even syntax errors, better to use "except AttributeError:"

@@ +207,5 @@
> +    try:
> +        # docker worker
> +        values = artifacts.values()
> +    except:
> +        # generic worker

This also holds for taskcluster-worker
Attached patch bug1278999_gecko_v2.patch (obsolete) — Splinter Review
Compromise! :-)
Attachment #8761514 - Attachment is obsolete: true
Attachment #8761514 - Flags: review?(wcosta)
Attachment #8761585 - Flags: review?(wcosta)
Attachment #8761585 - Flags: review?(wcosta) → review+
Same as previous patch, but forgot r=wcosta in commit message, so reattaching with updated commit message. =)
Attachment #8761585 - Attachment is obsolete: true
Attachment #8761614 - Flags: review?(wcosta)
Keywords: checkin-needed
Attachment #8761614 - Flags: review?(wcosta) → review+
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/fd3e2d8ed90a
handle generic worker style artifacts (list not dictionary). r=wcosta
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/fd3e2d8ed90a
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Component: Platform and Services → Services
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: