Skip to content

Commit 5204383

Browse files
committed
v4.0.2
2 parents 0bf4ff7 + 6b68503 commit 5204383

File tree

168 files changed

+11019
-3459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+11019
-3459
lines changed

.github/workflows/install_deps.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99

1010

1111
def install_requirements(what):
12+
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip'])
13+
s = subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'wheel', 'setuptools'])
14+
if s != 0:
15+
return s
16+
1217
old_path = sys.path[:]
1318
w = os.path.join(os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe())))
1419
sys.path.insert(0, os.path.dirname(os.path.dirname(w)))
1520
try:
1621
from setup import EXTRAS_REQUIRE, read
1722
finally:
1823
sys.path = old_path
19-
requirements = ['mock>=2.0.0', 'flake8', 'pytest', 'pytest-cov'] if what == 'all' else ['behave']
24+
requirements = ['flake8', 'pytest', 'pytest-cov'] if what == 'all' else ['behave']
2025
requirements += ['coverage']
2126
# try to split tests between psycopg2 and psycopg3
2227
requirements += ['psycopg[binary]'] if sys.version_info >= (3, 8, 0) and\
@@ -28,11 +33,7 @@ def install_requirements(what):
2833
if not extras or what == 'all' or what in extras:
2934
requirements.append(r)
3035

31-
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip'])
32-
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'wheel'])
33-
r = subprocess.call([sys.executable, '-m', 'pip', 'install'] + requirements)
34-
s = subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'setuptools'])
35-
return s | r
36+
return subprocess.call([sys.executable, '-m', 'pip', 'install'] + requirements)
3637

3738

3839
def install_packages(what):
@@ -110,7 +111,7 @@ def install_etcd():
110111

111112

112113
def install_postgres():
113-
version = os.environ.get('PGVERSION', '15.1-1')
114+
version = os.environ.get('PGVERSION', '16.1-1')
114115
platform = {'darwin': 'osx', 'win32': 'windows-x64', 'cygwin': 'windows-x64'}[sys.platform]
115116
if platform == 'osx':
116117
return subprocess.call(['brew', 'install', 'expect', 'postgresql@{0}'.format(version.split('.')[0])])

.github/workflows/mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
versions = {'etcd': '9.6', 'etcd3': '16', 'consul': '13', 'exhibitor': '12', 'raft': '11', 'kubernetes': '15'}
1+
versions = {'etcd': '9.6', 'etcd3': '16', 'consul': '13', 'exhibitor': '12', 'raft': '14', 'kubernetes': '15'}

.github/workflows/release.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ jobs:
1010
build-n-publish:
1111
name: Build and publish Patroni distributions to PyPI and TestPyPI
1212
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
1315
steps:
14-
- uses: actions/checkout@master
16+
- uses: actions/checkout@v4
1517

16-
- name: Set up Python 3.9
17-
uses: actions/setup-python@v4
18+
- name: Set up Python 3.11
19+
uses: actions/setup-python@v5
1820
with:
19-
python-version: 3.9
21+
python-version: 3.11
2022

2123
- name: Install dependencies
2224
run: python .github/workflows/install_deps.py
@@ -32,13 +34,10 @@ jobs:
3234

3335
- name: Publish distribution to Test PyPI
3436
if: github.event_name == 'push'
35-
uses: pypa/gh-action-pypi-publish@v1.5.1
37+
uses: pypa/gh-action-pypi-publish@v1.9.0
3638
with:
37-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
3839
repository_url: https://test.pypi.org/legacy/
3940

4041
- name: Publish distribution to PyPI
4142
if: github.event_name == 'release'
42-
uses: pypa/[email protected]
43-
with:
44-
password: ${{ secrets.PYPI_API_TOKEN }}
43+
uses: pypa/[email protected]

.github/workflows/run_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def main():
3030
unbuffer = ['timeout', '900', 'unbuffer']
3131
else:
3232
if sys.platform == 'darwin':
33-
version = os.environ.get('PGVERSION', '15.1-1')
34-
path = '/usr/local/opt/postgresql@{0}/bin:.'.format(version.split('.')[0])
33+
version = os.environ.get('PGVERSION', '16.1-1')
34+
path = '/opt/homebrew/opt/postgresql@{0}/bin:.'.format(version.split('.')[0])
3535
unbuffer = ['unbuffer']
3636
else:
3737
path = os.path.abspath(os.path.join('pgsql', 'bin'))

