From f7731df074a49cf9555a03d936e4f3a463aab62d Mon Sep 17 00:00:00 2001 From: Anton Ouzounov Date: Wed, 4 Aug 2021 21:09:20 +0300 Subject: [PATCH] fix(kube): ignore errors.IsConflict on update call - multiple log-routers try to update a single unique ResourceVersion - ignore errors.IsConflict as it is ResourceVersion collision - no need to retry, each log-router is a process, muli-thread because of daemonset, etcd version is our lock - only one log-router needs to succeed, same validation happens in all log-routers Signed-off-by: Anton Ouzounov --- config-reloader/datasource/kube_informer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config-reloader/datasource/kube_informer.go b/config-reloader/datasource/kube_informer.go index d677e197..38a068fa 100644 --- a/config-reloader/datasource/kube_informer.go +++ b/config-reloader/datasource/kube_informer.go @@ -6,6 +6,7 @@ import ( "sort" "time" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "github.com/sirupsen/logrus" @@ -122,7 +123,9 @@ func (d *kubeInformerConnection) UpdateStatus(namespace string, status string) { _, err = d.client.CoreV1().Namespaces().Update(ns) logrus.Debugf("Saving status annotation to namespace %s: %+v", namespace, err) - if err != nil { + // errors.IsConflict is safe to ignore since multiple log-routers try update at same time + // (only 1 router can update this unique ResourceVersion, no need to retry, each router is a retry process): + if err != nil && !errors.IsConflict(err) { logrus.Infof("Cannot set error status on namespace %s: %+v", namespace, err) } }