Skip to content

Commit

Permalink
Reorder snapshot configmap reconcile to reduce log spew during initia…
Browse files Browse the repository at this point in the history
…l startup

Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Nov 17, 2023
1 parent fd676a5 commit f0f2f45
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pkg/etcd/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand All @@ -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()

Expand Down

0 comments on commit f0f2f45

Please sign in to comment.