Upgrade to Patroni 4.0.5 or later

Overview

patroni should be upgraded to 4.0.5. This is the first version to support python 3.13.7 and is a requirement to upgrade omnibus-gitlab's python version.

Context

Python 3.9 is EOL and Patroni got support for 3.13 in 4.0.5.

This will require significant effort. The patch notes mention specific difficulty in the migration. omnibus-gitlab also has gitlab-ctl commands that reference the now-deprecated master:

grep -R master files/gitlab-ctl-commands-ee/lib/patroni.rb 
files/gitlab-ctl-commands-ee/lib/patroni.rb:        opts.on('--master [MASTER]', 'The name of the current master') do |m|
files/gitlab-ctl-commands-ee/lib/patroni.rb:          options[:master] = m
files/gitlab-ctl-commands-ee/lib/patroni.rb:        opts.on('--master [MASTER]', 'The name of the current master') do |m|
files/gitlab-ctl-commands-ee/lib/patroni.rb:          options[:master] = m
files/gitlab-ctl-commands-ee/lib/patroni.rb:    command << "--master #{options[:master]}" if options[:master]
files/gitlab-ctl-commands-ee/lib/patroni.rb:    command << "--master #{options[:master]}" if options[:master]

Upstream breaking changes in 4.0.0+ versions

Breaking changes

  • The following breaking changes were introduced when getting rid of the non-inclusive “master” term in the Patroni code:
    • On Kubernetes, Patroni by default will set role label to primary. In case if you want to keep the old behavior and avoid downtime or lengthy complex migrations, you can configure parameters kubernetes.leader_label_value and kubernetes.standby_leader_label_value to master. Read more here.
    • Patroni role is written to DCS as primary instead of master.
    • Patroni role returned by Patroni REST API has been changed from master to primary.
    • Patroni REST API no longer accepts role=master in requests to /switchover, /failover, /restart endpoints.
    • /metrics REST API endpoint will no longer report patroni_master metric.
    • patronictl no longer accepts --master option for any command. --leader or --primary options should be used instead.
    • no_master option in the declarative configuration of custom replica creation methods is no longer treated as a special option, please use no_leader instead.
    • patroni_wale_restore script doesn’t accept --no_master option anymore.
    • patroni_barman script doesn’t accept --role=master option anymore.
    • All callback scripts are executed with role=primary option passed instead of role=master.
  • patronictl failover does not accept --leader option that was deprecated since Patroni 3.2.0.
  • User creation functionality (bootstrap.users configuration section) deprecated since Patroni 3.2.0 has been removed.

Deliverables

  • Update Patroni to the most recent verison possible without incurring breaking changes to our users to avoid more delays of the Python 3.13 upgrade.
  • Confirm upgrade to this version does not break existing database clusters.
    • Patroni for in primary cluster.
    • Patroni works in the secondary / geo cluster.
  • Confirm fresh installation with this version works.
  • Confirm Patroni Failover works.
    • Failover in an upgraded installation.
    • Failover in a fresh installation.
  • Validate prometheus metrics changes.
Edited by Nailia Iskhakova