Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add condition for indicating restore completion #127

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apis/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ const (
StashInitContainerInjected = "StashInitContainerInjected"
// RestoreJobCreated indicates whether the restore job was created
RestoreJobCreated = "RestoreJobCreated"
// RestoreCompleted condition indicates whether the restore process has been completed or not.
// This condition is particularly helpful when the restore addon require some additional operations to perform
// before marking the RestoreSession Succeeded/Failed.
RestoreCompleted = "RestoreCompleted"

// GlobalPreBackupHookSucceeded indicates whether the global PreBackupHook was executed successfully or not
GlobalPreBackupHookSucceeded = "GlobalPreBackupHookSucceeded"
Expand Down
18 changes: 18 additions & 0 deletions pkg/conditions/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,21 @@ func SetInitContainerInjectedConditionToFalse(inv invoker.RestoreInvoker, tref a
Message: fmt.Sprintf("Failed to inject Stash init-container. Reason: %v", err.Error()),
})
}

func SetRestoreCompletedConditionToTrue(inv invoker.RestoreInvoker, tref api_v1beta1.TargetRef, msg string) error {
return inv.SetCondition(&tref, kmapi.Condition{
Type: apis.RestoreCompleted,
Status: core.ConditionTrue,
Reason: "PostRestoreTasksExecuted",
Message: msg,
})
}

func SetRestoreCompletedConditionToFalse(inv invoker.RestoreInvoker, tref api_v1beta1.TargetRef, msg string) error {
return inv.SetCondition(&tref, kmapi.Condition{
Type: apis.RestoreCompleted,
Status: core.ConditionFalse,
Reason: "PostRestoreTasksNotExecuted",
Message: msg,
})
}