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

fix overall status of application restore object #1311

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 20 additions & 9 deletions pkg/applicationmanager/controllers/applicationrestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -1357,15 +1357,7 @@ func (a *ApplicationRestoreController) restoreResources(

restore.Status.Stage = storkapi.ApplicationRestoreStageFinal
restore.Status.FinishTimestamp = metav1.Now()
restore.Status.Status = storkapi.ApplicationRestoreStatusSuccessful
restore.Status.Reason = "Volumes and resources were restored up successfully"
for _, resource := range restore.Status.Resources {
if resource.Status != storkapi.ApplicationRestoreStatusSuccessful {
restore.Status.Status = storkapi.ApplicationRestoreStatusPartialSuccess
restore.Status.Reason = "Volumes were restored successfully. Some existing resources were not replaced"
break
}
}
setOverallApplicationRestoreStatus(restore)

restore.Status.LastUpdateTimestamp = metav1.Now()
if err := a.client.Update(context.TODO(), restore); err != nil {
Expand All @@ -1375,6 +1367,25 @@ func (a *ApplicationRestoreController) restoreResources(
return nil
}

// setOverallApplicationRestoreStatus set final application restore status based on status of all individual resources
func setOverallApplicationRestoreStatus(restore *storkapi.ApplicationRestore) {
restore.Status.Status = storkapi.ApplicationRestoreStatusSuccessful
restore.Status.Reason = "Volumes and resources were restored up successfully"
numFailedResources := 0
for _, resource := range restore.Status.Resources {
if resource.Status == storkapi.ApplicationRestoreStatusFailed {
numFailedResources++
}
}
if numFailedResources == len(restore.Status.Resources) {
restore.Status.Status = storkapi.ApplicationRestoreStatusFailed
restore.Status.Reason = "Volumes were restored successfully. Resources were not replaced"
} else if numFailedResources != 0 {
restore.Status.Status = storkapi.ApplicationRestoreStatusPartialSuccess
restore.Status.Reason = "Volumes were restored successfully. Some resources were not replaced"
}
}

func (a *ApplicationRestoreController) addCSIVolumeResources(restore *storkapi.ApplicationRestore) error {
for _, vrInfo := range restore.Status.Volumes {
if vrInfo.DriverName != "csi" && vrInfo.DriverName != "kdmp" {
Expand Down