forked from flyingcircusio/fc-nixos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fc-postgresql: support upgrades with custom extensions
FC-42163 Upgrading postgresql to a new major with fc-postgresql fails when using custom extensions, defined via `services.postgresql.extraPlugins`. This patch modifies the relevant agent code to use a postgresql package WITH all needed plugins for upgrades: * for automatic upgrades, these extensions are discovered automatically. * for manual upgrades, the user must specify those manually with `--extension-names`. The original use-case of a customer was to upgrade postgresql to a newer version with `postgresqlPackages.anonymizer` installed (FC-42089). This is a little trickier since it requires `anon` to be listed in `shared_preload_libraries`. For this, all `shared_preload_libraries` are now extracted from `postgresql.conf` and passed to `pg_upgrade` via CLI. This code is based on the assumption that the old `postgresql.conf` is generated by Nix and thus ignores all edge-cases, the postgresql config format may have.
- Loading branch information
Showing
10 changed files
with
393 additions
and
18 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
changelog.d/20241209_114200_mb_FC_42163_fc_postgresql_extension_support.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- | ||
A new changelog entry. | ||
Delete placeholder items that do not apply. Empty sections will be removed | ||
automatically during release. | ||
Leave the XX.XX as is: this is a placeholder and will be automatically filled | ||
correctly during the release and helps when backporting over multiple platform | ||
branches. | ||
--> | ||
|
||
### Impact | ||
|
||
- None. | ||
|
||
### NixOS XX.XX platform | ||
|
||
- The `fc-postgresql` command now supports upgrades of databases with preinstalled extensions: | ||
- When upgrading manually with `fc-postgresql`, add `--extension-names ext1 --extension-names ext2` to the command line. `ext1`/`ext2` must be the package names of the extensions without the `postgresqlPackages.`-prefix. Usually it's the packages in [`services.postgresql.extraPlugins`](https://search.flyingcircus.io/search/options?q=services.postgresql.extraPlugins&channel=fc-24.05-dev#services.postgresql.extraPlugins). | ||
- When using automatic upgrades ([`flyingcircus.services.postgresql.autoUpgrade.enable `](https://search.flyingcircus.io/search/options?q=+flyingcircus.services.postgresql.autoUpgrade.enable+&channel=fc-24.11-dev&page=1#flyingcircus.services.postgresql.autoUpgrade.enable)), existing extensions will be discovered automatically. You don't have to do anything in this case. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import json | ||
from typing import List | ||
from unittest.mock import Mock | ||
|
||
import fc.manage.postgresql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.