mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-08 22:23:15 +00:00
bug fix: populate namespace in logs for backup errors (#2438)
Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
1
changelogs/unreleased/2438-skriss
Normal file
1
changelogs/unreleased/2438-skriss
Normal file
@@ -0,0 +1 @@
|
||||
bug fix: populate namespace in logs for backup errors
|
||||
@@ -273,24 +273,29 @@ func (rb *defaultResourceBackupper) backupItem(
|
||||
return false
|
||||
}
|
||||
|
||||
log = log.WithFields(map[string]interface{}{
|
||||
"namespace": metadata.GetNamespace(),
|
||||
"name": metadata.GetName(),
|
||||
})
|
||||
|
||||
if gr == kuberesource.Namespaces && !rb.backupRequest.NamespaceIncludesExcludes.ShouldInclude(metadata.GetName()) {
|
||||
log.WithField("name", metadata.GetName()).Info("Skipping namespace because it's excluded")
|
||||
log.Info("Skipping namespace because it's excluded")
|
||||
return false
|
||||
}
|
||||
|
||||
backedUpItem, err := itemBackupper.backupItem(log, unstructured, gr)
|
||||
if aggregate, ok := err.(kubeerrs.Aggregate); ok {
|
||||
log.WithField("name", metadata.GetName()).Infof("%d errors encountered backup up item", len(aggregate.Errors()))
|
||||
log.Infof("%d errors encountered backup up item", len(aggregate.Errors()))
|
||||
// log each error separately so we get error location info in the log, and an
|
||||
// accurate count of errors
|
||||
for _, err = range aggregate.Errors() {
|
||||
log.WithError(err).WithField("name", metadata.GetName()).Error("Error backing up item")
|
||||
log.WithError(err).Error("Error backing up item")
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("name", metadata.GetName()).Error("Error backing up item")
|
||||
log.WithError(err).Error("Error backing up item")
|
||||
return false
|
||||
}
|
||||
return backedUpItem
|
||||
|
||||
Reference in New Issue
Block a user