Skip to content

StorageBackupReconciler: recover from duplicate snapshot/backup creation on retry#226

Merged
boddumanohar merged 1 commit into
mainfrom
issue-144
Jul 24, 2026
Merged

StorageBackupReconciler: recover from duplicate snapshot/backup creation on retry#226
boddumanohar merged 1 commit into
mainfrom
issue-144

Conversation

@boddumanohar

@boddumanohar boddumanohar commented Jun 4, 2026

Copy link
Copy Markdown
Member

fixes: #144

Problem

When the operator creates a backup, it does two things in sequence:

  1. create snapshot
  2. create backup from the above snapshot
  3. Save the returned ID onto the Kubernetes status object

But If the operator crashed or restarted between those two steps, it creates the same backup again and we get 409 conflict. which is not handled on the operator side.

Fix

as a fix we handle 409 conflict and get the ID using findSnapshotByName. Since the backend doesn't have support get by Name, we list snapshots and get the name.

@noctarius
noctarius marked this pull request as draft July 13, 2026 10:12
Make snapshot and backup creation idempotent across reconcile retries.
Previously, if the operator restarted (or a request otherwise failed)
between the backend create call succeeding and the status write that
records the resulting ID, the CR's status field stayed empty and the
next reconcile issued a second, unconditional create call -- producing
an orphaned duplicate snapshot or backup on the backend.

Creation is now attempted directly (no pre-creation lookup, since that
would cost an extra network call on every normal reconcile for no
benefit in the common case). If the backend rejects the retried create
as a duplicate, the reconciler recovers the existing resource's ID with
a single lookup instead of failing:

- Snapshots: the backend's v2 API returns 409 Conflict with an
  "already exists" body on a duplicate name. isDuplicateNameError
  matches on the 409 status.
- Backups: the backend has no name uniqueness constraint for backups;
  it instead returns 400 with "already has a backup" when the target
  snapshot is already backed up. isDuplicateBackupError matches on
  that specific 400 condition.

storagebackupsync_controller.go also retries the status patch for a
StorageBackup CR that was previously imported (labeled) but whose
status write failed, instead of attempting to recreate it.
@boddumanohar
boddumanohar marked this pull request as ready for review July 24, 2026 09:39
@boddumanohar boddumanohar changed the title StorageBackupReconciler: fix duplicate snapshot creation StorageBackupReconciler: handle 409 conflict during backup creation Jul 24, 2026
@boddumanohar boddumanohar changed the title StorageBackupReconciler: handle 409 conflict during backup creation StorageBackupReconciler: recover from duplicate snapshot/backup creation on retry Jul 24, 2026
@boddumanohar
boddumanohar merged commit ff65e43 into main Jul 24, 2026
15 checks passed
@boddumanohar
boddumanohar deleted the issue-144 branch July 24, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: StorageBackupReconciler Creates Duplicate Snapshots When Operator Restarts Between API Call and Status Patch

3 participants