Commit c66d2499 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

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
parents 6065a0da 4a08a693
...@@ -343,8 +343,17 @@ func (r *crdHandler) getServingInfoFor(crd *apiextensions.CustomResourceDefiniti ...@@ -343,8 +343,17 @@ func (r *crdHandler) getServingInfoFor(crd *apiextensions.CustomResourceDefiniti
storage: storage, storage: storage,
requestScope: requestScope, 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 return ret
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment