From 019fa3d356c70c0c3a0eab5765a36af566ea08ea Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Fri, 13 Oct 2023 09:33:27 -0400 Subject: [PATCH] Add background keepalive to awx-manage migrate (#1589) --- roles/installer/tasks/install.yml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/roles/installer/tasks/install.yml b/roles/installer/tasks/install.yml index c4ab221c2..f68eb1d15 100644 --- a/roles/installer/tasks/install.yml +++ b/roles/installer/tasks/install.yml @@ -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 != ''