mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Merge pull request #50098 from nikhita/crd-data-race
Automatic merge from submit-queue (batch tested with PRs 46685, 49863, 50098, 50070, 50096) apiextensions: fix data race in storage Fixes data race in CRD storage. Copy to a new map because we cannot write to storageMap without a race as it is used without locking elsewhere. **Release note**: ```release-note NONE ``` /cc @sttts
This commit is contained in:
commit
c66d2499da
@ -343,8 +343,17 @@ func (r *crdHandler) getServingInfoFor(crd *apiextensions.CustomResourceDefiniti
|
||||
storage: storage,
|
||||
requestScope: requestScope,
|
||||
}
|
||||
storageMap[crd.UID] = ret
|
||||
r.customStorage.Store(storageMap)
|
||||
|
||||
storageMap2 := make(crdStorageMap, len(storageMap))
|
||||
|
||||
// Copy because we cannot write to storageMap without a race
|
||||
// as it is used without locking elsewhere
|
||||
for k, v := range storageMap {
|
||||
storageMap2[k] = v
|
||||
}
|
||||
|
||||
storageMap2[crd.UID] = ret
|
||||
r.customStorage.Store(storageMap2)
|
||||
return ret
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user