Skip to content

Commit df69e45

Browse files
authored
Merge branch 'main' into PMM-14109-improve-advisor-ux
2 parents 3b00694 + 18e909d commit df69e45

11 files changed

Lines changed: 62 additions & 205 deletions

File tree

build/ansible/roles/postgres/files/postgres-migration

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -o errexit
33
set -o pipefail
44

55
declare POSTGRES_DATA_DIR="${POSTGRES_DATA_DIR:?must be exported by the entrypoint}"
6+
declare POSTGRES_OLD_DATA_DIR="${POSTGRES_OLD_DATA_DIR:?must be exported by the entrypoint}"
67
declare POSTGRES_PASSWORD_FILE="${POSTGRES_PASSWORD_FILE:?must be exported by the entrypoint}"
78
declare POSTGRES_BIN_DIR="${POSTGRES_BIN_DIR:?must be exported by the entrypoint}"
89

@@ -49,7 +50,7 @@ create_pg_stat_statements() {
4950
# Runs once when /srv/postgres14 exists and /srv/postgres18 does not.
5051
# Requires both pg14 and pg18 binaries in the image (shipped through PMM 3.12.x).
5152
upgrade_pg14_to_pg18() {
52-
local PG14_DATA="/srv/postgres14"
53+
local PG14_DATA="$POSTGRES_OLD_DATA_DIR"
5354
local PG14_BIN="/usr/pgsql-14/bin"
5455
local BACKUP_DIR="/srv/backup"
5556
local STAGE_DIR="${POSTGRES_DATA_DIR}.new"

build/docker/server/entrypoint.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ declare CURRENT_GID CURRENT_UID CURRENT_USER
77
# Returns 0 (true) if the given variable is set to "1" or "true".
88
is_enabled() { [ "$1" = "1" ] || [ "$1" = "true" ]; }
99
declare POSTGRES_DATA_DIR="/srv/postgres18"
10+
declare POSTGRES_OLD_DATA_DIR="/srv/postgres14"
1011
declare POSTGRES_PASSWORD_FILE="/srv/.postgres_password"
1112
declare POSTGRES_BIN_DIR="/usr/pgsql-18/bin"
1213

@@ -119,11 +120,21 @@ elif is_enabled "$PMM_DISABLE_BUILTIN_POSTGRES"; then
119120
echo "Skipping embedded PostgreSQL setup (builtin PostgreSQL is disabled)."
120121
else
121122
mkdir -p /run/postgresql
122-
chmod 750 "$POSTGRES_DATA_DIR" || true
123+
# Kubernetes applies fsGroup by recursively adding group permissions to the volume, which
124+
# turns an initdb-created 0700 data directory into 2770 — a mode PostgreSQL refuses. Repair
125+
# the current cluster and a PostgreSQL 14 directory awaiting migration, which
126+
# postgres-migration has to start in order to dump it. chmod keeps the setgid bit on a
127+
# directory, so the result is 2750, which PostgreSQL accepts.
128+
for dir in "$POSTGRES_DATA_DIR" "$POSTGRES_OLD_DATA_DIR"; do
129+
if [ -d "$dir" ]; then
130+
chmod 750 "$dir" || true
131+
fi
132+
done
133+
unset dir
123134
# Scoped to this subshell so the helper scripts inherit them without polluting
124135
# the environment that supervisord and its children are started with.
125136
(
126-
export POSTGRES_DATA_DIR POSTGRES_PASSWORD_FILE POSTGRES_BIN_DIR
137+
export POSTGRES_DATA_DIR POSTGRES_OLD_DATA_DIR POSTGRES_PASSWORD_FILE POSTGRES_BIN_DIR
127138
bash /opt/ansible/roles/postgres/files/postgres-migration
128139
bash /opt/ansible/roles/postgres/files/postgres-sep
129140
)

build/docs/MIGRATION.md

Lines changed: 0 additions & 174 deletions
This file was deleted.

build/docs/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
This directory is home to a number of PMM build-related scripts, configs and specs.
44

5-
### How to create a [Release Candidate](./RELEASE_CANDIDATE.md)
6-
7-
### Migration from [PMM v2 to v3](./MIGRATION.md)
5+
### How to create a [Release Candidate](./RELEASE_CANDIDATE.md)

documentation/docs/admin/security/ssl_encryption.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ docker run -d -p 443:8443 --volumes-from pmm-data \
5151
!!! warning "Certificate requirements"
5252
Before mounting certificates, make sure to configure them correctly:
5353

54-
- All certificates must be owned by root: `chown 0:0 /etc/pmm-certs/*`
54+
- All certificates must be owned by 1000:0: `chown 1000:0 /etc/pmm-certs/*`
5555
- Set proper permissions: `chmod 644 /etc/pmm-certs/*.crt /etc/pmm-certs/*.pem && chmod 600 /etc/pmm-certs/*.key`
5656
- The certificate directory must contain all four required files
5757
- Use port `443` for SSL encryption instead of port `80`
@@ -67,9 +67,9 @@ docker cp ca-certs.pem pmm-server:/srv/nginx/ca-certs.pem
6767
docker cp dhparam.pem pmm-server:/srv/nginx/dhparam.pem
6868

6969
# Set proper ownership and permissions
70-
docker exec -it pmm-server chown pmm:root /srv/nginx/*
71-
docker exec -it pmm-server chmod 644 /srv/nginx/*.crt /srv/nginx/*.pem
72-
docker exec -it pmm-server chmod 600 /srv/nginx/*.key
70+
docker exec --user root pmm-server sh -c 'chown 1000:0 /srv/nginx/*'
71+
docker exec --user root pmm-server sh -c 'chmod 644 /srv/nginx/*.crt /srv/nginx/*.pem'
72+
docker exec --user root pmm-server sh -c 'chmod 600 /srv/nginx/*.key'
7373
```
7474

7575
### Apply certificate changes
@@ -226,4 +226,4 @@ curl -v https://<server-hostname>/ping
226226

227227
# Test pmm-admin connection
228228
pmm-admin status
229-
```
229+
```

documentation/docs/install-pmm/HA-docker.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,17 @@ docker cp certificate.crt pmm-server:/srv/nginx/certificate.crt
200200
docker cp certificate.key pmm-server:/srv/nginx/certificate.key
201201
docker cp ca-certs.pem pmm-server:/srv/nginx/ca-certs.pem
202202

203+
# Set proper ownership and permissions
204+
docker exec --user root pmm-server sh -c 'chown 1000:0 /srv/nginx/*'
205+
docker exec --user root pmm-server sh -c 'chmod 644 /srv/nginx/*.crt /srv/nginx/*.pem'
206+
docker exec --user root pmm-server sh -c 'chmod 600 /srv/nginx/*.key'
207+
203208
# Restart nginx
204209
docker exec pmm-server supervisorctl restart nginx
205210
```
206211

212+
For the full list of required certificate files and configuration details, see [SSL encryption](../admin/security/ssl_encryption.md).
213+
207214
## Operations
208215

209216
### Connect monitoring clients

documentation/docs/install-pmm/install-pmm-server/deployment-options/aws/configure_aws.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ Replace the self-signed certificate with a proper SSL certificate for production
3535
systemctl --user stop pmm-server
3636

3737
# Configure PMM to use the certificate
38-
sudo cp /etc/letsencrypt/live/pmm.yourdomain.com/fullchain.pem /home/admin/volume/pmm-certs/certificate.crt
39-
sudo cp /etc/letsencrypt/live/pmm.yourdomain.com/privkey.pem /home/admin/volume/pmm-certs/certificate.key
40-
sudo chown pmm:pmm /home/admin/volume/pmm-certs/certificate.*
41-
sudo chmod 600 /home/admin/volume/pmm-certs/certificate.*
38+
sudo cp /etc/letsencrypt/live/pmm.yourdomain.com/fullchain.pem /home/admin/volume/srv/nginx/certificate.crt
39+
sudo cp /etc/letsencrypt/live/pmm.yourdomain.com/privkey.pem /home/admin/volume/srv/nginx/certificate.key
40+
sudo chown admin:admin /home/admin/volume/srv/nginx/certificate.*
41+
sudo chmod 600 /home/admin/volume/srv/nginx/certificate.*
4242

4343
# Restart PMM Server
4444
systemctl --user start pmm-server
@@ -56,10 +56,10 @@ Replace the self-signed certificate with a proper SSL certificate for production
5656

5757
2. Install certificates:
5858
```bash
59-
sudo mv /tmp/certificate.crt /home/admin/volume/pmm-certs/
60-
sudo mv /tmp/private.key /home/admin/volume/pmm-certs/certificate.key
61-
sudo chown pmm:pmm /home/admin/volume/pmm-certs/certificate.*
62-
sudo chmod 600 /home/admin/volume/pmm-certs/certificate.*
59+
sudo mv /tmp/certificate.crt /home/admin/volume/srv/nginx/
60+
sudo mv /tmp/private.key /home/admin/volume/srv/nginx/certificate.key
61+
sudo chown admin:admin /home/admin/volume/srv/nginx/certificate.*
62+
sudo chmod 600 /home/admin/volume/srv/nginx/certificate.*
6363
systemctl --user restart pmm-server
6464
```
6565

documentation/docs/install-pmm/install-pmm-server/deployment-options/docker/restore_container.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Choose the restoration method that matches how your backup was created:
7979

8080
4. Fix ownership of restored files:
8181
```sh
82-
docker run --rm -v pmm-data:/srv -t percona/pmm-server:3 chown -R pmm:pmm /srv
82+
docker run --rm --user root -v pmm-data:/srv -t percona/pmm-server:3 chown -R 1000:0 /srv
8383
```
8484

8585
5. Start the restored PMM Server:
@@ -162,7 +162,7 @@ Choose the restoration method that matches how your backup was created:
162162

163163
6. Fix ownership of the restored files:
164164
```sh
165-
docker run --rm -v pmm-data:/srv -t percona/pmm-server:3 chown -R pmm:pmm /srv
165+
docker run --rm --user root -v pmm-data:/srv -t percona/pmm-server:3 chown -R 1000:0 /srv
166166
```
167167

168168
7. Start the restored PMM Server container:

0 commit comments

Comments
 (0)