Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion api/jobs/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def get_config(self, _id):
# Detect if config is old- or new-style.
# TODO: remove this logic with a DB upgrade, ref database.py's reserved upgrade section.

if c.get('config') is not None and c.get('inputs') is not None:
if 'config' in c and c.get('inputs') is not None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you explain the rationale behind this change? This would fail if c['config'] is None.

Copy link
Copy Markdown
Contributor Author

@nagem nagem Oct 24, 2017

Choose a reason for hiding this comment

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

It was failing when the config key existed but was not set. AKA, it was the "new" style, but there was no config for the job. There were inputs and destination.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Out-of-band: Given that this is a database anti-upgrade hackaround, let's just run with this for now 👍

# New behavior

# API keys are only returned in-flight, when the job is running, and not persisted to the job object.
Expand Down
6 changes: 4 additions & 2 deletions api/jobs/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from . import gears
from .jobs import Job
from .queue import Queue

log = config.log

Expand Down Expand Up @@ -237,9 +238,10 @@ def create_jobs(db, container_before, container_after, container_type):
spawned_jobs = []

for pj in potential_jobs:
pj['job'].insert()
spawned_jobs.append(pj['rule']['alg'])
job_map = pj['job'].map()
Queue.enqueue_job(job_map, None) # passing no origin results in system origin
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given this usage, what would your opinion be of making origin a named parameter, and always naming it when calling?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is more important we set and origin when we can, this is the only situation I am aware of that does not set an origin. I worry if the origin is optional, it will not be set when it should.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Out of band: the None here is really the problem, this will be replaced with a system default origin to make the call clearer.


spawned_jobs.append(pj['rule']['alg'])

return spawned_jobs

Expand Down