Ignore not found error during patching managedFields (#6135)

Signed-off-by: Wenkai Yin(尹文开) <yinw@vmware.com>
This commit is contained in:
Wenkai Yin(尹文开)
2023-04-13 08:33:09 +08:00
committed by GitHub
parent 6b499da5ff
commit ba6e356640
2 changed files with 7 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
Ignore not found error during patching managedFields
+6 -3
View File
@@ -1434,10 +1434,13 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
if patchBytes != nil {
if _, err = resourceClient.Patch(name, patchBytes); err != nil {
ctx.log.Errorf("error patch for managed fields %s: %v", kube.NamespaceAndName(obj), err)
errs.Add(namespace, err)
return warnings, errs
if !apierrors.IsNotFound(err) {
errs.Add(namespace, err)
return warnings, errs
}
} else {
ctx.log.Infof("the managed fields for %s is patched", kube.NamespaceAndName(obj))
}
ctx.log.Infof("the managed fields for %s is patched", kube.NamespaceAndName(obj))
}
if groupResource == kuberesource.Pods {