Skip to content

feat: allow users to disable ALTER SYSTEM - #3535

Merged
mnencia merged 4 commits into
cloudnative-pg:mainfrom
EnterpriseDB:dev/cnp-4392
Dec 13, 2023
Merged

mnencia merged 4 commits into
cloudnative-pg:mainfrom
EnterpriseDB:dev/cnp-4392

Conversation

@leonardoce

@leonardoce leonardoce commented Dec 12, 2023 •

Copy link
Copy Markdown
Contributor

Introduce the .spec.postgresql.enableAlterSystem to enable/disable the usage of the ALTER SYSTEM command for a PostgreSQL instance. Internally, the operator disables writes on the $PGDATA/postgresql.auto.conf file when .spec.postgresql.enableAlterSystem is set to false.

For back compatibility, the default is true.

Closes: #2725

@github-actions github-actions Bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.20 labels Dec 12, 2023
@github-actions

Copy link
Copy Markdown
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

@leonardoce

Copy link
Copy Markdown
Contributor Author

@gbartolini

Copy link
Copy Markdown
Contributor

I have tested it locally. By default this is the behaviour:

$ kubectl exec -ti pg1-1 -c postgres -- ls -la /var/lib/postgresql/data/pgdata/postgresql.auto.conf
-r-------- 1 postgres tape 88 Dec 13 01:55 /var/lib/postgresql/data/pgdata/postgresql.auto.conf

Then, once I add:

...
  postgresql:
    enableAlterSystem: true
...

I get this:

$ kubectl exec -ti pg1-1 -c postgres -- ls -la /var/lib/postgresql/data/pgdata/postgresql.auto.conf
-rw------- 1 postgres tape 88 Dec 13 01:55 /var/lib/postgresql/data/pgdata/postgresql.auto.conf

I manually changed the file permissions and noticed that with the next reconciliation loop they were restored.

With this patch we disable writes on the `$PGDATA/postgresql.auto.conf`
file, effectly preventing users from using ALTER SYSTEM.

The old behavior can still be requested by setting the
`.spec.postgresql.enableAlterSystem` field accordingly.

Signed-off-by: Leonardo Cecchi <[email protected]>
@leonardoce
leonardoce marked this pull request as ready for review December 13, 2023 10:11
@leonardoce

leonardoce commented Dec 13, 2023 •

Copy link
Copy Markdown
Contributor Author

I changed the patch to set enableAlterSystem to true by default. This PR is safe to backport now.
After that we can file a new PR to change the default to false without backporting it.

Signed-off-by: Gabriele Bartolini <[email protected]>
@mnencia

mnencia commented Dec 13, 2023

Copy link
Copy Markdown
Member

/ok-to-merge all E2E green, both with default off and on

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Dec 13, 2023
@mnencia
mnencia merged commit d96b3bb into cloudnative-pg:main Dec 13, 2023
@mnencia
mnencia deleted the dev/cnp-4392 branch December 13, 2023 17:07
cnpg-bot pushed a commit that referenced this pull request Dec 13, 2023
Introduce the `.spec.postgresql.enableAlterSystem` to enable/disable the
usage of the `ALTER SYSTEM` command for a PostgreSQL instance.
Internally, the operator disables writes on the
`$PGDATA/postgresql.auto.conf` file when
`.spec.postgresql.enableAlterSystem` is set to `false`.

For back compatibility, the default is `true`.

Closes: #2725

Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Co-authored-by: Gabriele Bartolini <[email protected]>
Co-authored-by: Marco Nenciarini <[email protected]>
(cherry picked from commit d96b3bb)
mnencia added a commit that referenced this pull request Dec 13, 2023
Introduce the `.spec.postgresql.enableAlterSystem` to enable/disable the
usage of the `ALTER SYSTEM` command for a PostgreSQL instance.
Internally, the operator disables writes on the
`$PGDATA/postgresql.auto.conf` file when
`.spec.postgresql.enableAlterSystem` is set to `false`.

For back compatibility, the default is `true`.

Closes: #2725

Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Marco Nenciarini <[email protected]>
Co-authored-by: Gabriele Bartolini <[email protected]>
Co-authored-by: Marco Nenciarini <[email protected]>
(cherry picked from commit d96b3bb)
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow users to disable ALTER SYSTEM

5 participants