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 <brad.davidson@rancher.com>
This commit is contained in:
Brad Davidson 2023-12-13 00:28:26 +00:00 committed by Brad Davidson
parent db7091b3f6
commit 319dca3e82

View File

@ -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{}