From 07b39e7d0af086fca387a151b71cad813949bc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Freitas?= Date: Fri, 19 Apr 2024 15:03:50 +0900 Subject: [PATCH] fix: resource already exists During syncing of virtual namespaces to physical, the default service account already exists, which leads to errors during syncing. In this fix we consume the error in case the physical resource already exists. Co-authored-by: Ajith Chandran Co-authored-by: Wojtek Koronski --- pkg/controllers/syncer/translator/namespaced_translator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/controllers/syncer/translator/namespaced_translator.go b/pkg/controllers/syncer/translator/namespaced_translator.go index 582dc52a6..7e99a8ccd 100644 --- a/pkg/controllers/syncer/translator/namespaced_translator.go +++ b/pkg/controllers/syncer/translator/namespaced_translator.go @@ -80,6 +80,10 @@ func (n *namespacedTranslator) SyncToHostCreate(ctx *context.SyncContext, vObj, ctx.Log.Debugf("error syncing %s %s/%s to physical cluster: %v", n.name, vObj.GetNamespace(), vObj.GetName(), err) return ctrl.Result{RequeueAfter: time.Second}, nil } + if kerrors.IsAlreadyExists(err) { + ctx.Log.Debugf("ignoring syncing %s %s/%s to physical cluster as it already exists", n.name, vObj.GetNamespace(), vObj.GetName()) + return ctrl.Result{}, nil + } ctx.Log.Infof("error syncing %s %s/%s to physical cluster: %v", n.name, vObj.GetNamespace(), vObj.GetName(), err) n.eventRecorder.Eventf(vObj, "Warning", "SyncError", "Error syncing to physical cluster: %v", err) return ctrl.Result{}, err