.github/workflows/tests.yaml

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,22 @@ jobs:
2020
os: [ubuntu, windows, macos]
2121

2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424

2525
- name: Set up Python 3.7
26-
uses: actions/setup-python@v4
26+
uses: actions/setup-python@v5
2727
with:
2828
python-version: 3.7
29+
if: matrix.os != 'macos'
2930
- name: Install dependencies
3031
run: python .github/workflows/install_deps.py
32+
if: matrix.os != 'macos'
3133
- name: Run tests and flake8
3234
run: python .github/workflows/run_tests.py
35+
if: matrix.os != 'macos'
3336

3437
- name: Set up Python 3.8
35-
uses: actions/setup-python@v4
38+
uses: actions/setup-python@v5
3639
with:
3740
python-version: 3.8
3841
- name: Install dependencies
@@ -41,7 +44,7 @@ jobs:
4144
run: python .github/workflows/run_tests.py
4245

4346
- name: Set up Python 3.9
44-
uses: actions/setup-python@v4
47+
uses: actions/setup-python@v5
4548
with:
4649
python-version: 3.9
4750
- name: Install dependencies
@@ -50,7 +53,7 @@ jobs:
5053
run: python .github/workflows/run_tests.py
5154

5255
- name: Set up Python 3.10
53-
uses: actions/setup-python@v4
56+
uses: actions/setup-python@v5
5457
with:
5558
python-version: '3.10'
5659
- name: Install dependencies
@@ -59,14 +62,23 @@ jobs:
5962
run: python .github/workflows/run_tests.py
6063

6164
- name: Set up Python 3.11
62-
uses: actions/setup-python@v4
65+
uses: actions/setup-python@v5
6366
with:
6467
python-version: 3.11
6568
- name: Install dependencies
6669
run: python .github/workflows/install_deps.py
6770
- name: Run tests and flake8
6871
run: python .github/workflows/run_tests.py
6972

73+
- name: Set up Python 3.12
74+
uses: actions/setup-python@v5
75+
with:
76+
python-version: 3.12
77+
- name: Install dependencies
78+
run: python .github/workflows/install_deps.py
79+
- name: Run tests and flake8
80+
run: python .github/workflows/run_tests.py
81+
7082
- name: Combine coverage
7183
run: python .github/workflows/run_tests.py combine
7284

@@ -85,12 +97,12 @@ jobs:
8597
env:
8698
DCS: ${{ matrix.dcs }}
8799
ETCDVERSION: 3.4.23
88-
PGVERSION: 15.1-1 # for windows and macos
100+
PGVERSION: 16.1-1 # for windows and macos
89101
strategy:
90102
fail-fast: false
91103
matrix:
92104
os: [ubuntu]
93-
python-version: [3.7, '3.10']
105+
python-version: [3.7, 3.12]
94106
dcs: [etcd, etcd3, consul, exhibitor, kubernetes, raft]
95107
include:
96108
- os: macos
@@ -104,9 +116,9 @@ jobs:
104116
dcs: etcd3
105117

106118
steps:
107-
- uses: actions/checkout@v3
119+
- uses: actions/checkout@v4
108120
- name: Set up Python
109-
uses: actions/setup-python@v4
121+
uses: actions/setup-python@v5
110122
with:
111123
python-version: ${{ matrix.python-version }}
112124
- uses: nolar/setup-k3d-k3s@v1
@@ -125,7 +137,7 @@ jobs:
125137
- name: Run behave tests
126138
run: python .github/workflows/run_tests.py
127139
- name: Upload logs if behave failed
128-
uses: actions/upload-artifact@v3
140+
uses: actions/upload-artifact@v4
129141
if: failure()
130142
with:
131143
name: behave-${{ matrix.os }}-${{ matrix.dcs }}-${{ matrix.python-version }}-logs
@@ -145,7 +157,7 @@ jobs:
145157
needs: unit
146158
runs-on: ubuntu-latest
147159
steps:
148-
- uses: actions/setup-python@v4
160+
- uses: actions/setup-python@v5
149161
- run: python -m pip install coveralls
150162
- run: python -m coveralls --service=github --finish
151163
env:
@@ -162,27 +174,27 @@ jobs:
162174
pyright:
163175
runs-on: ubuntu-latest
164176
steps:
165-
- uses: actions/checkout@v3
177+
- uses: actions/checkout@v4
166178

