From f0f2f4548c0d378a31119807a791ecab6367efc1 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Fri, 17 Nov 2023 01:30:49 +0000 Subject: [PATCH] Reorder snapshot configmap reconcile to reduce log spew during initial startup Signed-off-by: Brad Davidson --- pkg/etcd/snapshot_controller.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/etcd/snapshot_controller.go b/pkg/etcd/snapshot_controller.go index a21da8481719..b5e3be32251a 100644 --- a/pkg/etcd/snapshot_controller.go +++ b/pkg/etcd/snapshot_controller.go @@ -160,21 +160,6 @@ func (e *etcdSnapshotHandler) onRemove(key string, esf *apisv1.ETCDSnapshotFile) } func (e *etcdSnapshotHandler) reconcile() error { - logrus.Infof("Reconciling snapshot ConfigMap data") - - snapshotConfigMap, err := e.configmaps.Get(metav1.NamespaceSystem, snapshotConfigMapName, metav1.GetOptions{}) - if err != nil { - if !apierrors.IsNotFound(err) { - return errors.Wrap(err, "failed to get snapshot ConfigMap") - } - snapshotConfigMap = &v1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: snapshotConfigMapName, - Namespace: metav1.NamespaceSystem, - }, - } - } - // Get a list of all etcd nodes currently in the cluster. // We will use this list to prune local entries for any node that does not exist. nodes := e.etcd.config.Runtime.Core.Core().V1().Node() @@ -202,6 +187,8 @@ func (e *etcdSnapshotHandler) reconcile() error { return errNotReconciled } + logrus.Infof("Reconciling snapshot ConfigMap data") + // Get a list of existing snapshots snapshotList, err := e.snapshots.List(metav1.ListOptions{}) if err != nil { @@ -219,6 +206,19 @@ func (e *etcdSnapshotHandler) reconcile() error { snapshots[sfKey] = esf } + snapshotConfigMap, err := e.configmaps.Get(metav1.NamespaceSystem, snapshotConfigMapName, metav1.GetOptions{}) + if err != nil { + if !apierrors.IsNotFound(err) { + return errors.Wrap(err, "failed to get snapshot ConfigMap") + } + snapshotConfigMap = &v1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: snapshotConfigMapName, + Namespace: metav1.NamespaceSystem, + }, + } + } + // Make a copy of the configmap for change detection existing := snapshotConfigMap.DeepCopyObject()