Files
cozystack/internal/backupcontroller
Alexey Artamonov a6af14ce74 fix(postgres): build a backup's artifact from the destination it was written to
The WAL archive destination is written by the pass that creates the
cnpg.io/Backup and not again while it runs, yet the artifact took the
destination, the endpoint and the credentials Secret from the strategy
rendered when the Backup completed. A strategy or BackupClass edited
while the backup ran gave an artifact that pointed somewhere nothing
had been written, and a restore from it found no data.

The pass that writes the destination now records it on the
cnpg.io/Backup it creates, and the artifact is built from that record.
The record lives on the Backup rather than on the BackupJob because a
tenant can edit its BackupJobs but has no access to postgresql.cnpg.io
objects: a record a tenant could rewrite would point the artifact, and
a restore from it, which takes its S3 keys from the strategy, at an
endpoint of the tenant's choosing.

The artifact size probe measures the same place: the recorded
location and credentials Secret, with the Secret keys and the endpoint
CA, which the record does not carry, from the strategy. Should those no
longer fit after an edit, the probe reports no size instead of
measuring somewhere else.

A record that cannot be read, or that names no destination path,
creates no artifact and fails the job, since the strategy may no longer
match the write. A Backup without a record was created by a controller
that kept none, and its artifact is built from the strategy as before.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-11-10 00:08:41 +03:00
..