mirror of https://github.com/k3s-io/k3s
fix data race in storage (during addition)
parent
64a984bb62
commit
4a08a693b7
|
@ -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