167-
- name: Set up Python 3.11
168-
uses: actions/setup-python@v4
179+
- name: Set up Python 3.12
180+
uses: actions/setup-python@v5
169181
with:
170-
python-version: 3.11
182+
python-version: 3.12
171183

172184
- name: Install dependencies
173185
run: python -m pip install -r requirements.txt psycopg2-binary psycopg
174186

175-
- uses: jakebailey/pyright-action@v1
187+
- uses: jakebailey/pyright-action@v2
176188
with:
177-
version: 1.1.347
189+
version: 1.1.379
178190

179191
docs:
180192
runs-on: ubuntu-latest
181193
steps:
182-
- uses: actions/checkout@v3
194+
- uses: actions/checkout@v4
183195

184196
- name: Set up Python 3.11
185-
uses: actions/setup-python@v4
197+
uses: actions/setup-python@v5
186198
with:
187199
python-version: 3.11
188200
cache: pip
@@ -199,3 +211,20 @@ jobs:
199211
200212
- name: Generate documentation
201213
run: tox -m docs
214+
215+
isort:
216+
runs-on: ubuntu-latest
217+
steps:
218+
- uses: actions/checkout@v4
219+
220+
- name: Set up Python 3.12
221+
uses: actions/setup-python@v5
222+
with:
223+
python-version: 3.12
224+
cache: pip
225+
226+
- name: isort
227+
uses: isort/isort-action@master
228+
with:
229+
requirementsFiles: "requirements.txt requirements.dev.txt requirements.docs.txt"
230+
sort-paths: "patroni tests features setup.py"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ lib64
2727
pip-log.txt
2828

2929
# Unit test / coverage reports
30-
.coverage
30+
.coverage*
3131
.tox
3232
nosetests.xml
3333
coverage.xml
3434
htmlcov
3535
junit.xml
3636
features/output*
3737
dummy
38+
result.json
3839

3940
# Translations
4041
*.mo

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## This Dockerfile is meant to aid in the building and debugging patroni whilst developing on your local machine
22
## It has all the necessary components to play/debug with a single node appliance, running etcd
3-
ARG PG_MAJOR=15
3+
ARG PG_MAJOR=16
44
ARG COMPRESS=false
55
ARG PGHOME=/home/postgres
66
ARG PGDATA=$PGHOME/data
@@ -94,9 +94,9 @@ RUN set -ex \
9494
/usr/share/locale/??_?? \
9595
/usr/share/postgresql/*/man \
9696
/usr/share/postgresql-common/pg_wrapper \
97-
/usr/share/vim/vim80/doc \
98-
/usr/share/vim/vim80/lang \
99-
/usr/share/vim/vim80/tutor \
97+
/usr/share/vim/vim*/doc \
98+
/usr/share/vim/vim*/lang \
99+
/usr/share/vim/vim*/tutor \
100100
# /var/lib/dpkg/info/* \
101101
&& find /usr/bin -xtype l -delete \
102102
&& find /var/log -type f -exec truncate --size 0 {} \; \
@@ -125,6 +125,8 @@ RUN if [ "$COMPRESS" = "true" ]; then \
125125
&& /bin/busybox sh -c "(find $save_dirs -not -type d && cat /exclude /exclude && echo exclude) | sort | uniq -u | xargs /bin/busybox rm" \
126126
&& /bin/busybox --install -s \
127127
&& /bin/busybox sh -c "find $save_dirs -type d -depth -exec rmdir -p {} \; 2> /dev/null"; \
128+
else \
129+
/bin/busybox --install -s; \
128130
fi
129131

130132
FROM scratch
@@ -143,6 +145,7 @@ ARG PGBIN=/usr/lib/postgresql/$PG_MAJOR/bin
143145

