Skip to content

Commit

Permalink
Fix nill map in full snapshot reconcile
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
brandond committed Dec 13, 2023
1 parent 1082202 commit e5d6904
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/etcd/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down

0 comments on commit e5d6904

Please sign in to comment.