From 5d143387d701b7b9da3a6a770946761135662865 Mon Sep 17 00:00:00 2001 From: wesleysu <59680532+River-sh@users.noreply.github.com> Date: Sat, 28 Oct 2023 10:55:32 +0800 Subject: [PATCH] fix dns controller get raven dns configmap (#1759) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 珩轩 --- .../controller/raven/dns/dns_controller.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/yurtmanager/controller/raven/dns/dns_controller.go b/pkg/yurtmanager/controller/raven/dns/dns_controller.go index 38347ba643c..18a28c8fdd4 100644 --- a/pkg/yurtmanager/controller/raven/dns/dns_controller.go +++ b/pkg/yurtmanager/controller/raven/dns/dns_controller.go @@ -160,23 +160,24 @@ func (r *ReconcileDns) Reconcile(ctx context.Context, req reconcile.Request) (re func (r ReconcileDns) getProxyDNS(ctx context.Context, objKey client.ObjectKey) (*corev1.ConfigMap, error) { var cm corev1.ConfigMap - err := wait.PollImmediate(5*time.Second, time.Minute, func() (done bool, err error) { + waitErr := wait.PollImmediate(5*time.Second, time.Minute, func() (done bool, err error) { err = r.Client.Get(ctx, objKey, &cm) if err != nil { if apierrors.IsNotFound(err) { err = r.buildRavenDNSConfigMap() if err != nil { - klog.Errorf(Format("failed to generate dns record , error %s", err.Error())) - return false, nil + klog.Errorf(Format(err.Error())) } + } else { + klog.Errorf(Format("failed to get configmap %s, error %s", objKey.String(), err.Error())) } - klog.Error(Format("failed to get ConfigMap %s, error %s", objKey.String(), err.Error())) return false, nil } return true, nil }) - if err != nil { - return cm.DeepCopy(), fmt.Errorf("failed to get ConfigMap %s, error %s", objKey.String(), err.Error()) + + if waitErr != nil { + return nil, fmt.Errorf("failed to get ConfigMap %s, error %s", objKey.String(), waitErr.Error()) } return cm.DeepCopy(), nil }