144146
ENV LC_ALL=$LC_ALL LANG=$LANG EDITOR=/usr/bin/editor
145147
ENV PGDATA=$PGDATA PATH=$PATH:$PGBIN
148+
ENV ETCDCTL_API=3
146149

147150
COPY patroni /patroni/
148151
COPY extras/confd/conf.d/haproxy.toml /etc/confd/conf.d/

Dockerfile.citus

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## This Dockerfile is meant to aid in the building and debugging patroni whilst developing on your local machine
22
## It has all the necessary components to play/debug with a single node appliance, running etcd
3-
ARG PG_MAJOR=15
3+
ARG PG_MAJOR=16
44
ARG COMPRESS=false
55
ARG PGHOME=/home/postgres
66
ARG PGDATA=$PGHOME/data
@@ -40,7 +40,7 @@ RUN set -ex \
4040
echo "deb [signed-by=/etc/apt/trusted.gpg.d/citusdata_community.gpg] https://packagecloud.io/citusdata/community/debian/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/citusdata_community.list \
4141
&& curl -sL https://packagecloud.io/citusdata/community/gpgkey | gpg --dearmor > /etc/apt/trusted.gpg.d/citusdata_community.gpg \
4242
&& apt-get update -y \
43-
&& apt-get -y install postgresql-$PG_MAJOR-citus-11.3; \
43+
&& apt-get -y install postgresql-$PG_MAJOR-citus-12.1; \
4444
fi \
4545
\
4646
# Cleanup all locales but en_US.UTF-8
@@ -113,9 +113,9 @@ RUN set -ex \
113113
/usr/share/locale/??_?? \
114114
/usr/share/postgresql/*/man \
115115
/usr/share/postgresql-common/pg_wrapper \
116-
/usr/share/vim/vim80/doc \
117-
/usr/share/vim/vim80/lang \
118-
/usr/share/vim/vim80/tutor \
116+
/usr/share/vim/vim*/doc \
117+
/usr/share/vim/vim*/lang \
118+
/usr/share/vim/vim*/tutor \
119119
# /var/lib/dpkg/info/* \
120120
&& find /usr/bin -xtype l -delete \
121121
&& find /var/log -type f -exec truncate --size 0 {} \; \
@@ -164,6 +164,7 @@ ARG PGBIN=/usr/lib/postgresql/$PG_MAJOR/bin
164164

165165
ENV LC_ALL=$LC_ALL LANG=$LANG EDITOR=/usr/bin/editor
166166
ENV PGDATA=$PGDATA PATH=$PATH:$PGBIN
167+
ENV ETCDCTL_API=3
167168

168169
COPY patroni /patroni/
169170
COPY extras/confd/conf.d/haproxy.toml /etc/confd/conf.d/
@@ -179,7 +180,7 @@ RUN sed -i 's/env python/&3/' /patroni*.py \
179180
&& sed -i "s|^\( data_dir: \).*|\1$PGDATA|" postgres?.yml \
180181
&& sed -i "s|^#\( bin_dir: \).*|\1$PGBIN|" postgres?.yml \
181182
&& sed -i 's/^ - encoding: UTF8/ - locale: en_US.UTF-8\n&/' postgres?.yml \
182-
&& sed -i 's/^scope:/log:\n loggers:\n patroni.postgresql.citus: DEBUG\n#&/' postgres?.yml \
183+
&& sed -i 's/^scope:/log:\n loggers:\n patroni.postgresql.mpp.citus: DEBUG\n#&/' postgres?.yml \
183184
&& sed -i 's/^\(name\|etcd\| host\| authentication\| connect_address\| parameters\):/#&/' postgres?.yml \
184185
&& sed -i 's/^ \(replication\|superuser\|rewind\|unix_socket_directories\|\(\( \)\{0,1\}\(username\|password\)\)\):/#&/' postgres?.yml \
185186
&& sed -i 's/^postgresql:/&\n basebackup:\n checkpoint: fast/' postgres?.yml \

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Compose, Zalando SE
3+
Copyright (c) 2024 Compose, Zalando SE, Patroni Contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)