Skip to content

Commit

Permalink
Do not use a proxy when accessing the Patroni API (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Dec 4, 2023
1 parent 72ca50c commit cb9db73
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
changed_when: false
failed_when: false
check_mode: false
environment:
no_proxy: "{{ inventory_hostname }}"

# Stop, if Patroni is unavailable
- name: The Patroni cluster is unhealthy
Expand Down
2 changes: 2 additions & 0 deletions pg_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
register: patroni_leader_result
changed_when: false
failed_when: false
environment:
no_proxy: "{{ inventory_hostname }}"

# Stop, if Patroni is unavailable
- name: The Patroni cluster is unhealthy
Expand Down
4 changes: 4 additions & 0 deletions roles/patroni/tasks/custom_wal_dir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
until: patroni_result.status == 200
retries: 120
delay: 10
environment:
no_proxy: "{{ inventory_hostname }}"
when: is_master | bool and not ansible_check_mode

- name: Start patroni service on the Replica
Expand Down Expand Up @@ -141,6 +143,8 @@
until: patroni_result.status == 200
retries: 120
delay: 10
environment:
no_proxy: "{{ inventory_hostname }}"
when: not is_master | bool and not ansible_check_mode

- name: "Remove {{ pg_wal_dir }}_old directory"
Expand Down
4 changes: 4 additions & 0 deletions roles/patroni/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@
until: result.status == 200
retries: 10
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"
when:
- (patroni_standby_cluster.host is not defined or patroni_standby_cluster.host | length < 1)
- not ansible_check_mode
Expand Down Expand Up @@ -1000,6 +1002,8 @@
until: replica_result.status == 200
retries: 1200 # timeout 10 hours
delay: 30
environment:
no_proxy: "{{ inventory_hostname }}"
when: not ansible_check_mode
when: not is_master | bool
tags: patroni, patroni_start_replica, point_in_time_recovery
Expand Down
2 changes: 2 additions & 0 deletions roles/update/tasks/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
register: patroni_leader_result
changed_when: false
failed_when: false
environment:
no_proxy: "{{ inventory_hostname }}"

- name: Get a list of databases
ansible.builtin.command: >-
Expand Down
2 changes: 1 addition & 1 deletion roles/update/tasks/pre_checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: '[Pre-Check] (ALL) Test PostgreSQL DB Access'
ansible.builtin.command: >
ansible.builtin.command: >-
psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc 'select 1'
changed_when: false

Expand Down
2 changes: 2 additions & 0 deletions roles/update/tasks/start_services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
until: patroni_replica_result.status == 200
retries: 300
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"

- name: Check PostgreSQL is started and accepting connections
become: true
Expand Down
2 changes: 2 additions & 0 deletions roles/update/tasks/start_traffic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
until: patroni_replica_result.status == 200
retries: 30
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"
...
2 changes: 2 additions & 0 deletions roles/update/tasks/stop_traffic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
until: patroni_replica_result.status == 503
retries: 30
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"

- name: Wait for active transactions to complete
become: true
Expand Down
2 changes: 2 additions & 0 deletions roles/update/tasks/switchover.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@
until: patroni_replica_result.status == 200
retries: 300
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"
...
6 changes: 6 additions & 0 deletions roles/upgrade/tasks/rollback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
register: patroni_cluster_result
failed_when: false
changed_when: false
environment:
no_proxy: "{{ inventory_hostname }}"
when:
- inventory_hostname in groups['primary']

Expand Down Expand Up @@ -133,6 +135,8 @@
until: patroni_leader_result.status == 200
retries: "{{ (pg_start_stop_timeout | int) // 2 }}"
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"
when:
- inventory_hostname in groups['primary']

Expand Down Expand Up @@ -163,6 +167,8 @@
until: patroni_replica_result.status == 200
retries: "{{ (pg_start_stop_timeout | int) // 2 }}"
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"
when:
- inventory_hostname in groups['secondary']

Expand Down
4 changes: 4 additions & 0 deletions roles/upgrade/tasks/start_services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
until: patroni_leader_result.status == 200
retries: "{{ (pg_start_stop_timeout | int) // 2 }}"
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"
when:
- inventory_hostname in groups['primary']

Expand Down Expand Up @@ -65,6 +67,8 @@
until: patroni_replica_result.status == 200
retries: "{{ (pg_start_stop_timeout | int) // 2 }}"
delay: 2
environment:
no_proxy: "{{ inventory_hostname }}"
when:
- inventory_hostname in groups['secondary']

Expand Down
2 changes: 2 additions & 0 deletions update_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
register: patroni_leader_result
changed_when: false
failed_when: false
environment:
no_proxy: "{{ inventory_hostname }}"
tags: always

- name: '[Prepare] Add host to group "primary" (in-memory inventory)'
Expand Down

0 comments on commit cb9db73

Please sign in to comment.