mirror of
https://github.com/ansible/awx-operator.git
synced 2026-03-26 21:33:14 +00:00
Check if pg_isready before trying to restore to new postgresql pod (#2039)
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
postgres_configuration_secret: "{{ spec['postgres_configuration_secret'] | default(postgres_configuration_secret) }}"
|
postgres_configuration_secret: "{{ spec['postgres_configuration_secret'] | default(postgres_configuration_secret) }}"
|
||||||
|
|
||||||
- name: Check for specified PostgreSQL configuration
|
- name: Check for specified PostgreSQL configuration
|
||||||
k8s_info:
|
kubernetes.core.k8s_info:
|
||||||
kind: Secret
|
kind: Secret
|
||||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||||
name: '{{ postgres_configuration_secret }}'
|
name: '{{ postgres_configuration_secret }}'
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Get the postgres pod information
|
- name: Get the postgres pod information
|
||||||
k8s_info:
|
kubernetes.core.k8s_info:
|
||||||
kind: Pod
|
kind: Pod
|
||||||
namespace: '{{ ansible_operator_meta.namespace }}'
|
namespace: '{{ ansible_operator_meta.namespace }}'
|
||||||
label_selectors:
|
label_selectors:
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
when: awx_postgres_type == 'managed'
|
when: awx_postgres_type == 'managed'
|
||||||
|
|
||||||
- name: Check for presence of AWX Deployment
|
- name: Check for presence of AWX Deployment
|
||||||
k8s_info:
|
kubernetes.core.k8s_info:
|
||||||
api_version: apps/v1
|
api_version: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
name: "{{ deployment_name }}-task"
|
name: "{{ deployment_name }}-task"
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
register: this_deployment
|
register: this_deployment
|
||||||
|
|
||||||
- name: Scale down Deployment for migration
|
- name: Scale down Deployment for migration
|
||||||
k8s_scale:
|
kubernetes.core.k8s_scale:
|
||||||
api_version: apps/v1
|
api_version: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
@@ -72,6 +72,14 @@
|
|||||||
resolvable_db_host: '{{ (awx_postgres_type == "managed") | ternary(awx_postgres_host + "." + ansible_operator_meta.namespace + ".svc." + cluster_name, awx_postgres_host) }}' # yamllint disable-line rule:line-length
|
resolvable_db_host: '{{ (awx_postgres_type == "managed") | ternary(awx_postgres_host + "." + ansible_operator_meta.namespace + ".svc." + cluster_name, awx_postgres_host) }}' # yamllint disable-line rule:line-length
|
||||||
no_log: "{{ no_log }}"
|
no_log: "{{ no_log }}"
|
||||||
|
|
||||||
|
- name: Set pg_isready command
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
pg_isready: >-
|
||||||
|
pg_isready
|
||||||
|
-h {{ resolvable_db_host }}
|
||||||
|
-p {{ awx_postgres_port }}
|
||||||
|
no_log: "{{ no_log }}"
|
||||||
|
|
||||||
- name: Set pg_restore command
|
- name: Set pg_restore command
|
||||||
set_fact:
|
set_fact:
|
||||||
pg_restore: >-
|
pg_restore: >-
|
||||||
@@ -112,7 +120,7 @@
|
|||||||
when: force_drop_db
|
when: force_drop_db
|
||||||
|
|
||||||
- name: Restore database dump to the new postgresql container
|
- name: Restore database dump to the new postgresql container
|
||||||
k8s_exec:
|
kubernetes.core.k8s_exec:
|
||||||
namespace: "{{ backup_pvc_namespace }}"
|
namespace: "{{ backup_pvc_namespace }}"
|
||||||
pod: "{{ ansible_operator_meta.name }}-db-management"
|
pod: "{{ ansible_operator_meta.name }}-db-management"
|
||||||
container: "{{ ansible_operator_meta.name }}-db-management"
|
container: "{{ ansible_operator_meta.name }}-db-management"
|
||||||
@@ -126,6 +134,11 @@
|
|||||||
exit $rc
|
exit $rc
|
||||||
}
|
}
|
||||||
keepalive_file=\"$(mktemp)\"
|
keepalive_file=\"$(mktemp)\"
|
||||||
|
until {{ pg_isready }} &> /dev/null
|
||||||
|
do
|
||||||
|
echo \"Waiting until Postgres is accepting connections...\"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
while [[ -f \"$keepalive_file\" ]]; do
|
while [[ -f \"$keepalive_file\" ]]; do
|
||||||
echo 'Migrating data from old database...'
|
echo 'Migrating data from old database...'
|
||||||
sleep 60
|
sleep 60
|
||||||
|
|||||||
Reference in New Issue
Block a user