Skip to content

Commit

Permalink
[Patroni4] change no_master and master as argument (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
idanovinda authored Dec 13, 2024
1 parent 517daf7 commit 635ec0c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion postgres-appliance/runit/pgqd/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ if ! $CHPST true 2> /dev/null; then
fi

exec 2>&1
exec $CHPST env -i PGAPPNAME="pgq ticker" /scripts/patroni_wait.sh --role master -- /usr/bin/pgqd /home/postgres/pgq_ticker.ini
exec $CHPST env -i PGAPPNAME="pgq ticker" /scripts/patroni_wait.sh --role primary -- /usr/bin/pgqd /home/postgres/pgq_ticker.ini
2 changes: 1 addition & 1 deletion postgres-appliance/scripts/callback_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def main():

ec2 = boto.ec2.connect_to_region(metadata['region'])

if argc == 5 and role in ('master', 'standby_leader') and action in ('on_start', 'on_role_change'):
if argc == 5 and role in ('primary', 'standby_leader') and action in ('on_start', 'on_role_change'):
associate_address(ec2, sys.argv[1], instance_id)

instance = get_instance(ec2, instance_id)
Expand Down
3 changes: 2 additions & 1 deletion postgres-appliance/scripts/callback_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
logger = logging.getLogger(__name__)

LABEL = os.environ.get("KUBERNETES_ROLE_LABEL", 'spilo-role')
LEADER_LABEL_VALUE = os.environ.get("KUBERNETES_LEADER_LABEL_VALUE", 'master')


def read_first_line(filename):
Expand Down Expand Up @@ -78,7 +79,7 @@ def record_role_change(action, new_role, cluster):
new_role = None if action == 'on_stop' else new_role
logger.debug("Changing the pod's role to %s", new_role)
pod_namespace = os.environ.get('POD_NAMESPACE', read_first_line(KUBE_NAMESPACE_FILENAME)) or 'default'
if new_role == 'master':
if new_role == LEADER_LABEL_VALUE:
change_endpoints(pod_namespace, cluster)
change_pod_role_label(pod_namespace, new_role)

Expand Down
4 changes: 2 additions & 2 deletions postgres-appliance/scripts/configure_spilo.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def deep_update(a, b):
threshold_megabytes: {{WALE_BACKUP_THRESHOLD_MEGABYTES}}
threshold_backup_size_percentage: {{WALE_BACKUP_THRESHOLD_PERCENTAGE}}
retries: 2
no_master: 1
no_leader: 1
{{/USE_WALE}}
basebackup_fast_xlog:
command: /scripts/basebackup.sh
Expand All @@ -390,7 +390,7 @@ def deep_update(a, b):
threshold_megabytes: {{WALE_BACKUP_THRESHOLD_MEGABYTES}}
threshold_backup_size_percentage: {{WALE_BACKUP_THRESHOLD_PERCENTAGE}}
retries: 2
no_master: 1
no_leader: 1
{{/STANDBY_WITH_WALE}}
'''

Expand Down
2 changes: 1 addition & 1 deletion postgres-appliance/scripts/on_role_change.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ shift


readonly dbname=postgres
if [[ "${*: -3:1}" == "on_role_change" && "${*: -2:1}" == "master" ]]; then
if [[ "${*: -3:1}" == "on_role_change" && "${*: -2:1}" == "primary" ]]; then
num=30 # wait 30 seconds for end of recovery
while [[ $((num--)) -gt 0 ]]; do
if [[ "$(psql -d $dbname -tAc 'SELECT pg_catalog.pg_is_in_recovery()')" == "f" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions postgres-appliance/scripts/patroni_wait.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

ROLE=master
ROLE=primary
INTERVAL=60
TIMEOUT=""

Expand All @@ -17,7 +17,7 @@ Options:
-t, --timeout Fail after TIMEOUT seconds (default: no timeout)
Waits for ROLE (master or replica). It will check every INTERVAL seconds ($INTERVAL).
Waits for ROLE (primary or replica). It will check every INTERVAL seconds ($INTERVAL).
If TIMEOUT is specified, it will stop trying after TIMEOUT seconds.
Executes COMMAND after ROLE has become available. (Default: exit 0)
Expand Down
2 changes: 1 addition & 1 deletion postgres-appliance/scripts/wale_restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ while getopts ":-:" optchar; do
threshold_megabytes=*|threshold-megabytes=* )
THRESHOLD_MEGABYTES=${OPTARG#*=}
;;
no_master=*|no-master=* )
no_leader=*|no-master=* )
NO_MASTER=${OPTARG#*=}
;;
esac
Expand Down

0 comments on commit 635ec0c

Please sign in to comment.