From 10245b05de46f25e4b76fecb859b150d0e98069b Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai Date: Thu, 2 Nov 2023 15:53:47 -0400 Subject: [PATCH] restore: Use warning when Create IsAlreadyExist and Get error (#7004) Signed-off-by: Tiger Kaovilai --- changelogs/unreleased/7004-kaovilai | 1 + pkg/restore/restore.go | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/7004-kaovilai diff --git a/changelogs/unreleased/7004-kaovilai b/changelogs/unreleased/7004-kaovilai new file mode 100644 index 000000000..3b85df196 --- /dev/null +++ b/changelogs/unreleased/7004-kaovilai @@ -0,0 +1 @@ +restore: Use warning when Create IsAlreadyExist and Get error \ No newline at end of file diff --git a/pkg/restore/restore.go b/pkg/restore/restore.go index 031742900..dee68d33f 100644 --- a/pkg/restore/restore.go +++ b/pkg/restore/restore.go @@ -1532,18 +1532,17 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso } if restoreErr != nil { - // check for the existence of the object in cluster, if no error then it implies that object exists - // and if err then we want to judge whether there is an existing error in the previous creation. - // if so, we will return the 'get' error. - // otherwise, we will return the original creation error. + // check for the existence of the object that failed creation due to alreadyExist in cluster, if no error then it implies that object exists. + // and if err then itemExists remains false as we were not able to confirm the existence of the object via Get call or creation call. + // We return the get error as a warning to notify the user that the object could exist in cluster and we were not able to confirm it. if !ctx.disableInformerCache { fromCluster, err = ctx.getResource(groupResource, obj, namespace, name) } else { fromCluster, err = resourceClient.Get(name, metav1.GetOptions{}) } if err != nil && isAlreadyExistsError { - ctx.log.Errorf("Error retrieving in-cluster version of %s: %v", kube.NamespaceAndName(obj), err) - errs.Add(namespace, err) + ctx.log.Warnf("Unable to retrieve in-cluster version of %s: %v, object won't be restored by velero or have restore labels, and existing resource policy is not applied", kube.NamespaceAndName(obj), err) + warnings.Add(namespace, err) return warnings, errs, itemExists } }