-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Delay update of artifacts until final job save #11832
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from awx.main.tasks.callback import RunnerCallback | ||
from awx.main.constants import ANSIBLE_RUNNER_NEEDS_UPDATE_MESSAGE | ||
|
||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
def test_delay_update(mock_me): | ||
rc = RunnerCallback() | ||
rc.delay_update(foo='bar') | ||
assert rc.extra_update_fields == {'foo': 'bar'} | ||
rc.delay_update(foo='foobar') | ||
assert rc.extra_update_fields == {'foo': 'foobar'} | ||
rc.delay_update(bar='foo') | ||
assert rc.get_delayed_update_fields() == {'foo': 'foobar', 'bar': 'foo', 'emitted_events': 0} | ||
|
||
|
||
def test_delay_update_skip_if_set(mock_me): | ||
rc = RunnerCallback() | ||
rc.delay_update(foo='bar', skip_if_already_set=True) | ||
assert rc.extra_update_fields == {'foo': 'bar'} | ||
rc.delay_update(foo='foobar', skip_if_already_set=True) | ||
assert rc.extra_update_fields == {'foo': 'bar'} | ||
|
||
|
||
def test_delay_update_failure_fields(mock_me): | ||
rc = RunnerCallback() | ||
rc.delay_update(job_explanation='1') | ||
rc.delay_update(job_explanation=_('2')) | ||
assert rc.extra_update_fields == {'job_explanation': '1\n2'} | ||
rc.delay_update(result_traceback='1') | ||
rc.delay_update(result_traceback=_('2')) | ||
rc.delay_update(result_traceback=_('3'), skip_if_already_set=True) | ||
assert rc.extra_update_fields == {'job_explanation': '1\n2', 'result_traceback': '1\n2'} | ||
|
||
|
||
def test_duplicate_updates(mock_me): | ||
rc = RunnerCallback() | ||
rc.delay_update(job_explanation='really long summary...') | ||
rc.delay_update(job_explanation='really long summary...') | ||
rc.delay_update(job_explanation='really long summary...') | ||
assert rc.extra_update_fields == {'job_explanation': 'really long summary...'} | ||
|
||
|
||
def test_special_ansible_runner_message(mock_me): | ||
rc = RunnerCallback() | ||
rc.delay_update(result_traceback='Traceback:\ngot an unexpected keyword argument\nFile: foo.py') | ||
rc.delay_update(result_traceback='Traceback:\ngot an unexpected keyword argument\nFile: bar.py') | ||
assert rc.get_delayed_update_fields().get('result_traceback') == ( | ||
'Traceback:\ngot an unexpected keyword argument\nFile: foo.py\n' | ||
'Traceback:\ngot an unexpected keyword argument\nFile: bar.py\n' | ||
f'{ANSIBLE_RUNNER_NEEDS_UPDATE_MESSAGE}' | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an in-congruence here. Yes, if the status_handler received this information the receptor output should be this... but it's an imperfect metric. These two things are associated, but other events could cause one to be true but not the other.
so I forced it by doing this
And this works as I expected. The new
if
condition is accurate. I like this also because it avoids running additional receptor commands when they are not necessary. That's something theif
here was accomplishing before, and I didn't want to lose that.