crd create event: skip storage teardown if the crd info doesn't change

This commit is contained in:
Haowei Cai 2020-12-22 13:00:06 -08:00
parent d815833a30
commit ba143a7bdd

View File

@ -468,6 +468,16 @@ func (r *crdHandler) createCustomResourceDefinition(obj interface{}) {
r.customStorageLock.Lock()
defer r.customStorageLock.Unlock()
// this could happen if the create event is merged from create-update events
storageMap := r.customStorage.Load().(crdStorageMap)
oldInfo, found := storageMap[crd.UID]
if !found {
return
}
if apiequality.Semantic.DeepEqual(&crd.Spec, oldInfo.spec) && apiequality.Semantic.DeepEqual(&crd.Status.AcceptedNames, oldInfo.acceptedNames) {
klog.V(6).Infof("Ignoring customresourcedefinition %s create event because a storage with the same spec and accepted names exists",
crd.Name)
return
}
r.removeStorage_locked(crd.UID)
}