mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-13 08:05:19 +09:00
The in-place CNPG restore skips deleting the live Cluster when it carries bootstrap.recovery and was created after the RestoreJob started, taking that as "this restore's own purge and re-render produced it". The timestamp does not say which restore rendered the Cluster. A Cluster deleted while the restore waits for the WAL archive is re-rendered by the still-active HelmRelease from the previous restore's values and is created after StartedAt too; the restore then skipped its purge and reported Succeeded on the previous restore's data. The restore patch already sets bootstrap.newServerName to restoredServerName(cluster, RestoreJob UID). The chart now annotates the Cluster with it as postgres.cozystack.io/restored-server-name, whether or not it renders the barman plugin that also carries the value, and the purge is skipped only when the annotation names this RestoreJob. The mark lives on the rendered Cluster rather than in RestoreJob status, so it still covers the failed status write the skip exists for. A Cluster rendered by a chart that predates the annotation keeps the creation-time check. Fixes #3322 Assisted-by: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com>
67 lines
1.8 KiB
YAML
67 lines
1.8 KiB
YAML
suite: Cluster carries the restore that rendered it
|
|
|
|
# The CNPG restore driver sets bootstrap.newServerName to a value unique to each
|
|
# RestoreJob and reads it back off the Cluster to decide whether the live
|
|
# recovery Cluster is the one its own purge produced. The barman plugin's
|
|
# serverName is not enough, since the plugin renders only with chart-level S3
|
|
# coordinates, so the chart annotates the Cluster whenever the value is set.
|
|
|
|
templates:
|
|
- templates/db.yaml
|
|
|
|
release:
|
|
name: pg-test
|
|
namespace: tenant-test
|
|
|
|
set:
|
|
_cluster:
|
|
scheduling: {}
|
|
|
|
tests:
|
|
- it: annotates a restored Cluster with bootstrap.newServerName
|
|
set:
|
|
backup:
|
|
enabled: true
|
|
useSystemBucket: false
|
|
s3AccessKey: AKIAEXAMPLE
|
|
s3SecretKey: s3cr3t
|
|
destinationPath: s3://bucket/pg-test/
|
|
endpointURL: https://s3.example:9000
|
|
bootstrap:
|
|
enabled: true
|
|
oldName: pg-test
|
|
serverName: pg-test
|
|
newServerName: pg-test-restore-deadbeef
|
|
documentSelector:
|
|
path: kind
|
|
value: Cluster
|
|
asserts:
|
|
- equal:
|
|
path: metadata.annotations["postgres.cozystack.io/restored-server-name"]
|
|
value: pg-test-restore-deadbeef
|
|
|
|
- it: keeps the annotation when the barman plugin is not rendered
|
|
set:
|
|
backup:
|
|
enabled: false
|
|
bootstrap:
|
|
enabled: false
|
|
newServerName: pg-test-restore-deadbeef
|
|
documentSelector:
|
|
path: kind
|
|
value: Cluster
|
|
asserts:
|
|
- notExists:
|
|
path: spec.plugins
|
|
- equal:
|
|
path: metadata.annotations["postgres.cozystack.io/restored-server-name"]
|
|
value: pg-test-restore-deadbeef
|
|
|
|
- it: renders no annotation on a Cluster that was never restored
|
|
documentSelector:
|
|
path: kind
|
|
value: Cluster
|
|
asserts:
|
|
- notExists:
|
|
path: metadata.annotations
|