Skip to content

Commit

Permalink
etcd: expect 'is healthy' status in stdout or in stderr
Browse files Browse the repository at this point in the history
In certain scenarios (for example the old etcd version), even when a command executes without errors (.rc=0), the output may reside in stderr instead of stdout. Now we accommodate for 'is healthy' in either output stream.
  • Loading branch information
vitabaks authored Sep 14, 2023
1 parent 7f49ef6 commit f5efcd1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions roles/etcd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,20 @@
environment:
ETCDCTL_API: "3"
register: etcd_health_result
until: "'is healthy' in etcd_health_result.stdout"
until: >
'is healthy' in etcd_health_result.stdout or

Check failure on line 136 in roles/etcd/tasks/main.yml

View workflow job for this annotation

GitHub Actions / build

yaml[trailing-spaces]

Trailing spaces

Check failure on line 136 in roles/etcd/tasks/main.yml

View workflow job for this annotation

GitHub Actions / build

136:53 [trailing-spaces] trailing spaces
'is healthy' in etcd_health_result.stderr
retries: 10
delay: 10
changed_when: false
ignore_errors: false

- name: cluster health
ansible.builtin.debug:
msg: "{{ etcd_health_result.stdout }}"
msg: >
{{ etcd_health_result.stdout
if etcd_health_result.stdout | length > 0
else etcd_health_result.stderr }}
when: not ansible_check_mode
tags: etcd, etcd_start, etcd_status

Expand Down

0 comments on commit f5efcd1

Please sign in to comment.