Skip to content

Commit 9366435

Browse files
committed
Upgrade: show stashed changes when git stash pop fails
We may end up with merge conflicts in upgrade jobs.
1 parent d1bb9e4 commit 9366435

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

ansible/deploy-openstack-config.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,30 @@
102102
dest: "{{ src_directory }}/{{ kayobe_config_name }}"
103103
update: "{{ upgrade | bool }}"
104104

105-
- name: Pop stashed Kayobe Config changes (upgrade)
106-
ansible.builtin.command:
107-
cmd: git stash pop
108-
chdir: "{{ src_directory }}/{{ kayobe_config_name }}"
109-
when: upgrade | bool
105+
- when: upgrade
106+
block:
107+
- name: Pop stashed Kayobe Config changes (upgrade)
108+
ansible.builtin.command:
109+
cmd: git stash pop
110+
chdir: "{{ src_directory }}/{{ kayobe_config_name }}"
111+
register: pop_result
112+
# NOTE: Fails when no stash exists
113+
failed_when:
114+
- pop_result is failure
115+
- "'No stash entries found' not in pop_result.stderr"
116+
rescue:
117+
- name: Check Kayobe Config diff (upgrade)
118+
ansible.builtin.command:
119+
cmd: git diff
120+
chdir: "{{ src_directory }}/{{ kayobe_config_name }}"
121+
register: diff_result
122+
123+
- name: Fail on git stash pop failure
124+
ansible.builtin.fail:
125+
msg: |-
126+
Failed to pop stashed changes after upgrade.
127+
128+
{{ diff_result.stdout }}
110129
111130
- name: Replace TLS changes to avoid git conflicts (upgrade)
112131
ansible.builtin.shell:

0 commit comments

Comments
 (0)