From 319dca3e82a78721c85187b783ec735e45e9f826 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Wed, 13 Dec 2023 00:28:26 +0000 Subject: [PATCH] Fix nil map in full snapshot configmap reconcile If a full reconcile wins the race against sync of an individual snapshot resource, or someone intentionally deletes the configmap, the data map could be nil and cause a crash. Signed-off-by: Brad Davidson --- pkg/etcd/snapshot_controller.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/etcd/snapshot_controller.go b/pkg/etcd/snapshot_controller.go index b5e3be3225..295f0117e4 100644 --- a/pkg/etcd/snapshot_controller.go +++ b/pkg/etcd/snapshot_controller.go @@ -252,6 +252,10 @@ func (e *etcdSnapshotHandler) reconcile() error { } } + if len(snapshots) > 0 && snapshotConfigMap.Data == nil { + snapshotConfigMap.Data = map[string]string{} + } + // Ensure keys for existing snapshots for sfKey, esf := range snapshots { sf := snapshotFile{}