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>
(cherry picked from commit 319dca3e82)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/9216/head
Brad Davidson 2023-12-13 00:28:26 +00:00 committed by Brad Davidson
parent fe19faaf9a
commit f95ab7aaf9
1 changed files with 4 additions and 0 deletions

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