Skip to content

Commit

Permalink
Add background keepalive to awx-manage migrate (ansible#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealHaoLiu authored Oct 13, 2023
1 parent 4a968aa commit 019fa3d
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions roles/installer/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,26 @@
namespace: "{{ ansible_operator_meta.namespace }}"
pod: "{{ awx_task_pod_name }}"
container: "{{ ansible_operator_meta.name }}-task"
command: >-
bash -c "awx-manage migrate --noinput"
command: |
bash -c "
function end_keepalive {
rc=$?
rm -f \"$1\"
kill $(cat /proc/$2/task/$2/children 2>/dev/null) 2>/dev/null || true
wait $2 || true
exit $rc
}
keepalive_file=\"$(mktemp)\"
while [[ -f \"$keepalive_file\" ]]; do
echo 'Database schema migration in progress...'
sleep 60
done &
keepalive_pid=$!
trap 'end_keepalive \"$keepalive_file\" \"$keepalive_pid\"' EXIT SIGINT SIGTERM
echo keepalive_pid: $keepalive_pid
awx-manage migrate --noinput
echo 'Successful'
"
register: migrate_result
when:
- awx_task_pod_name != ''
Expand Down

0 comments on commit 019fa3d

Please sign in to comment.