Skip to content

Commit

Permalink
Merge branch 'zalando:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathon2nd authored Dec 16, 2024
2 parents 3a8fcfd + 4b3d1c6 commit e9c407e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/publish-ghcr-container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
jobs:
publish:
name: Build and push Spilo multiarch images
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
contents: 'read'
packages: 'write'
Expand All @@ -20,15 +20,15 @@ jobs:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up packages
run: sudo apt-get install -y docker-compose

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.7

- name: Install flake8 and docker-compose
run: python -m pip install flake8 docker-compose==1.17.1
python-version: '3.10'

- name: Derive spilo image name
id: image
Expand All @@ -39,20 +39,20 @@ jobs:
echo "NAME=$IMAGE" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and export to local docker for testing
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: "postgres-appliance/"
load: true
Expand All @@ -65,7 +65,7 @@ jobs:
bash postgres-appliance/tests/test_spilo.sh
- name: Build arm64 additionaly and push multiarch image to ghcr
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: "postgres-appliance/"
push: true
Expand Down
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 e9c407e

Please sign in to comment.