Skip to content

Commit

Permalink
Update the tasks to check the availability of the VIP address (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Apr 9, 2024
1 parent 167a322 commit 238f2fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
17 changes: 15 additions & 2 deletions roles/keepalived/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,26 @@
state: restarted
listen: "restart keepalived"

# This task checks the cluster VIP's availability, selecting the appropriate port:
# - during maintenance, it targets the database through PgBouncer or directly.
# - otherwise, it defaults to SSH, applicable during deployment when the database is not yet available.
- name: Wait for the cluster ip address (VIP) "{{ cluster_vip }}" is running
ansible.builtin.wait_for:
host: "{{ cluster_vip }}"
port: "{{ ansible_ssh_port | default(22) }}"
port: "{{ target_port }}"
state: started
timeout: 60
timeout: 15 # max wait time: 30 seconds
delay: 2
vars:
target_port: >-
{{
(postgresql_cluster_maintenance | default(false) | bool) |
ternary(
pgbouncer_listen_port if pgbouncer_install | bool else postgresql_port,
ansible_ssh_port | default(22)
)
}}
ignore_errors: true # show the error and continue the playbook execution
listen: "restart keepalived"

...
9 changes: 3 additions & 6 deletions roles/upgrade/tasks/pre_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,11 @@
- name: Make sure that the cluster ip address (VIP) "{{ cluster_vip }}" is running
ansible.builtin.wait_for:
host: "{{ cluster_vip }}"
port: "{{ target_port }}"
port: "{{ pgbouncer_listen_port if pgbouncer_install | bool else postgresql_port }}"
state: started
timeout: 3
timeout: 15 # max wait time: 30 seconds
delay: 2
vars:
target_port: >-
{{ pgbouncer_listen_port if pgbouncer_install | bool
else (ansible_ssh_port | default(22)) }}
ignore_errors: true # show the error and continue the playbook execution
when:
- cluster_vip | length > 0

Expand Down
5 changes: 3 additions & 2 deletions roles/vip-manager/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
- name: Wait for the cluster ip address (VIP) "{{ cluster_vip }}" is running
ansible.builtin.wait_for:
host: "{{ cluster_vip }}"
port: "{{ ansible_ssh_port | default(22) }}"
port: "{{ pgbouncer_listen_port if pgbouncer_install | bool else postgresql_port }}"
state: started
timeout: 60
timeout: 15 # max wait time: 30 seconds
delay: 2
ignore_errors: true # show the error and continue the playbook execution
listen: "restart vip-manager"

...

0 comments on commit 238f2fa

Please sign in to comment.