From 1b124a314663e01108ab90d0417cea455d7ef4f6 Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Wed, 3 Jan 2018 13:02:38 -0500 Subject: [PATCH] Log backup item action error when it occurs If a backup item action errors, log the error as soon as it occurs, so it's clear when the error happened. Also include information about the groupResource, namespace, and name of the item in the error. Signed-off-by: Andy Goldstein --- pkg/backup/item_backupper.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/backup/item_backupper.go b/pkg/backup/item_backupper.go index a75573d18..ec5015113 100644 --- a/pkg/backup/item_backupper.go +++ b/pkg/backup/item_backupper.go @@ -213,7 +213,12 @@ func (ib *defaultItemBackupper) backupItem(logger logrus.FieldLogger, obj runtim ib.additionalItemBackupper.backupItem(log, additionalItem, gvr.GroupResource()) } } else { - return errors.Wrap(err, "error executing custom action") + // We want this to show up in the log file at the place where the error occurs. When we return + // the error, it get aggregated with all the other ones at the end of the backup, making it + // harder to tell when it happened. + log.WithError(err).Error("error executing custom action") + + return errors.Wrapf(err, "error executing custom action (groupResource=%s, namespace=%s, name=%s)", groupResource.String(), namespace, name) } }