-
Notifications
You must be signed in to change notification settings - Fork 80
K8SPG-786 K8SPG-1040 add upgrade test and fix operator behaviuor with extentions. #1734
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
Open
nmarukovich
wants to merge
31
commits into
main
Choose a base branch
from
K8SPG-786
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7bd10f9
K8SPG-786 add upgrade tests and fix K8SPG-1040
nmarukovich 50b7da0
update PR
nmarukovich efeb32f
fix
nmarukovich f70c061
fix
nmarukovich 1687fe1
fix
nmarukovich 4fa4db7
Merge branch 'main' of github.com:percona/percona-postgresql-operator…
nmarukovich 73f2ffc
fix conflicts
nmarukovich a681612
Merge branch 'main' into K8SPG-786
nmarukovich 66aa7ad
fix tests
nmarukovich 0a25673
Merge branch 'main' into K8SPG-786
nmarukovich 1d4d9f5
fix test
nmarukovich 19ddc1e
Merge branch 'K8SPG-786' of github.com:percona/percona-postgresql-ope…
nmarukovich 7405fca
Merge branch 'main' into K8SPG-786
nmarukovich 2b0ca7a
fix
nmarukovich b85d5dd
Merge branch 'main' into K8SPG-786
nmarukovich a9c8eee
PR comments fix
nmarukovich fab2d77
Merge branch 'K8SPG-786' of github.com:percona/percona-postgresql-ope…
nmarukovich 2f1e0fe
fix timeout for custom-extensions
nmarukovich 7067484
Merge branch 'main' into K8SPG-786
nmarukovich 71f7ec9
Merge branch 'main' into K8SPG-786
nmarukovich 78452a1
Merge branch 'main' into K8SPG-786
nmarukovich 4667032
Merge branch 'main' into K8SPG-786
nmarukovich 4fd0d5e
Merge branch 'main' into K8SPG-786
nmarukovich ffd39c0
Merge branch 'main' into K8SPG-786
nmarukovich d3dff41
Merge branch 'main' into K8SPG-786
nmarukovich 775a3a7
test fix
nmarukovich df01865
resolve conflict
nmarukovich 4f46592
Merge branch 'main' into K8SPG-786
nmarukovich 28ecf4c
fix tests
nmarukovich e88ca43
fix upgrade-minor
nmarukovich d0a4282
Merge branch 'main' into K8SPG-786
nmarukovich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,25 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| # adding pg_cron to the custom list and to shared_preload_libraries restarts | ||
| # every instance pod | ||
| timeout: 420 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: custom-extensions | ||
| status: | ||
| installedCustomExtensions: | ||
| - pg_stat_kcache | ||
| - pg_cron | ||
| pgbouncer: | ||
| ready: 3 | ||
| size: 3 | ||
| postgres: | ||
| instances: | ||
| - name: instance1 | ||
| ready: 3 | ||
| size: 3 | ||
| ready: 3 | ||
| size: 3 | ||
| state: ready |
This file contains hidden or 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,20 @@ | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: custom-extensions | ||
| spec: | ||
| # pg_cron is installed as a custom extension here so the next steps can move | ||
| # it to spec.extensions.pg_cron: it is the only extension that is both | ||
| # available as a custom archive and managed as a builtin one, and it owns | ||
| # data (the cron.job rows) that a wrong drop would destroy | ||
| extensions: | ||
| custom: | ||
| - name: pg_stat_kcache | ||
| version: 2.3.2 | ||
| - name: pg_cron | ||
| version: 1.6.7 | ||
| patroni: | ||
| dynamicConfiguration: | ||
| postgresql: | ||
| parameters: | ||
| shared_preload_libraries: pg_stat_statements,pg_stat_kcache,pg_cron |
This file contains hidden or 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,16 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| # pg_cron was added to shared_preload_libraries in the previous step and | ||
| # postgres only loads it on start, so the pods have to be restarted before | ||
| # the extension can be created | ||
| wait_cluster_consistency custom-extensions | ||
|
|
||
| restart_pg_pods custom-extensions instance1 | ||
| timeout: 360 |
This file contains hidden or 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,31 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| timeout: 120 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| uri="postgres:$(get_psql_user_pass custom-extensions-pguser-postgres)@$(get_psql_user_host custom-extensions-pguser-postgres)" | ||
|
|
||
| # cron.database_name only exists once the pg_cron library is loaded, so it | ||
| # tells us the restart of the previous step actually picked up the new | ||
| # shared_preload_libraries. CREATE EXTENSION fails without it. | ||
| for i in $(seq 1 30); do | ||
| if run_psql_local '\c postgres \\\ SHOW cron.database_name' "$uri" >/dev/null 2>&1; then | ||
| break | ||
| fi | ||
| sleep 5 | ||
| done | ||
| run_psql_local '\c postgres \\\ SHOW cron.database_name' "$uri" \ | ||
| || { echo "ERROR: pg_cron library is not loaded, shared_preload_libraries did not take effect"; exit 1; } | ||
|
|
||
| run_psql_local '\c postgres \\\ CREATE EXTENSION pg_cron' "$uri" | ||
|
|
||
| # a job in cron.job is the data a user loses if pg_cron gets dropped | ||
| run_psql_local '\c postgres \\\ SELECT cron.schedule($$migration-tick$$,$$* * * * *$$,$$SELECT 1$$)' "$uri" | ||
|
|
||
| jobs=$(run_psql_local '\c postgres \\\ SELECT count(*) FROM cron.job WHERE jobname = $$migration-tick$$' "$uri" | tr -d '[:space:]') | ||
| [[ "$jobs" == "1" ]] || { echo "ERROR: failed to schedule the pg_cron job"; exit 1; } |
This file contains hidden or 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,25 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| # removing pg_cron from the custom list changes INSTALL_EXTENSIONS and restarts | ||
| # every instance pod | ||
| timeout: 600 | ||
| --- | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: custom-extensions | ||
| status: | ||
| # pg_cron is gone from the custom list, it is managed as a builtin now | ||
| installedCustomExtensions: | ||
| - pg_stat_kcache | ||
| pgbouncer: | ||
| ready: 3 | ||
| size: 3 | ||
| postgres: | ||
| instances: | ||
| - name: instance1 | ||
| ready: 3 | ||
| size: 3 | ||
| ready: 3 | ||
| size: 3 | ||
| state: ready |
20 changes: 20 additions & 0 deletions
20
e2e-tests/tests/custom-extensions/20-migrate-to-builtin.yaml
This file contains hidden or 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,20 @@ | ||
| apiVersion: pgv2.percona.com/v2 | ||
| kind: PerconaPGCluster | ||
| metadata: | ||
| name: custom-extensions | ||
| spec: | ||
| # pg_cron moves from a custom extension to a builtin one: the operator takes | ||
| # over its lifecycle, but the extension and its data must survive the move. | ||
| # Dropping it here used to be the default behavior, because the extension | ||
| # disappears from the custom list. | ||
| extensions: | ||
| pg_cron: | ||
| enabled: true | ||
| custom: | ||
| - name: pg_stat_kcache | ||
| version: 2.3.2 | ||
| patroni: | ||
| dynamicConfiguration: | ||
| postgresql: | ||
| parameters: | ||
| shared_preload_libraries: pg_stat_statements,pg_stat_kcache,pg_cron |
This file contains hidden or 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,20 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestStep | ||
| timeout: 120 | ||
| commands: | ||
| - script: |- | ||
| set -o errexit | ||
| set -o xtrace | ||
|
|
||
| source ../../functions | ||
|
|
||
| uri="postgres:$(get_psql_user_pass custom-extensions-pguser-postgres)@$(get_psql_user_host custom-extensions-pguser-postgres)" | ||
|
|
||
| # moving an extension from spec.extensions.custom to a builtin flag must | ||
| # not drop it: the operator removes it from the custom list, but the | ||
| # builtin flag is enabled, so the extension and its data have to stay | ||
| installed=$(run_psql_local '\c postgres \\\ SELECT extname FROM pg_extension WHERE extname = $$pg_cron$$' "$uri" | tr -d '[:space:]') | ||
| [[ "$installed" == "pg_cron" ]] || { echo "ERROR: pg_cron was dropped by the custom to builtin migration"; exit 1; } | ||
|
|
||
| jobs=$(run_psql_local '\c postgres \\\ SELECT count(*) FROM cron.job WHERE jobname = $$migration-tick$$' "$uri" | tr -d '[:space:]') | ||
| [[ "$jobs" == "1" ]] || { echo "ERROR: cron.job data lost in the custom to builtin migration"; exit 1; } |
This file contains hidden or 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,8 @@ | ||
| apiVersion: kuttl.dev/v1beta1 | ||
| kind: TestAssert | ||
| metadata: | ||
| name: check-operator-and-minio | ||
| timeout: 180 | ||
| commands: | ||
| - script: kubectl assert exist-enhanced deployment percona-postgresql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1 | ||
| - script: kubectl assert exist-enhanced deployment minio-service -n ${NAMESPACE} --field-selector status.readyReplicas=1 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[shfmt] reported by reviewdog 🐶