Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use allow_alter_system on Postgres >=17 #4921

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

feat: use allow_alter_system on Postgres >=17 #4921

wants to merge 6 commits into from

Conversation

armru
Copy link
Member

@armru armru commented Jun 20, 2024

Closes #4244

@armru armru requested a review from a team as a code owner June 20, 2024 15:07
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.22 release-1.23 labels Jun 20, 2024
Copy link
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@armru armru added do not backport This PR must not be backported - it will be in the next minor release and removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.22 release-1.23 labels Jun 20, 2024
@armru armru force-pushed the dev/4244 branch 4 times, most recently from 0c3ab22 to 1e496db Compare June 20, 2024 15:40
@armru armru added backport-requested ◀️ This pull request should be backported to all supported releases release-1.22 release-1.23 and removed do not backport This PR must not be backported - it will be in the next minor release labels Jun 20, 2024
@armru armru changed the title feat: use allow_alter_system on Postgres 17+ feat: use allow_alter_system on Postgres >=17 Jun 21, 2024
@leonardoce leonardoce force-pushed the dev/4244 branch 2 times, most recently from 739d8e4 to fd5c24b Compare June 21, 2024 11:49
@leonardoce
Copy link
Contributor

@mnencia
Copy link
Member

mnencia commented Jun 24, 2024

/ok-to-merge E2E tests green

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Jun 24, 2024
leonardoce and others added 3 commits June 29, 2024 20:15
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
@gbartolini
Copy link
Contributor

Tested it with this cluster definition:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: clapton
spec:
  imageName: ghcr.io/cloudnative-pg/postgresql:17beta1-bookworm
  instances: 3
  postgresql:
    enableAlterSystem: false

then ran:

kubectl exec -ti clapton-1 -c postgres -- psql -c 'show allow_alter_system'
 allow_alter_system
--------------------
 off
(1 row)

And:

kubectl exec -ti clapton-1 -c postgres -- psql -c 'alter system set max_connections to 200;'
ERROR:  ALTER SYSTEM is not allowed in this environment

I then applied this:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: clapton
spec:
  imageName: ghcr.io/cloudnative-pg/postgresql:17beta1-bookworm
  instances: 3
  postgresql:
    enableAlterSystem: true

then ran:

kubectl exec -ti clapton-1 -c postgres -- psql -c 'show allow_alter_system'
 allow_alter_system
--------------------
 on
(1 row)

The log reported:

{
  "level": "info",
  "ts": "2024-06-29T18:18:24Z",
  "logger": "postgres",
  "msg": "record",
  "logging_pod": "clapton-1",
  "record": {
    "log_time": "2024-06-29 18:18:24.876 UTC",
    "process_id": "28",
    "session_id": "66804ec0.1c",
    "session_line_num": "14",
    "session_start_time": "2024-06-29 18:13:20 UTC",
    "transaction_id": "0",
    "error_severity": "LOG",
    "sql_state_code": "00000",
    "message": "parameter \"allow_alter_system\" changed to \"on\"",
    "backend_type": "postmaster",
    "query_id": "0"
  }
}

I then checked that the postgresql.auto.conf file is not read only:

kubectl exec -ti clapton-1 -c postgres -- bash

Then inside I ran:

postgres@clapton-1:~/data/pgdata$ ls -la $PGDATA/postgresql.auto.conf
-rw------- 1 postgres tape 88 Jun 29 18:13 /var/lib/postgresql/data/pgdata/postgresql.auto.conf

Version 17 works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-requested ◀️ This pull request should be backported to all supported releases ok to merge 👌 This PR can be merged release-1.22 release-1.23
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: support allow_alter_system from PostgreSQL 17
5 participants