Skip to content

Commit

Permalink
Add condition for indicating restore completion (#127)
Browse files Browse the repository at this point in the history
Signed-off-by: piyush1146115 <piyush@appscode.com>
  • Loading branch information
piyush1146115 committed Oct 8, 2021
1 parent 3ddabb5 commit 561988c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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,
})
}

0 comments on commit 561988c

Please sign in to comment.