mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-02 21:30:46 +09:00
fix(postgres): run the collation repair outside the Helm hook (#5479)
## What this PR does
Refs #5459 (item 3: "Waiting for rollout eats Job budget").
**Depends on #5505.** Merge #5505 first or together with this PR. Here a
failed repair no longer fails the HelmRelease. #5505 makes the
WorkloadMonitor report the failed repair Job as `WorkloadsReady=False`
with reason `JobFailed`. Without it the failure shows only on the Job
itself.
Moving tenant PostgreSQL to another image (for example bullseye `17.7`
to `17.12-standard-trixie`) fails the first Helm upgrade of every
release whose clients keep sessions open. The collation repair at the
end of the post-upgrade init-job waits for CNPG to move the primary to
the new image. CNPG rolls the primary last, and every instance spends up
to `smartShutdownTimeout` (180 s) in smart shutdown, so the wait uses up
the init-job's 540 s deadline and the HelmRelease goes `UpgradeFailed`
until Flux retries. When the repair instead meets the primary restart,
psql fails with `FATAL: the database system is shutting down` and the
upgrade fails the same way.
The one commit moves the repair out of the hook. A short
post-install/post-upgrade hook, run after the init-job, creates a
`<release>-collation-repair` Job through the API (outside the release,
so helm-controller does not wait for it) and returns. That Job keeps the
OID mark / fingerprint resume and the in-place attempt records. It waits
for the new image whenever the image changes, not only when an index
already depends on a versioned collation: a plan built on the previous
primary would miss an index created meanwhile, which the release
recorded at the end would then claim as repaired. In the hook that wait
was too expensive to make unconditional. The Job gets an hour, is owned
by the Cluster, and its fixed name keeps two repairs from running at
once. It carries the WorkloadMonitor's selector labels plus the opt-in
`workloads.cozystack.io/report-failure: "true"` from #5505, and has no
`ttlSecondsAfterFinished`, so a failed repair stays until the next
upgrade replaces it (see the proposal in #5459). Both Jobs now rerun
their idempotent script on psql exit status 2 (connection refused or
dropped) with backoff instead of failing.
Decisions for reviewers:
- **Repair failures no longer fail the HelmRelease.** A repair that
cannot finish (for example duplicates under a UNIQUE index) shows up as
a Failed `<release>-collation-repair` Job and its log, kept until the
next upgrade starts a new run. The next upgrade retries it. Before, it
showed up as `UpgradeFailed`.
- **The repair also runs after install.** The install-time init-job used
to record which Debian release each database starts on. Without that
record, a cluster whose first upgrade moves the image would have its C.*
indexes rebuilt only if the repair reached the primary before it
restarted. On a fresh cluster the run only writes that record. The Job
sets `PGCONNECT_TIMEOUT=10`.
- **A failed rebuild no longer holds back the PostGIS update.** The
update runs after the collation pass whatever it found, and the Job
still fails at the end if a rebuild failed.
- **The e2e upgrades twice.** The second upgrade finds the first repair
Job complete on the same image, and the test waits for its replacement
to complete.
- **Lock waits are bounded by the Job's remaining hour, not about 8
minutes.** This is harmless for `REINDEX CONCURRENTLY`. For the in-place
rebuild of an exclusion-constraint index, writers to that table can
queue behind its lock wait for longer. Capping it separately means
touching the per-index code that the parallel PRs on #5459 also edit, so
I left it out.
- **The hook's Role** has `get`/`delete` on the repair Job and `get` on
the release's Cluster, both by `resourceNames`. It also has `create` on
jobs, which RBAC cannot narrow by name. The SA, Role and RoleBinding are
deleted once the hooks succeed.
- **Verified under Flux.** helm-controller v1.5.0 runs the post-upgrade
hooks about a second after it patches the Cluster, without waiting for
the rollout. The rollout therefore no longer counts against the release
timeout. Details in the PR thread.
Rebased onto main after #5477 and #5485. The PostGIS extension update
from #5477 waits for the same rollout, so it moves into `repair.sh`
after the collation pass; left in the init-job, it would bring the
hook-budget problem back for postgis clusters. Every message about a
repair or update that did not finish says that the next upgrade of the
release starts it again. The starter and the repair Job take their names
from one base, which stays distinct and within 63 characters for any
release name.
### Testing
- `helm unittest packages/apps/postgres`: 32 suites, 257 tests pass,
including a new `collation_repair_test.yaml`. It checks gating (upgrade
only, skipped while bootstrap is on), hook order after the init-job, the
Role rules, RBAC removal on success, name length, and the init-job
command.
- Docker, with the rendered `run.sh` + `repair.sh` against
`postgres:17-bullseye` and stale ICU / en_US collations:
- Killing the `REINDEX INDEX CONCURRENTLY` backend mid-rebuild made the
pass exit 2. `run.sh` reran it, the already rebuilt index was skipped by
the OID mark, and the other index was rebuilt. amcheck was clean and the
versions were refreshed.
- With the server stopped before the first connection, the script
retried with 5 s and 10 s pauses and finished once the server came back.
- An SQL error exits 1 and is not retried.
- dev7 (cozystack v1.7.0): two 3-instance v17 releases installed from
v1.7.1 (bullseye `17.7`), with ICU and en_US UNIQUE indexes on 200k rows
and `pg_sleep(3600)` sessions held on `-rw` and `-ro`. Both were
upgraded with `helm upgrade --timeout 10m`:
- origin/main: the init-job waited for `PostgreSQL 17.12 pgdg13`, hit
`DeadlineExceeded`, and the command failed with `UPGRADE FAILED:
post-upgrade hooks failed: resource Job/tenant-root/rr-main-init-job not
ready. status: Failed` (exit 1 after 611 s).
- This branch: exit 0 after 70 s (init-job 9 s, starter 10 s, starter
RBAC removed afterwards). The repair Job waited out the rollout and
rebuilt `t_u` and `t_k`. Collation versions were refreshed to `2.41` /
`153.128`, `bt_index_check(..., true)` passed on all three instances,
and the resume mark was reset.
- A second upgrade replaced the finished repair Job, and the rerun found
nothing to do.
- The rebuild sat in `waiting for old snapshots` behind the test
client's open transaction. That is expected for `REINDEX CONCURRENTLY`;
I ended that session to finish the run.
### Downstream repositories
Walked against the diff (the new template, test and init-script/init-job
changes in `packages/apps/postgres`). The diff changes no values,
schema, `ApplicationDefinition`, Secret or Service names, package
layout, or tooling. The only new objects are a hook-scoped
ServiceAccount/Role/RoleBinding/Job and a Job created at runtime, which
no listed repository refers to.
- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:
- Flux (dev cluster, helm-controller v1.5.0): a tenant app on the v1.7.0
chart (bullseye `17.7`, 3 instances, sessions held on `-rw`/`-ro`) was
upgraded by switching the platform's postgres chart.
- With this PR, the HelmRelease reached `UpgradeSucceeded` in 21 s, and
the repair Job finished after the rollout with `bt_index_check` clean on
all instances.
- With main, the upgrade took 7 min 06 s of the 10-minute timeout.
- Docker: the rendered `repair.sh` for the postgis flavor moved PostGIS
3.6.1 → 3.7.0 after the collation pass. A tenant trigger on
`spatial_ref_sys` did not run.
### Release note
```release-note
[postgres] An image change of a tenant PostgreSQL no longer fails the Helm upgrade while CNPG rolls the instances. The collation repair now runs in a separate `<release>-collation-repair` Job, started after each upgrade, which waits for the new image and retries after connection drops. Check that Job's status and log to confirm the repair finished.
```
release-1.6 has no postgis flavor, so the PostGIS extension update that
follows the collation pass in repair.sh on main is not carried over, and
repair.sh ends with the collation pass's own exit status; nothing in the
chart reads .Values.flavor. It has no adopted-restore record either, so
the step that writes one, which the split moved to the end of init.sh on
main, is not carried over. The init-job comment no longer describes the
collation pass, which left that Job here, and says what JOB_DEADLINE
bounds there now: the reruns of run.sh.
(cherry picked from commit c8ffc87717)
Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
This commit is contained in:
1 parent
3ae890ac4a
commit
4e6f5743e0
10 files changed
+553
-66
No files matched your search
@@ -40,7 +40,7 @@ type ConfigSpec struct {
|
|||||||
// PostgreSQL major version to deploy
|
// PostgreSQL major version to deploy
|
||||||
// +kubebuilder:default:="v18"
|
// +kubebuilder:default:="v18"
|
||||||
Version Version `json:"version"`
|
Version Version `json:"version"`
|
||||||
// Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The init Job rebuilds the indexes on such text, those on C.UTF-8 and other C.* locales included; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.
|
// Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The collation repair Job, which a post-upgrade hook starts once the init Job is done, rebuilds the indexes on such text after the rollout, those on C.UTF-8 and other C.* locales included, and its log reports a rebuild that failed; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.
|
||||||
// +kubebuilder:default:=false
|
// +kubebuilder:default:=false
|
||||||
AllowCollationChange bool `json:"allowCollationChange"`
|
AllowCollationChange bool `json:"allowCollationChange"`
|
||||||
// TLS configuration for server connections.
|
// TLS configuration for server connections.
|
||||||
|
|||||||
@@ -127,9 +127,9 @@ spec:
|
|||||||
# The Postgres CR itself was applied by chainsaw and is deleted (and waited
|
# The Postgres CR itself was applied by chainsaw and is deleted (and waited
|
||||||
# on) automatically during cleanup — no explicit teardown step needed.
|
# on) automatically during cleanup — no explicit teardown step needed.
|
||||||
|
|
||||||
# The init Job rebuilds an index whose collation changed library version.
|
# The collation repair Job rebuilds an index whose collation changed library
|
||||||
# The pass is SQL run by a Helm hook, so only a real server can say whether
|
# version. The pass is SQL run by a Job a Helm hook starts, so only a real
|
||||||
# it works. A collation created with an explicit version reads as stale
|
# server can say whether it works. A collation created with an explicit version reads as stale
|
||||||
# without swapping the operand image, and so does a C.<codeset> collation
|
# without swapping the operand image, and so does a C.<codeset> collation
|
||||||
# once the database records another Debian release as the one it was
|
# once the database records another Debian release as the one it was
|
||||||
# repaired for, which makes one more upgrade of the release enough to run
|
# repaired for, which makes one more upgrade of the release enough to run
|
||||||
@@ -170,6 +170,15 @@ spec:
|
|||||||
EOF
|
EOF
|
||||||
check:
|
check:
|
||||||
($error == null): true
|
($error == null): true
|
||||||
|
# A repair Job left by the install has completed already; it goes
|
||||||
|
# first, so that the Job awaited below is the one this upgrade starts.
|
||||||
|
- script:
|
||||||
|
timeout: 2m
|
||||||
|
content: |
|
||||||
|
set -eu
|
||||||
|
kubectl -n "$NAMESPACE" delete job postgres-test-collation-repair --ignore-not-found --wait=true
|
||||||
|
check:
|
||||||
|
($error == null): true
|
||||||
# A declared user is the smallest change that makes Helm upgrade the
|
# A declared user is the smallest change that makes Helm upgrade the
|
||||||
# release, and so run the hook, without restarting PostgreSQL.
|
# release, and so run the hook, without restarting PostgreSQL.
|
||||||
- patch:
|
- patch:
|
||||||
@@ -194,6 +203,58 @@ spec:
|
|||||||
status:
|
status:
|
||||||
(conditions[?type == 'Complete']):
|
(conditions[?type == 'Complete']):
|
||||||
- status: "True"
|
- status: "True"
|
||||||
|
# The repair runs in a Job a post-upgrade hook starts outside the
|
||||||
|
# release, after the init Job. The label is what makes the
|
||||||
|
# WorkloadMonitor report a failed repair on the Application.
|
||||||
|
- assert:
|
||||||
|
timeout: 15m
|
||||||
|
resource:
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: postgres-test-collation-repair
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: postgres.apps.cozystack.io
|
||||||
|
app.kubernetes.io/instance: postgres-test
|
||||||
|
workloads.cozystack.io/report-failure: "true"
|
||||||
|
status:
|
||||||
|
(conditions[?type == 'Complete']):
|
||||||
|
- status: "True"
|
||||||
|
# The next upgrade finds that Job complete on the same image and replaces
|
||||||
|
# it with a new run under the same name.
|
||||||
|
- script:
|
||||||
|
timeout: 1m
|
||||||
|
content: |
|
||||||
|
set -eu
|
||||||
|
# A failed repair must stay visible until the next upgrade replaces it.
|
||||||
|
ttl=$(kubectl -n "$NAMESPACE" get job postgres-test-collation-repair -o jsonpath='{.spec.ttlSecondsAfterFinished}')
|
||||||
|
if [ -n "$ttl" ]; then
|
||||||
|
echo "the collation repair Job has ttlSecondsAfterFinished=$ttl, so a failed repair would disappear" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
kubectl -n "$NAMESPACE" annotate job postgres-test-collation-repair e2e.cozystack.io/previous-run=true
|
||||||
|
check:
|
||||||
|
($error == null): true
|
||||||
|
- patch:
|
||||||
|
resource:
|
||||||
|
apiVersion: apps.cozystack.io/v1alpha1
|
||||||
|
kind: Postgres
|
||||||
|
metadata:
|
||||||
|
name: test
|
||||||
|
spec:
|
||||||
|
users:
|
||||||
|
collationprobe: {}
|
||||||
|
collationprobe2: {}
|
||||||
|
- script:
|
||||||
|
timeout: 15m
|
||||||
|
content: |
|
||||||
|
set -eu
|
||||||
|
until [ "$(kubectl -n "$NAMESPACE" get job postgres-test-collation-repair --ignore-not-found \
|
||||||
|
-o jsonpath='{.metadata.annotations.e2e\.cozystack\.io/previous-run}|{.status.conditions[?(@.type=="Complete")].status}')" = "|True" ]; do
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
check:
|
||||||
|
($error == null): true
|
||||||
- script:
|
- script:
|
||||||
timeout: 2m
|
timeout: 2m
|
||||||
content: |
|
content: |
|
||||||
@@ -207,14 +268,14 @@ spec:
|
|||||||
}
|
}
|
||||||
refreshed=$(q "SELECT collversion = pg_collation_actual_version(oid) FROM pg_collation WHERE collname = 'stale_icu'")
|
refreshed=$(q "SELECT collversion = pg_collation_actual_version(oid) FROM pg_collation WHERE collname = 'stale_icu'")
|
||||||
if [ "$refreshed" != t ]; then
|
if [ "$refreshed" != t ]; then
|
||||||
echo "the init Job left the collation version stale" >&2
|
echo "the collation repair Job left the collation version stale" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# REINDEX CONCURRENTLY gives the index a new OID, so an unchanged
|
# REINDEX CONCURRENTLY gives the index a new OID, so an unchanged
|
||||||
# one means the version was refreshed over an index nobody rebuilt.
|
# one means the version was refreshed over an index nobody rebuilt.
|
||||||
rebuilt=$(q "SELECT 'collation_probe_s'::regclass::oid <> index FROM collation_probe_before")
|
rebuilt=$(q "SELECT 'collation_probe_s'::regclass::oid <> index FROM collation_probe_before")
|
||||||
if [ "$rebuilt" != t ]; then
|
if [ "$rebuilt" != t ]; then
|
||||||
echo "the init Job refreshed the collation version without rebuilding the index" >&2
|
echo "the collation repair Job refreshed the collation version without rebuilding the index" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
q "CREATE EXTENSION IF NOT EXISTS amcheck"
|
q "CREATE EXTENSION IF NOT EXISTS amcheck"
|
||||||
@@ -223,18 +284,18 @@ spec:
|
|||||||
# OID and gets a new storage file.
|
# OID and gets a new storage file.
|
||||||
rebuilt_in_place=$(q "SELECT c.relfilenode <> b.in_place_file FROM pg_class c, collation_probe_before b WHERE c.oid = 'collation_probe_excl_s_excl'::regclass")
|
rebuilt_in_place=$(q "SELECT c.relfilenode <> b.in_place_file FROM pg_class c, collation_probe_before b WHERE c.oid = 'collation_probe_excl_s_excl'::regclass")
|
||||||
if [ "$rebuilt_in_place" != t ]; then
|
if [ "$rebuilt_in_place" != t ]; then
|
||||||
echo "the init Job did not rebuild the exclusion constraint's index" >&2
|
echo "the collation repair Job did not rebuild the exclusion constraint's index" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rebuilt_c=$(q "SELECT 'collation_probe_c_s_key'::regclass::oid <> c_index FROM collation_probe_before")
|
rebuilt_c=$(q "SELECT 'collation_probe_c_s_key'::regclass::oid <> c_index FROM collation_probe_before")
|
||||||
if [ "$rebuilt_c" != t ]; then
|
if [ "$rebuilt_c" != t ]; then
|
||||||
echo "the init Job did not rebuild the index on a C.<codeset> collation after the Debian release changed" >&2
|
echo "the collation repair Job did not rebuild the index on a C.<codeset> collation after the Debian release changed" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
q "SELECT bt_index_check('collation_probe_c_s_key', true)"
|
q "SELECT bt_index_check('collation_probe_c_s_key', true)"
|
||||||
release=$(q "SELECT current_setting('cozystack.collation_release', true) = substring(current_setting('server_version') from 'pgdg[0-9]+')")
|
release=$(q "SELECT current_setting('cozystack.collation_release', true) = substring(current_setting('server_version') from 'pgdg[0-9]+')")
|
||||||
if [ "$release" != t ]; then
|
if [ "$release" != t ]; then
|
||||||
echo "the init Job did not record the Debian release it repaired the database for" >&2
|
echo "the collation repair Job did not record the Debian release it repaired the database for" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
qu() {
|
qu() {
|
||||||
@@ -243,21 +304,21 @@ spec:
|
|||||||
}
|
}
|
||||||
rebuilt_unrecorded=$(qu "SELECT 'collation_probe_c_s_key'::regclass::oid <> c_index FROM collation_probe_before")
|
rebuilt_unrecorded=$(qu "SELECT 'collation_probe_c_s_key'::regclass::oid <> c_index FROM collation_probe_before")
|
||||||
if [ "$rebuilt_unrecorded" != t ]; then
|
if [ "$rebuilt_unrecorded" != t ]; then
|
||||||
echo "the init Job did not rebuild the index on a C.<codeset> collation in a database that recorded no release and holds a stale libc collation" >&2
|
echo "the collation repair Job did not rebuild the index on a C.<codeset> collation in a database that recorded no release and holds a stale libc collation" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
qu "CREATE EXTENSION IF NOT EXISTS amcheck"
|
qu "CREATE EXTENSION IF NOT EXISTS amcheck"
|
||||||
qu "SELECT bt_index_check('collation_probe_c_s_key', true)"
|
qu "SELECT bt_index_check('collation_probe_c_s_key', true)"
|
||||||
release=$(qu "SELECT current_setting('cozystack.collation_release', true) = substring(current_setting('server_version') from 'pgdg[0-9]+')")
|
release=$(qu "SELECT current_setting('cozystack.collation_release', true) = substring(current_setting('server_version') from 'pgdg[0-9]+')")
|
||||||
if [ "$release" != t ]; then
|
if [ "$release" != t ]; then
|
||||||
echo "the init Job did not record the Debian release it repaired the unrecorded database for" >&2
|
echo "the collation repair Job did not record the Debian release it repaired the unrecorded database for" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
# The pass keeps its progress in a setting of the database and
|
# The pass keeps its progress in a setting of the database and
|
||||||
# removes it once nothing is left to repair.
|
# removes it once nothing is left to repair.
|
||||||
progress=$(q "SELECT count(*) FROM pg_db_role_setting s JOIN pg_database d ON d.oid = s.setdatabase, unnest(s.setconfig) AS c WHERE d.datname = current_database() AND c LIKE 'cozystack.collation_repair=%'")
|
progress=$(q "SELECT count(*) FROM pg_db_role_setting s JOIN pg_database d ON d.oid = s.setdatabase, unnest(s.setconfig) AS c WHERE d.datname = current_database() AND c LIKE 'cozystack.collation_repair=%'")
|
||||||
if [ "$progress" != 0 ]; then
|
if [ "$progress" != 0 ]; then
|
||||||
echo "the init Job left its repair setting on a database it finished repairing" >&2
|
echo "the collation repair Job left its repair setting on a database it finished repairing" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
leftovers=$(q "SELECT count(*) FROM pg_index WHERE NOT indisvalid")
|
leftovers=$(q "SELECT count(*) FROM pg_index WHERE NOT indisvalid")
|
||||||
@@ -284,6 +345,11 @@ spec:
|
|||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
name: postgres-test-init-job
|
name: postgres-test-init-job
|
||||||
|
- delete:
|
||||||
|
ref:
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
name: postgres-test-collation-repair
|
||||||
---
|
---
|
||||||
# Full barman-cloud backup -> to-copy RestoreJob round-trip, driving the
|
# Full barman-cloud backup -> to-copy RestoreJob round-trip, driving the
|
||||||
# validated example scripts (examples/backups/postgres) as the harness so the
|
# validated example scripts (examples/backups/postgres) as the harness so the
|
||||||
|
|||||||
@@ -195,18 +195,18 @@ For `sslmode=verify-full` to work, the CA bundle retrieved above must be saved t
|
|||||||
|
|
||||||
### Common parameters
|
### Common parameters
|
||||||
|
|
||||||
| Name | Description | Type | Value |
|
| Name | Description | Type | Value |
|
||||||
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------- |
|
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ---------- |
|
||||||
| `replicas` | Number of Postgres replicas. | `int` | `2` |
|
| `replicas` | Number of Postgres replicas. | `int` | `2` |
|
||||||
| `resources` | Explicit CPU and memory configuration for each PostgreSQL replica. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` |
|
| `resources` | Explicit CPU and memory configuration for each PostgreSQL replica. When omitted, the preset defined in `resourcesPreset` is applied. | `object` | `{}` |
|
||||||
| `resources.cpu` | CPU available to each replica. | `quantity` | `""` |
|
| `resources.cpu` | CPU available to each replica. | `quantity` | `""` |
|
||||||
| `resources.memory` | Memory (RAM) available to each replica. | `quantity` | `""` |
|
| `resources.memory` | Memory (RAM) available to each replica. | `quantity` | `""` |
|
||||||
| `resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.micro` |
|
| `resourcesPreset` | Default sizing preset used when `resources` is omitted. | `string` | `t1.micro` |
|
||||||
| `size` | Persistent Volume Claim size available for application data. | `quantity` | `10Gi` |
|
| `size` | Persistent Volume Claim size available for application data. | `quantity` | `10Gi` |
|
||||||
| `storageClass` | StorageClass used to store the data. | `string` | `""` |
|
| `storageClass` | StorageClass used to store the data. | `string` | `""` |
|
||||||
| `external` | Enable external access from outside the cluster. | `bool` | `false` |
|
| `external` | Enable external access from outside the cluster. | `bool` | `false` |
|
||||||
| `version` | PostgreSQL major version to deploy | `string` | `v18` |
|
| `version` | PostgreSQL major version to deploy | `string` | `v18` |
|
||||||
| `allowCollationChange` | Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The init Job rebuilds the indexes on such text, those on C.UTF-8 and other C.* locales included; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade. | `bool` | `false` |
|
| `allowCollationChange` | Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The collation repair Job, which a post-upgrade hook starts once the init Job is done, rebuilds the indexes on such text after the rollout, those on C.UTF-8 and other C.* locales included, and its log reports a rebuild that failed; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade. | `bool` | `false` |
|
||||||
|
|
||||||
|
|
||||||
### TLS configuration
|
### TLS configuration
|
||||||
|
|||||||
@@ -0,0 +1,223 @@
|
|||||||
|
{{- /*
|
||||||
|
The collation repair (repair.sh in the init-script Secret) must not run as
|
||||||
|
a Helm hook: it waits for CNPG to move the primary to the new image and then
|
||||||
|
rebuilds indexes, and both take as long as the data and the clients make
|
||||||
|
them. Nor can it be an ordinary manifest: helm-controller waits for every
|
||||||
|
Job of a release to complete within the same upgrade timeout. So this hook
|
||||||
|
creates it through the API, outside the release, and returns.
|
||||||
|
|
||||||
|
The repair Job has one fixed name, so no two of them run against the
|
||||||
|
Cluster at once. One still running on the image this release renders,
|
||||||
|
and not being deleted, is left to finish; any other is deleted, and its pod is gone, before the new
|
||||||
|
one is created, which also retries a repair that failed. It is owned by
|
||||||
|
the Cluster, so it goes with it. The hook's Role reaches only those two
|
||||||
|
objects by name, except for create, which RBAC cannot narrow to a name,
|
||||||
|
and is removed again once the hooks succeed. Skipped with the init-job
|
||||||
|
while bootstrap is on: the repair runs from its Secret, and the init-job
|
||||||
|
must have converged the release first. It runs on install too, where it
|
||||||
|
only records the Debian release each database starts on: a later image
|
||||||
|
move is told apart by that record, and the repair of that move may start
|
||||||
|
only after the primary has moved.
|
||||||
|
*/}}
|
||||||
|
{{- if not .Values.bootstrap.enabled }}
|
||||||
|
{{- /* One base for both names, short enough for the longer suffix: cut
|
||||||
|
separately, a long release name would give both the same name, and
|
||||||
|
the starter would take its own Job for a previous repair. */}}
|
||||||
|
{{- $base := .Release.Name }}
|
||||||
|
{{- if gt (len $base) 40 }}
|
||||||
|
{{- $base = printf "%s-%s" ($base | trunc 31 | trimSuffix "-") ($base | sha256sum | trunc 8) }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $name := printf "%s-collation-repair" $base }}
|
||||||
|
{{- $starter := printf "%s-collation-repair-start" $base }}
|
||||||
|
{{- /*
|
||||||
|
The repair keeps what is left of an hour for rebuilding once the primary
|
||||||
|
runs the new image, and it bounds its lock waits by the same clock, so a
|
||||||
|
longer deadline is not free: an index rebuilt in place waits for its lock
|
||||||
|
in the queue that writes to its table join.
|
||||||
|
*/}}
|
||||||
|
{{- $deadline := 3600 }}
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: {{ $starter }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: post-install,post-upgrade
|
||||||
|
helm.sh/hook-weight: "0"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: {{ $starter }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: post-install,post-upgrade
|
||||||
|
helm.sh/hook-weight: "0"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["batch"]
|
||||||
|
resources: ["jobs"]
|
||||||
|
resourceNames: [{{ $name | quote }}]
|
||||||
|
verbs: ["get", "delete"]
|
||||||
|
- apiGroups: ["batch"]
|
||||||
|
resources: ["jobs"]
|
||||||
|
verbs: ["create"]
|
||||||
|
- apiGroups: ["postgresql.cnpg.io"]
|
||||||
|
resources: ["clusters"]
|
||||||
|
resourceNames: [{{ .Release.Name | quote }}]
|
||||||
|
verbs: ["get"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ $starter }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: post-install,post-upgrade
|
||||||
|
helm.sh/hook-weight: "0"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation,hook-succeeded
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: {{ $starter }}
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ $starter }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: {{ $starter }}
|
||||||
|
annotations:
|
||||||
|
helm.sh/hook: post-install,post-upgrade
|
||||||
|
helm.sh/hook-weight: "1"
|
||||||
|
helm.sh/hook-delete-policy: before-hook-creation
|
||||||
|
spec:
|
||||||
|
activeDeadlineSeconds: 180
|
||||||
|
backoffLimit: 0
|
||||||
|
ttlSecondsAfterFinished: 3600
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
policy.cozystack.io/allow-to-apiserver: "true"
|
||||||
|
spec:
|
||||||
|
serviceAccountName: {{ $starter }}
|
||||||
|
restartPolicy: Never
|
||||||
|
securityContext:
|
||||||
|
runAsGroup: 26
|
||||||
|
runAsNonRoot: true
|
||||||
|
runAsUser: 26
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
|
containers:
|
||||||
|
- name: kubectl
|
||||||
|
image: {{ include "cozy-lib.image" (list "clastix/kubectl:v1.32@sha256:b9ef7d8dbe65bcc81a46c09b8dc7543103055021c4f43287bf59e92a8f4fe05c" $) }}
|
||||||
|
command: [sh, -ec]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
name={{ $name | quote }}
|
||||||
|
image={{ include "postgres.imageName" $ | quote }}
|
||||||
|
|
||||||
|
state=$(kubectl get job "$name" --ignore-not-found -o jsonpath='{.spec.template.spec.containers[0].image}|{.status.conditions[?(@.status=="True")].type}|{.metadata.deletionTimestamp}')
|
||||||
|
if [ "$state" = "$image||" ]; then
|
||||||
|
echo "the collation repair for $image is still running; leaving it to finish"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [ -n "$state" ]; then
|
||||||
|
echo "replacing the previous collation repair ($state)"
|
||||||
|
kubectl delete job "$name" --cascade=foreground --wait=false
|
||||||
|
echo "waiting for the pod of the previous collation repair to terminate; one on an unreachable node keeps it, and fails this upgrade, until the node is back or the pod is force-deleted"
|
||||||
|
until left=$(kubectl get job "$name" --ignore-not-found -o name) && [ -z "$left" ]; do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
uid=$(kubectl get clusters.postgresql.cnpg.io {{ .Release.Name | quote }} -o jsonpath='{.metadata.uid}')
|
||||||
|
kubectl create -f - <<MANIFEST
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: ${name}
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: postgres.apps.cozystack.io
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
workloads.cozystack.io/report-failure: "true"
|
||||||
|
ownerReferences:
|
||||||
|
- apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
uid: ${uid}
|
||||||
|
spec:
|
||||||
|
activeDeadlineSeconds: {{ $deadline }}
|
||||||
|
backoffLimit: 0
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
restartPolicy: Never
|
||||||
|
automountServiceAccountToken: false
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: ${image}
|
||||||
|
command: [bash, /scripts/run.sh, /scripts/repair.sh]
|
||||||
|
env:
|
||||||
|
- name: PGUSER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ .Release.Name }}-superuser
|
||||||
|
key: username
|
||||||
|
- name: PGPASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ .Release.Name }}-superuser
|
||||||
|
key: password
|
||||||
|
- name: PGHOST
|
||||||
|
value: {{ .Release.Name }}-rw
|
||||||
|
- name: PGPORT
|
||||||
|
value: "5432"
|
||||||
|
- name: PGDATABASE
|
||||||
|
value: postgres
|
||||||
|
- name: PGCONNECT_TIMEOUT
|
||||||
|
value: "10"
|
||||||
|
- name: JOB_DEADLINE
|
||||||
|
value: "{{ $deadline }}"
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
capabilities:
|
||||||
|
drop:
|
||||||
|
- ALL
|
||||||
|
privileged: false
|
||||||
|
readOnlyRootFilesystem: true
|
||||||
|
runAsNonRoot: true
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /scripts
|
||||||
|
name: scripts
|
||||||
|
{{- include "postgresjobs.resources" . | nindent 18 }}
|
||||||
|
securityContext:
|
||||||
|
fsGroup: 26
|
||||||
|
runAsGroup: 26
|
||||||
|
runAsNonRoot: true
|
||||||
|
runAsUser: 26
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
|
volumes:
|
||||||
|
- name: scripts
|
||||||
|
secret:
|
||||||
|
secretName: {{ .Release.Name }}-init-script
|
||||||
|
MANIFEST
|
||||||
|
env:
|
||||||
|
- name: HOME
|
||||||
|
value: /work
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
capabilities:
|
||||||
|
drop:
|
||||||
|
- ALL
|
||||||
|
readOnlyRootFilesystem: true
|
||||||
|
runAsNonRoot: true
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /work
|
||||||
|
name: work
|
||||||
|
{{- include "postgresjobs.resources" . | nindent 8 }}
|
||||||
|
volumes:
|
||||||
|
- name: work
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
@@ -23,16 +23,15 @@ spec:
|
|||||||
{{- /*
|
{{- /*
|
||||||
This Job is a post-install,post-upgrade Helm hook Helm blocks on. Bound it under
|
This Job is a post-install,post-upgrade Helm hook Helm blocks on. Bound it under
|
||||||
the 10m hook budget so its own DeadlineExceeded surfaces first, instead of Helm's
|
the 10m hook budget so its own DeadlineExceeded surfaces first, instead of Helm's
|
||||||
generic 10m timeout that says nothing about why. The script reads the value back
|
generic 10m timeout that says nothing about why. On UPGRADE the Cluster is already
|
||||||
as JOB_DEADLINE and bounds its collation-rebuild waits by what is left of it.
|
up and the readiness loop answers in seconds, so 540s leaves the grant pass ~9m.
|
||||||
On UPGRADE the Cluster is already up and the readiness loop answers in seconds,
|
On INSTALL the same release is still provisioning the Cluster (PVC, image pull,
|
||||||
so 540s leaves the grant and rebuild passes ~9m. On INSTALL the same release is
|
initdb) and Helm's wait does not cover a CR, so the cold start gets 570s. run.sh
|
||||||
still provisioning the Cluster (PVC, image pull, initdb) and Helm's wait does not
|
reads the value back as JOB_DEADLINE and stops rerunning the script after a lost
|
||||||
cover a CR, so the cold start gets 570s. Do not retry the pod either way: the
|
connection a minute before it. The collation repair runs in a Job of its own, see
|
||||||
collation pass bounds lock_timeout and the in-place statement_timeout by
|
collation-repair.yaml. Do not retry the pod either way: run.sh already reruns the
|
||||||
JOB_DEADLINE minus $SECONDS, and $SECONDS counts from the pod's start while
|
script after a lost connection, and a retried pod would start its $SECONDS from
|
||||||
activeDeadlineSeconds counts from the Job's. A retried pod would hand the server
|
zero against a deadline that counts from the Job's start.
|
||||||
a bound longer than the Job has left, so a rebuild or lock wait would outlive it.
|
|
||||||
*/}}
|
*/}}
|
||||||
{{- $deadline := ternary 570 540 .Release.IsInstall }}
|
{{- $deadline := ternary 570 540 .Release.IsInstall }}
|
||||||
activeDeadlineSeconds: {{ $deadline }}
|
activeDeadlineSeconds: {{ $deadline }}
|
||||||
@@ -50,6 +49,7 @@ spec:
|
|||||||
image: {{ include "postgres.imageName" $ }}
|
image: {{ include "postgres.imageName" $ }}
|
||||||
command:
|
command:
|
||||||
- bash
|
- bash
|
||||||
|
- /scripts/run.sh
|
||||||
- /scripts/init.sh
|
- /scripts/init.sh
|
||||||
env:
|
env:
|
||||||
- name: PGUSER
|
- name: PGUSER
|
||||||
|
|||||||
@@ -38,6 +38,28 @@ kind: Secret
|
|||||||
metadata:
|
metadata:
|
||||||
name: {{ .Release.Name }}-init-script
|
name: {{ .Release.Name }}-init-script
|
||||||
stringData:
|
stringData:
|
||||||
|
run.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
{{- /*
|
||||||
|
Both Jobs reach the server through the -rw Service while CNPG may be
|
||||||
|
restarting the instance behind it. psql exits with status 2 both when the
|
||||||
|
server refuses the connection ("the database system is shutting down")
|
||||||
|
and when it drops one mid-session, and each script is safe to run again
|
||||||
|
from the top, so that status reruns the script after a growing pause
|
||||||
|
instead of failing the Job; any other status is final. The child is
|
||||||
|
handed $SECONDS, which bash keeps counting from, so every bound a script
|
||||||
|
measures against it still counts from the first attempt.
|
||||||
|
*/}}
|
||||||
|
delay=5
|
||||||
|
until SECONDS=$SECONDS bash "$1"; do
|
||||||
|
status=$?
|
||||||
|
if [ "$status" -ne 2 ] || [ $((SECONDS + delay)) -ge $((JOB_DEADLINE - 60)) ]; then
|
||||||
|
exit "$status"
|
||||||
|
fi
|
||||||
|
echo "lost the connection to the server; running $1 again in ${delay}s" >&2
|
||||||
|
sleep "$delay"
|
||||||
|
delay=$((delay * 2 > 60 ? 60 : delay * 2))
|
||||||
|
done
|
||||||
init.sh: |
|
init.sh: |
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
@@ -229,6 +251,9 @@ stringData:
|
|||||||
EOT
|
EOT
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
repair.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
{{- /*
|
{{- /*
|
||||||
An operand image built on another Debian release ships another glibc and
|
An operand image built on another Debian release ships another glibc and
|
||||||
ICU, and an index ordered by a collation of either library is then
|
ICU, and an index ordered by a collation of either library is then
|
||||||
@@ -247,20 +272,27 @@ stringData:
|
|||||||
not need it, and still misses a collation that an expression applies to
|
not need it, and still misses a collation that an expression applies to
|
||||||
a column of another one.
|
a column of another one.
|
||||||
|
|
||||||
This pass comes after the ones that manage roles and databases, so
|
This pass runs in a Job of its own, which a post-upgrade hook starts
|
||||||
that a rebuild that fails, or does not finish before the Job deadline,
|
once the init-job has managed roles and databases, and which Helm does
|
||||||
costs none of them.
|
not wait for. The hook runs as soon as the Cluster is patched, while
|
||||||
|
CNPG is still rolling the instances, the primary last, and an instance
|
||||||
|
whose clients keep their sessions open waits out smartShutdownTimeout
|
||||||
|
before it restarts: the rollout alone can take longer than Helm gives a
|
||||||
|
hook, and the rebuild of a large index as long again, so inside the
|
||||||
|
hook either one failed the upgrade. Here a rebuild that fails costs
|
||||||
|
nothing else, and the next upgrade starts the Job again.
|
||||||
|
|
||||||
Helm runs this hook as soon as the Cluster is patched, while CNPG is
|
The primary may therefore answer from the previous image for minutes.
|
||||||
still rolling the instances, so the primary may answer from the previous
|
The Job runs the image the Cluster is moving to, so
|
||||||
image for minutes. The Job runs the image the Cluster is moving to, so
|
|
||||||
the server is on it once both report the same PostgreSQL version and
|
the server is on it once both report the same PostgreSQL version and
|
||||||
the same Debian release. The rebuild counter that follows them is left
|
the same Debian release. The rebuild counter that follows them is left
|
||||||
out: a tag is rebuilt in place, so the Job and an instance can run
|
out: a tag is rebuilt in place, so the Job and an instance can run
|
||||||
different rebuilds of one release for good. Waiting is only worth its
|
different rebuilds of one release for good. The pass waits for that
|
||||||
time when an index depends on a versioned collation. The wait ends 120
|
whenever the image changes, even when no index depends on a collation
|
||||||
seconds before the Job's deadline, which is what a first run keeps for
|
yet: a plan made on the previous image misses an index created in the
|
||||||
rebuilding.
|
meantime, which the release recorded at the end would then claim as
|
||||||
|
repaired. The wait ends 120 seconds before the Job's deadline, which is
|
||||||
|
what a first run keeps for rebuilding.
|
||||||
|
|
||||||
Rebuilds survive a retry: REINDEX CONCURRENTLY gives the index a new
|
Rebuilds survive a retry: REINDEX CONCURRENTLY gives the index a new
|
||||||
OID, so the highest OID seen when the repair began separates the
|
OID, so the highest OID seen when the repair began separates the
|
||||||
@@ -303,9 +335,9 @@ stringData:
|
|||||||
failed there: the pass then leaves the table's stale indexes alone
|
failed there: the pass then leaves the table's stale indexes alone
|
||||||
until an operator has dropped the leftovers. A rebuild that succeeds
|
until an operator has dropped the leftovers. A rebuild that succeeds
|
||||||
drops them itself. A failed or
|
drops them itself. A failed or
|
||||||
skipped rebuild does not stop the others: the pass reports them and
|
skipped rebuild does not stop the others: the pass reports them, and
|
||||||
exits non-zero at the end, with the recorded versions of that database
|
the Job exits non-zero at its end, with the recorded versions of that
|
||||||
left as they are.
|
database left as they are.
|
||||||
|
|
||||||
A collation that a range partition key depends on is never refreshed:
|
A collation that a range partition key depends on is never refreshed:
|
||||||
rebuilding an index does not move a row to the partition the new
|
rebuilding an index does not move a row to the partition the new
|
||||||
@@ -423,24 +455,18 @@ stringData:
|
|||||||
COLLATION_DBS=$(psql -v ON_ERROR_STOP=1 -t -A -c "SELECT datname FROM pg_database WHERE datallowconn AND NOT datistemplate")
|
COLLATION_DBS=$(psql -v ON_ERROR_STOP=1 -t -A -c "SELECT datname FROM pg_database WHERE datallowconn AND NOT datistemplate")
|
||||||
if [ "$(server_release)" != "$JOB_RELEASE" ]; then
|
if [ "$(server_release)" != "$JOB_RELEASE" ]; then
|
||||||
IMAGE_MOVED=true
|
IMAGE_MOVED=true
|
||||||
DEPENDENT=""
|
|
||||||
for db in $COLLATION_DBS; do
|
for db in $COLLATION_DBS; do
|
||||||
DEPENDENT="$DEPENDENT$(collation_run "$db" <<\EOT
|
collation_run "$db" </dev/null >/dev/null
|
||||||
SELECT index FROM cozystack_collation_index;
|
|
||||||
EOT
|
|
||||||
)"
|
|
||||||
done
|
done
|
||||||
if [ -n "$DEPENDENT" ]; then
|
echo "waiting for the server to run PostgreSQL $JOB_RELEASE"
|
||||||
echo "indexes depend on a versioned collation; waiting for the server to run PostgreSQL $JOB_RELEASE"
|
|
||||||
until [ "$(server_release)" = "$JOB_RELEASE" ]; do
|
until [ "$(server_release)" = "$JOB_RELEASE" ]; do
|
||||||
if [ "$SECONDS" -ge $((JOB_DEADLINE - 120)) ]; then
|
if [ "$SECONDS" -ge $((JOB_DEADLINE - 120)) ]; then
|
||||||
echo "the server did not move to PostgreSQL $JOB_RELEASE in time (check the rollout of the cnpg.io/Cluster); indexes that depend on a versioned collation are not rebuilt yet - failing the init-job, the next run of it rebuilds them" >&2
|
echo "the server did not move to PostgreSQL $JOB_RELEASE in time (check the rollout of the cnpg.io/Cluster); no index is rebuilt yet - failing the collation repair Job, the next upgrade of the release starts it again" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
COLLATION_FAILED=""
|
COLLATION_FAILED=""
|
||||||
for db in $COLLATION_DBS; do
|
for db in $COLLATION_DBS; do
|
||||||
PLAN=$(collation_run "$db" <<\EOT
|
PLAN=$(collation_run "$db" <<\EOT
|
||||||
@@ -460,7 +486,7 @@ stringData:
|
|||||||
for index in $PLAN; do
|
for index in $PLAN; do
|
||||||
LEFT=$((JOB_DEADLINE - SECONDS - 60))
|
LEFT=$((JOB_DEADLINE - SECONDS - 60))
|
||||||
if [ "$LEFT" -lt 10 ]; then
|
if [ "$LEFT" -lt 10 ]; then
|
||||||
echo "index $index in database $db was not rebuilt: the init-job is out of time, the next run of it carries on" >&2
|
echo "index $index in database $db was not rebuilt: the collation repair Job is out of time, the next upgrade of the release starts it again" >&2
|
||||||
DB_FAILED=yes
|
DB_FAILED=yes
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -470,7 +496,7 @@ stringData:
|
|||||||
SET lock_timeout = :'lock_wait';
|
SET lock_timeout = :'lock_wait';
|
||||||
SELECT EXISTS (SELECT FROM pg_index i JOIN pg_stat_progress_create_index p ON p.relid = i.indrelid JOIN pg_database d ON d.oid = p.datid WHERE i.indexrelid = :'index'::oid AND d.datname = current_database() AND p.pid <> pg_backend_pid()) AS building \gset
|
SELECT EXISTS (SELECT FROM pg_index i JOIN pg_stat_progress_create_index p ON p.relid = i.indrelid JOIN pg_database d ON d.oid = p.datid WHERE i.indexrelid = :'index'::oid AND d.datname = current_database() AND p.pid <> pg_backend_pid()) AS building \gset
|
||||||
\if :building
|
\if :building
|
||||||
SELECT format('DO %L', format('BEGIN RAISE EXCEPTION %L, %L; END', '%', format('index %s in database %s was skipped: another session is building an index of its table, as a rebuild left by an earlier run of the init-job does; the next run of the init-job carries on', :'index'::oid::regclass, current_database()))) \gexec
|
SELECT format('DO %L', format('BEGIN RAISE EXCEPTION %L, %L; END', '%', format('index %s in database %s was skipped: another session is building an index of its table, as a rebuild left by an earlier repair does; the next upgrade of the release starts the repair again', :'index'::oid::regclass, current_database()))) \gexec
|
||||||
\endif
|
\endif
|
||||||
SELECT count(*) = 1 AS present FROM pg_index WHERE indexrelid = :'index'::oid \gset
|
SELECT count(*) = 1 AS present FROM pg_index WHERE indexrelid = :'index'::oid \gset
|
||||||
\if :present
|
\if :present
|
||||||
@@ -480,11 +506,11 @@ stringData:
|
|||||||
(SELECT count(*) FROM unnest(string_to_array(split_part(:'recorded', ':', 3), ',')) AS e WHERE e = :'index' || '/' || r.relfilenode) >= 2 AS abandoned_in_place
|
(SELECT count(*) FROM unnest(string_to_array(split_part(:'recorded', ':', 3), ',')) AS e WHERE e = :'index' || '/' || r.relfilenode) >= 2 AS abandoned_in_place
|
||||||
FROM pg_index i JOIN pg_class r ON r.oid = i.indexrelid WHERE i.indexrelid = :'index'::oid \gset
|
FROM pg_index i JOIN pg_class r ON r.oid = i.indexrelid WHERE i.indexrelid = :'index'::oid \gset
|
||||||
\if :abandoned
|
\if :abandoned
|
||||||
SELECT format('DO %L', format('BEGIN RAISE EXCEPTION %L, %L; END', '%', format('index %s in database %s was left alone: two earlier runs failed to rebuild an index of its table, and each left an invalid _ccnew index there. Fix what made them fail, then drop those _ccnew indexes; the next run of the init-job rebuilds this one', :'name', current_database()))) \gexec
|
SELECT format('DO %L', format('BEGIN RAISE EXCEPTION %L, %L; END', '%', format('index %s in database %s was left alone: two earlier runs failed to rebuild an index of its table, and each left an invalid _ccnew index there. Fix what made them fail, then drop those _ccnew indexes; the repair started by the next upgrade of the release rebuilds this one', :'name', current_database()))) \gexec
|
||||||
\endif
|
\endif
|
||||||
\if :exclusion
|
\if :exclusion
|
||||||
\if :abandoned_in_place
|
\if :abandoned_in_place
|
||||||
SELECT format('DO %L', format('BEGIN RAISE EXCEPTION %L, %L; END', '%', format('index %s in database %s was left alone: two earlier runs began rebuilding it in place and did not finish. Rebuild it by hand with REINDEX INDEX, which blocks its table meanwhile; the next run of the init-job sees that it was rebuilt', :'name', current_database()))) \gexec
|
SELECT format('DO %L', format('BEGIN RAISE EXCEPTION %L, %L; END', '%', format('index %s in database %s was left alone: two earlier runs began rebuilding it in place and did not finish. Rebuild it by hand with REINDEX INDEX, which blocks its table meanwhile; the repair started by the next upgrade of the release sees that it was rebuilt', :'name', current_database()))) \gexec
|
||||||
\endif
|
\endif
|
||||||
SELECT format('rebuilding index %s in database %s in place: its collation changed version', :'name', current_database());
|
SELECT format('rebuilding index %s in database %s in place: its collation changed version', :'name', current_database());
|
||||||
SELECT format('ALTER DATABASE %I SET cozystack.collation_repair = %L', current_database(), split_part(:'recorded', ':', 1) || ':' || split_part(:'recorded', ':', 2) || ':' || concat_ws(',', nullif(split_part(:'recorded', ':', 3), ''), :'attempt')) WHERE :'recorded' <> '' \gexec
|
SELECT format('ALTER DATABASE %I SET cozystack.collation_repair = %L', current_database(), split_part(:'recorded', ':', 1) || ':' || split_part(:'recorded', ':', 2) || ':' || concat_ws(',', nullif(split_part(:'recorded', ':', 3), ''), :'attempt')) WHERE :'recorded' <> '' \gexec
|
||||||
@@ -499,6 +525,7 @@ stringData:
|
|||||||
\endif
|
\endif
|
||||||
EOT
|
EOT
|
||||||
then
|
then
|
||||||
|
[ "${PIPESTATUS[0]}" != 2 ] || COLLATION_LOST=yes
|
||||||
DB_FAILED=yes
|
DB_FAILED=yes
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -527,10 +554,14 @@ stringData:
|
|||||||
EOT
|
EOT
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ -n "$COLLATION_FAILED" ]; then
|
if [ -n "$COLLATION_LOST" ]; then
|
||||||
echo "index rebuilds failed in:$COLLATION_FAILED (the errors are above); the other indexes were rebuilt. A unique index cannot be rebuilt over rows that the previous ordering kept apart and the new one treats as equal, so remove such duplicates. The next run of the init-job tries again, except for an index an error above reports as left alone" >&2
|
echo "lost the connection to the server during index rebuilds in:$COLLATION_FAILED" >&2
|
||||||
exit 1
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$COLLATION_FAILED" ]; then
|
||||||
|
echo "index rebuilds failed in:$COLLATION_FAILED (the errors are above); the other indexes were rebuilt. A unique index cannot be rebuilt over rows that the previous ordering kept apart and the new one treats as equal, so remove such duplicates. The next upgrade of the release starts the repair again, except for an index an error above reports as left alone" >&2
|
||||||
|
fi
|
||||||
|
[ -z "$COLLATION_FAILED" ] || exit 1
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if hasKey (.Values.users | default dict) "app" }}
|
{{- if hasKey (.Values.users | default dict) "app" }}
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
suite: the collation repair is started by a hook and runs outside the release
|
||||||
|
|
||||||
|
# The repair waits for CNPG to roll the new image out and then rebuilds
|
||||||
|
# indexes; inside the init-job hook that wait alone outlasted the upgrade
|
||||||
|
# timeout. A post-install/post-upgrade hook now only starts a Job of its own
|
||||||
|
# through the API, so the hook must never render while bootstrap is on, must
|
||||||
|
# run after the init-job, and reach nothing but the repair Job and the Cluster.
|
||||||
|
|
||||||
|
templates:
|
||||||
|
- templates/collation-repair.yaml
|
||||||
|
- templates/init-job.yaml
|
||||||
|
- templates/init-script.yaml
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: pg-test
|
||||||
|
namespace: tenant-test
|
||||||
|
|
||||||
|
set:
|
||||||
|
_cluster:
|
||||||
|
scheduling: {}
|
||||||
|
users:
|
||||||
|
app: {}
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: renders the starter and its RBAC on install, to record the release the data starts on
|
||||||
|
template: templates/collation-repair.yaml
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 4
|
||||||
|
|
||||||
|
- it: renders nothing while bootstrap is on, like the init-job it follows
|
||||||
|
template: templates/collation-repair.yaml
|
||||||
|
release:
|
||||||
|
upgrade: true
|
||||||
|
set:
|
||||||
|
bootstrap:
|
||||||
|
enabled: true
|
||||||
|
oldName: pg-old
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
|
||||||
|
- it: renders the starter and its RBAC on upgrade
|
||||||
|
template: templates/collation-repair.yaml
|
||||||
|
release:
|
||||||
|
upgrade: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 4
|
||||||
|
|
||||||
|
- it: runs the starter after the init-job, as a post-install and post-upgrade hook
|
||||||
|
template: templates/collation-repair.yaml
|
||||||
|
release:
|
||||||
|
upgrade: true
|
||||||
|
documentSelector:
|
||||||
|
path: kind
|
||||||
|
value: Job
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: metadata.annotations["helm.sh/hook"]
|
||||||
|
value: post-install,post-upgrade
|
||||||
|
- equal:
|
||||||
|
path: metadata.annotations["helm.sh/hook-weight"]
|
||||||
|
value: "1"
|
||||||
|
- equal:
|
||||||
|
path: spec.backoffLimit
|
||||||
|
value: 0
|
||||||
|
- equal:
|
||||||
|
path: spec.activeDeadlineSeconds
|
||||||
|
value: 180
|
||||||
|
- equal:
|
||||||
|
path: spec.template.spec.serviceAccountName
|
||||||
|
value: pg-test-collation-repair-start
|
||||||
|
- equal:
|
||||||
|
path: spec.template.metadata.labels["policy.cozystack.io/allow-to-apiserver"]
|
||||||
|
value: "true"
|
||||||
|
|
||||||
|
- it: the init-job runs before the starter
|
||||||
|
template: templates/init-job.yaml
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: metadata.annotations["helm.sh/hook-weight"]
|
||||||
|
value: "-5"
|
||||||
|
|
||||||
|
- it: limits the Role to the repair Job and the release's own Cluster
|
||||||
|
template: templates/collation-repair.yaml
|
||||||
|
release:
|
||||||
|
upgrade: true
|
||||||
|
documentSelector:
|
||||||
|
path: kind
|
||||||
|
value: Role
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: rules
|
||||||
|
value:
|
||||||
|
- apiGroups: ["batch"]
|
||||||
|
resources: ["jobs"]
|
||||||
|
resourceNames: ["pg-test-collation-repair"]
|
||||||
|
verbs: ["get", "delete"]
|
||||||
|
- apiGroups: ["batch"]
|
||||||
|
resources: ["jobs"]
|
||||||
|
verbs: ["create"]
|
||||||
|
- apiGroups: ["postgresql.cnpg.io"]
|
||||||
|
resources: ["clusters"]
|
||||||
|
resourceNames: ["pg-test"]
|
||||||
|
verbs: ["get"]
|
||||||
|
|
||||||
|
- it: removes the RBAC once the hooks succeed
|
||||||
|
template: templates/collation-repair.yaml
|
||||||
|
release:
|
||||||
|
upgrade: true
|
||||||
|
documentSelector:
|
||||||
|
path: kind
|
||||||
|
value: RoleBinding
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: metadata.annotations["helm.sh/hook-delete-policy"]
|
||||||
|
value: before-hook-creation,hook-succeeded
|
||||||
|
- equal:
|
||||||
|
path: subjects[0].name
|
||||||
|
value: pg-test-collation-repair-start
|
||||||
|
|
||||||
|
- it: keeps the starter and the repair Job apart for a long release name
|
||||||
|
template: templates/collation-repair.yaml
|
||||||
|
release:
|
||||||
|
name: postgres-a-name-at-the-53-character-release-name-limi
|
||||||
|
upgrade: true
|
||||||
|
documentSelector:
|
||||||
|
path: kind
|
||||||
|
value: Job
|
||||||
|
asserts:
|
||||||
|
- matchRegex:
|
||||||
|
path: metadata.name
|
||||||
|
pattern: ^.{1,40}-collation-repair-start$
|
||||||
|
|
||||||
|
- it: names the repair Job within 63 characters for a long release name
|
||||||
|
template: templates/collation-repair.yaml
|
||||||
|
release:
|
||||||
|
name: postgres-a-name-at-the-53-character-release-name-limi
|
||||||
|
upgrade: true
|
||||||
|
documentSelector:
|
||||||
|
path: kind
|
||||||
|
value: Role
|
||||||
|
asserts:
|
||||||
|
- matchRegex:
|
||||||
|
path: rules[0].resourceNames[0]
|
||||||
|
pattern: ^.{1,46}-collation-repair$
|
||||||
|
|
||||||
|
- it: the init-job runs its script through the reconnecting wrapper
|
||||||
|
template: templates/init-job.yaml
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.template.spec.containers[0].command
|
||||||
|
value: [bash, /scripts/run.sh, /scripts/init.sh]
|
||||||
|
|
||||||
|
- it: the init-script Secret carries the repair apart from the init script
|
||||||
|
template: templates/init-script.yaml
|
||||||
|
documentSelector:
|
||||||
|
path: metadata.name
|
||||||
|
value: pg-test-init-script
|
||||||
|
asserts:
|
||||||
|
- exists:
|
||||||
|
path: stringData["run.sh"]
|
||||||
|
- exists:
|
||||||
|
path: stringData["init.sh"]
|
||||||
|
- exists:
|
||||||
|
path: stringData["repair.sh"]
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"allowCollationChange": {
|
"allowCollationChange": {
|
||||||
"description": "Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The init Job rebuilds the indexes on such text, those on C.UTF-8 and other C.* locales included; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.",
|
"description": "Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The collation repair Job, which a post-upgrade hook starts once the init Job is done, rebuilds the indexes on such text after the rollout, those on C.UTF-8 and other C.* locales included, and its log reports a rebuild that failed; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ external: false
|
|||||||
version: v18
|
version: v18
|
||||||
|
|
||||||
##
|
##
|
||||||
## @param {bool} allowCollationChange - Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The init Job rebuilds the indexes on such text, those on C.UTF-8 and other C.* locales included; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.
|
## @param {bool} allowCollationChange - Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The collation repair Job, which a post-upgrade hook starts once the init Job is done, rebuilds the indexes on such text after the rollout, those on C.UTF-8 and other C.* locales included, and its log reports a rebuild that failed; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.
|
||||||
allowCollationChange: false
|
allowCollationChange: false
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ spec:
|
|||||||
singular: postgres
|
singular: postgres
|
||||||
plural: postgreses
|
plural: postgreses
|
||||||
openAPISchema: |-
|
openAPISchema: |-
|
||||||
{"title":"Chart Values","type":"object","properties":{"replicas":{"description":"Number of Postgres replicas.","type":"integer","default":2},"resources":{"description":"Explicit CPU and memory configuration for each PostgreSQL replica. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"CPU available to each replica.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Memory (RAM) available to each replica.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.micro","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]},"size":{"description":"Persistent Volume Claim size available for application data.","default":"10Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"storageClass":{"description":"StorageClass used to store the data.","type":"string","default":"","x-kubernetes-validations":[{"rule":"self == oldSelf","message":"storageClass is immutable"}],"x-cozystack-options":{"source":"storageclass"}},"external":{"description":"Enable external access from outside the cluster.","type":"boolean","default":false},"version":{"description":"PostgreSQL major version to deploy","type":"string","default":"v18","enum":["v18","v17","v16","v15","v14","v13"]},"allowCollationChange":{"description":"Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The init Job rebuilds the indexes on such text, those on C.UTF-8 and other C.* locales included; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.","type":"boolean","default":false},"tls":{"description":"TLS configuration for server connections.","type":"object","default":{},"properties":{"enabled":{"description":"Tri-state switch controlling whether the chart injects the external hostname into the operator-managed CNPG cert via spec.certificates.serverAltDNSNames. When omitted, the chart injects the SAN if `external: true` and skips it otherwise. Set explicitly to `true` to inject regardless of `external` (no-op when `external: false` since there is no external hostname to add). Set to `false` to skip injection. Note that CNPG keeps its built-in TLS on the wire regardless of this flag — this toggle only controls the chart-side SAN injection; to disLine truncated
|
{"title":"Chart Values","type":"object","properties":{"replicas":{"description":"Number of Postgres replicas.","type":"integer","default":2},"resources":{"description":"Explicit CPU and memory configuration for each PostgreSQL replica. When omitted, the preset defined in `resourcesPreset` is applied.","type":"object","default":{},"properties":{"cpu":{"description":"CPU available to each replica.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Memory (RAM) available to each replica.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset used when `resources` is omitted.","type":"string","default":"t1.micro","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]},"size":{"description":"Persistent Volume Claim size available for application data.","default":"10Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"storageClass":{"description":"StorageClass used to store the data.","type":"string","default":"","x-kubernetes-validations":[{"rule":"self == oldSelf","message":"storageClass is immutable"}],"x-cozystack-options":{"source":"storageclass"}},"external":{"description":"Enable external access from outside the cluster.","type":"boolean","default":false},"version":{"description":"PostgreSQL major version to deploy","type":"string","default":"v18","enum":["v18","v17","v16","v15","v14","v13"]},"allowCollationChange":{"description":"Allow a cluster created on a Debian bullseye image (before the move to standard-trixie) to move to the new image without a clean locale check. Such a cluster is checked before each upgrade, except while `bootstrap.enabled` is set (set it back to false once a restore set up by hand has finished), and stays on its current image until the check finds nothing that depends on a collation other than C, POSIX or builtin: while this is false, a cluster the check found affected (an ICU or libc locale, or C.UTF-8) or could not finish on stays put, because glibc and ICU on the new image sort text differently and every index on such text must be rebuilt. A held cluster runs the bare bullseye tag it has, gets no further PostgreSQL minors and so none of their security fixes, and refuses a change of `version`, since new majors are built only on the new images. To leave that state, either remove the dependency (move such columns and indexes to C, or to the builtin `pg_c_utf8` on PostgreSQL 17 and later) and let the next upgrade check again, or set this to true in a maintenance window: the cluster moves on the next upgrade, replicas restart on the new image first and can return wrong results through `-ro`, and unique indexes can accept duplicates, until the indexes are rebuilt on the primary. The collation repair Job, which a post-upgrade hook starts once the init Job is done, rebuilds the indexes on such text after the rollout, those on C.UTF-8 and other C.* locales included, and its log reports a rebuild that failed; check range partitions, CHECK constraints and materialized views on it, which a rebuild does not fix. A held cluster shows the hold only as an unchanged image; the result and the objects found are in the `postgres.cozystack.io/locale-data` and `postgres.cozystack.io/locale-data-objects` annotations of the cnpg.io Cluster, which an administrator can read. A restore of a backup taken on one of those bullseye images comes back on that image and is checked by the next upgrade.","type":"boolean","default":false},"tls":{"description":"TLS configuration for server connections.","type":"object","default":{},"properties":{"enabled":{"description":"Tri-state switch controlling whether the chart injects the external hostname into the operator-managed CNPG cert via spec.certificates.serverAltDNSNames. When omitted, the chart injects the SAN if `external: true` and skips it otherwise. Set explicitly to `true` to inject regardless of `external` (no-op when `external: false` since there is no external hostname to add). Set to `false` to skip injection. Note tLine truncated
|
||||||
release:
|
release:
|
||||||
prefix: postgres-
|
prefix: postgres-
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
Reference in new issue
Block a user