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

fix for unspecified retries on until + test #16963

Merged
merged 1 commit into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/ansible/executor/task_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,13 @@ def _execute(self, variables=None):

# Read some values from the task, so that we can modify them if need be
if self._task.until:
retries = self._task.retries + 1
retries = self._task.retries
if retries is None:
retries = 3
elif retries <= 0:
retries = 1
else:
retries += 1
else:
retries = 1

Expand Down
1 change: 1 addition & 0 deletions test/integration/non_destructive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- { role: test_changed_when, tags: test_changed_when }
- { role: test_failed_when, tags: test_failed_when }
- { role: test_handlers, tags: test_handlers }
- { role: test_until, tags: test_until }
- { role: test_copy, tags: test_copy }
- { role: test_stat, tags: test_stat }
- { role: test_template, tags: test_template }
Expand Down
32 changes: 32 additions & 0 deletions test/integration/roles/test_until/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
- shell: python -c "import tempfile; print(tempfile.mkstemp()[1])"
register: tempfilepath

- set_fact:
until_tempfile_path: "{{ tempfilepath.stdout }}"

- name: loop with default retries
shell: echo "run" >> {{ until_tempfile_path }} && wc -w < {{ until_tempfile_path }} | tr -d ' '
register: runcount
until: runcount.stdout | int == 3
delay: 0.01

- assert:
that: runcount.stdout | int == 3

- file: path="{{ until_tempfile_path }}" state=absent

- name: loop with specified max retries
shell: echo "run" >> {{ until_tempfile_path }}
until: 1==0
retries: 5
delay: 0.01
ignore_errors: true

- name: validate output
shell: wc -l < {{ until_tempfile_path }}
register: runcount

- assert:
that: runcount.stdout | int == 6 # initial + 5 retries

- file: path="{{ until_tempfile_path }}" state=absent