Insert all restore errors and warnings into restore log (#4743)

This allows a user inspecting the restore logs to see any
errors or warnings generated by the restore so that they
will be seen even without having to use the describe cli.

Signed-off-by: Scott Seago <sseago@redhat.com>
pull/4762/head
Scott Seago 2022-03-21 02:29:03 -04:00 committed by GitHub
parent 0e0d42b5f2
commit 09ec3ba994
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1 @@
Insert all restore errors and warnings into restore log.

View File

@ -486,6 +486,30 @@ func (c *restoreController) runValidatedRestore(restore *api.Restore, info backu
}
restoreWarnings, restoreErrors := c.restorer.RestoreWithResolvers(restoreReq, actionsResolver, snapshotItemResolver,
c.snapshotLocationLister, pluginManager)
// log errors and warnings to the restore log
for _, msg := range restoreErrors.Velero {
restoreLog.Errorf("Velero restore error: %v", msg)
}
for _, msg := range restoreErrors.Cluster {
restoreLog.Errorf("Cluster resource restore error: %v", msg)
}
for ns, errs := range restoreErrors.Namespaces {
for _, msg := range errs {
restoreLog.Errorf("Namespace %v, resource restore error: %v", ns, msg)
}
}
for _, msg := range restoreWarnings.Velero {
restoreLog.Warnf("Velero restore warning: %v", msg)
}
for _, msg := range restoreWarnings.Cluster {
restoreLog.Warnf("Cluster resource restore warning: %v", msg)
}
for ns, errs := range restoreWarnings.Namespaces {
for _, msg := range errs {
restoreLog.Warnf("Namespace %v, resource restore warning: %v", ns, msg)
}
}
restoreLog.Info("restore completed")
// re-instantiate the backup store because credentials could have changed since the original