Skip to content

Commit

Permalink
retry content update if it was delete before snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Shelly Kagan <[email protected]>
  • Loading branch information
ShellyKa13 committed Sep 4, 2022
1 parent b389cdd commit 5db6470
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/storage/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const (
vmSnapshotDeadlineExceededError = "snapshot deadline exceeded"

snapshotRetryInterval = 5 * time.Second

contentDeletionInterval = 5 * time.Second
)

func VmSnapshotReady(vmSnapshot *snapshotv1.VirtualMachineSnapshot) bool {
Expand Down Expand Up @@ -99,6 +101,10 @@ func shouldDeleteContent(vmSnapshot *snapshotv1.VirtualMachineSnapshot, content
return deleteContentPolicy(vmSnapshot) || !vmSnapshotContentReady(content)
}

func vmSnapshotContentDeleting(content *snapshotv1.VirtualMachineSnapshotContent) bool {
return content != nil && content.DeletionTimestamp != nil
}

func vmSnapshotDeleting(vmSnapshot *snapshotv1.VirtualMachineSnapshot) bool {
return vmSnapshot != nil && vmSnapshot.DeletionTimestamp != nil
}
Expand Down Expand Up @@ -276,6 +282,12 @@ func (ctrl *VMSnapshotController) updateVMSnapshotContent(content *snapshotv1.Vi
}
}

if vmSnapshotContentDeleting(content) {
log.Log.V(3).Infof("Content deleting %s/%s", content.Namespace, content.Name)
return contentDeletionInterval, nil

}

currentlyReady := vmSnapshotContentReady(content)
currentlyError := (content.Status != nil && content.Status.Error != nil) || vmSnapshotError(vmSnapshot) != nil

Expand Down

0 comments on commit 5db6470

Please sign in to comment.