fix(restore): label each Velero Restore with the id of its restore

FA
5d ago
+68-5

Stacked on #631. This pull request targets the branch of #631 (034-backup-rename-description). After #631 merges, retarget it to develop.

Summary

ADR-073 requires every Kubernetes object that Styrmin creates for a record to carry a label with the record's id. #631 adds the label styrmin.io/backup-id to the Velero Backup. The Velero Restore was already named styrmin-<restore id>, but it had no label with the restore's id. With this change, an operator can select the Velero Restore of a restore by its id:

kubectl get restores.velero.io -n styrmin -l styrmin.io/restore-id=<restore id>

Key changes

  • Every new Velero Restore has the label styrmin.io/restore-id with the id of the Styrmin restore. This applies to in-place restores, environment restores and the restores that an environment clone runs.
    • build_velero_restore takes the new required argument restore_id.
    • execute_restore_workflow passes the id of the Restore record that it read.
  • Velero Restore objects that earlier versions created keep their labels. Nothing in Styrmin updates or deletes Velero Restore objects, so the older objects need no migration.

Documentation updates

Test plan

  • Unit tests:
    • backend/tests/unit/agent/test_backup_builders.py checks the label on in-place and cross-target restores.
    • test_restore_workflow_labels_the_velero_restore_with_the_restore_id in backend/tests/unit/workflows/test_restore_steps.py checks that the flow passes the restore's id.
    • The backend unit suite passed locally: 5318 passed, 1 skipped.
  • uv run invoke format lint passed locally.
  • E2E: test_backup_and_restore_lifecycle (shard backup) now reads the Velero Restore styrmin-<restore id> after the restore completes and checks its styrmin.io/restore-id label.
    • The test did not run locally. The local Docker uses the classic (non-containerd) image store, so vCluster in Docker turns off its registry proxy, and the images that the fixtures build never reach the cluster. The chart-server pod stayed in ImagePullBackOff during fixture setup, before the test body ran.
    • This pull request relies on the CI shard E2E Tests (api / backup) and its UI variant for this test.

Related

  • #631: Velero Backup objects named and labelled by the backup's id.
  • Found during a review of develop against ADR-073. Issues from the same review: #634, #635, #636, #637.