Skip to content

Commit 3627033

Browse files
committed
Fix bug where no config resulted in infinate loop
1 parent a13cc90 commit 3627033

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎pkg/reconcile/config_map.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func ReconcileConfigMap(ctx context.Context, logger logr.Logger, reader client.R
6363
}
6464
if !reflect.DeepEqual(actualConfigMap.Data, data) {
6565
// Correct the data field
66+
logger.V(0).WithValues("actual", actualConfigMap.Data, "expected", data).Info("Configmap data incorrect")
6667
actualConfigMap.Data = data
6768
return &actualConfigMap,
6869
func(ctx context.Context, logger logr.Logger, writer client.Writer) (ctrl.Result, error) {
@@ -163,5 +164,10 @@ func configMapData(spec minecraftv1alpha1.MinecraftServerSpec) (map[string]strin
163164
config["prometheus_exporter_config.yaml"] = string(d)
164165
}
165166

167+
// We need this for comparison later, because K8s will store an empty map as a nil (on the configmap data field
168+
// anyway).
169+
if len(config) == 0 {
170+
return nil, nil
171+
}
166172
return config, nil
167173
}

0 commit comments

Comments
 (0)