Skip to content

Commit 967ad1b

Browse files
committed
Discard promoted snapshot base after snapshot failure
1 parent 7d4bb48 commit 967ad1b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/instances/standby.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ func (m *manager) standbyInstance(
105105
log.ErrorContext(ctx, "snapshot failed, attempting to resume VM", "instance_id", id, "error", err)
106106
hv.Resume(ctx)
107107
if promotedRetainedBase {
108-
if rollbackErr := restoreRetainedSnapshotBase(snapshotDir, retainedBaseDir); rollbackErr != nil {
109-
log.WarnContext(ctx, "failed to restore retained snapshot base after snapshot error", "instance_id", id, "error", rollbackErr)
108+
// Snapshot errors can happen after partial file writes; discard the
109+
// promoted base to avoid reusing potentially corrupted data.
110+
if rollbackErr := os.RemoveAll(snapshotDir); rollbackErr != nil {
111+
log.WarnContext(ctx, "failed to discard promoted snapshot target after snapshot error", "instance_id", id, "error", rollbackErr)
110112
}
111113
}
112114
return nil, fmt.Errorf("create snapshot: %w", err)

0 commit comments

Comments
 (0)