Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Upgrade Support for Standby Cluster #830

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/molecule_pg_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ jobs:
- distro: debian11
tag: latest
namespace: geerlingguy
- distro: debian10
- distro: ubuntu2404
tag: latest
namespace: geerlingguy
- distro: ubuntu2204
tag: latest
namespace: geerlingguy
- distro: ubuntu2004
tag: latest
namespace: geerlingguy
- distro: rockylinux8
tag: latest
namespace: geerlingguy
Expand Down
18 changes: 3 additions & 15 deletions automation/roles/upgrade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,10 @@ Please see the variable file vars/[upgrade.yml](../../vars/upgrade.yml)
- Backup the patroni.yml configuration file
- Edit the patroni.yml configuration file
- **Update parameters**: `data_dir`, `bin_dir`, `config_dir`
- **Check if the 'standby_cluster' parameter is specified**
- Remove parameters: `standby_cluster` (if exists)
- **Prepare the PostgreSQL parameters**
- Notes: Removed or renamed parameters
- **Remove 'standby_cluster' parameter (if exists)**
- Notes: To support upgrades in the Patroni Standby Cluster
- **Prepare the PostgreSQL parameters** (removed or renamed parameters)
- Check if the '`replacement_sort_tuples`' parameter is specified (removed in PG 11)
- remove parameter: 'replacement_sort_tuples' (if exists)
- Check if the '`default_with_oids`' parameter is specified (removed in PG 12)
- remove parameter: 'default_with_oids' (if exists)
- Check if the '`wal_keep_segments`' parameter is specified (removed in PG 13)
- replace parameter: 'wal_keep_segments' to '`wal_keep_size`'
- Check if the '`operator_precedence_warning`' parameter is specified" (removed in PG 14)
- remove parameter: 'operator_precedence_warning' (if exists)
- Check if the '`vacuum_cleanup_index_scale_factor`' parameter is specified (removed in PG 14)
- remove parameter: 'vacuum_cleanup_index_scale_factor' (if exists)
- Check if the '`stats_temp_directory`' parameter is specified (removed in PG 15)
- remove parameter: 'stats_temp_directory' (if exists)
- **Copy pg_hba.conf to `pg_new_confdir`**
- Notes: to save pg_hba rules

Expand Down
31 changes: 11 additions & 20 deletions automation/roles/upgrade/tasks/update_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@
loop_control:
label: '{{ item.replace }}'

# To support upgrades in the Patroni Standby Cluster.
- block: # standby_cluster
- name: "Edit patroni.yml | check if the 'standby_cluster' parameter is specified"
ansible.builtin.command: grep standby_cluster {{ patroni_config_file }}
register: standby_cluster_output
changed_when: false
failed_when: false

# The standby_cluster parameter will be removed from the bootstrap.dcs section (if exists)
# along with all the text between 'standby_cluster' and the next 'initdb' parameter
- name: "Edit patroni.yml | remove parameters: standby_cluster (if exists)"
ansible.builtin.replace:
path: "{{ patroni_config_file }}"
regexp: '^\s*standby_cluster:[^\n]*\n(.|\n)*?initdb:'
replace: ' initdb:'
when: standby_cluster_output.stdout | length > 0
when:
- patroni_standby_cluster.host is defined
- patroni_standby_cluster.host | length > 0

# Prepare the parameters for PostgreSQL (removed or renamed parameters).

- block: # replacement_sort_tuples (removed in the PG 11)
Expand Down Expand Up @@ -269,6 +249,17 @@

# TODO: Prepare the parameters for PostgreSQL 18 and etc.

# To support upgrades in the Patroni Standby Cluster.
- name: "Edit patroni.yml | remove parameter: standby_cluster (if exists)"
ansible.builtin.replace:
path: "{{ patroni_config_file }}"
regexp: '^\s*standby_cluster:[^\n]*\n(.|\n)*?initdb:'
replace: ' initdb:'

- name: "Remove 'standby_cluster' parameter from DCS (if exists)"
ansible.builtin.command: patronictl -c {{ patroni_config_file }} edit-config -s standby_cluster=null --force
when: inventory_hostname in groups['primary']

# Copy the pg_hba.conf file to a new PostgreSQL to save pg_hba rules.
- name: "Copy pg_hba.conf to {{ pg_new_confdir }}"
ansible.builtin.copy:
Expand Down
Loading