mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Perform dead storage removal linearly
This commit is contained in:
parent
9f841bf423
commit
9bc862ec69
@ -526,29 +526,21 @@ func (r *crdHandler) removeDeadStorage() {
|
|||||||
r.customStorageLock.Lock()
|
r.customStorageLock.Lock()
|
||||||
defer r.customStorageLock.Unlock()
|
defer r.customStorageLock.Unlock()
|
||||||
|
|
||||||
oldInfos := []*crdInfo{}
|
|
||||||
storageMap := r.customStorage.Load().(crdStorageMap)
|
storageMap := r.customStorage.Load().(crdStorageMap)
|
||||||
// Copy because we cannot write to storageMap without a race
|
// Copy because we cannot write to storageMap without a race
|
||||||
// as it is used without locking elsewhere
|
storageMap2 := make(crdStorageMap)
|
||||||
storageMap2 := storageMap.clone()
|
for _, crd := range allCustomResourceDefinitions {
|
||||||
for uid, s := range storageMap2 {
|
if _, ok := storageMap[crd.UID]; ok {
|
||||||
found := false
|
storageMap2[crd.UID] = storageMap[crd.UID]
|
||||||
for _, crd := range allCustomResourceDefinitions {
|
|
||||||
if crd.UID == uid {
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
klog.V(4).Infof("Removing dead CRD storage for %s/%s", s.spec.Group, s.spec.Names.Kind)
|
|
||||||
oldInfos = append(oldInfos, s)
|
|
||||||
delete(storageMap2, uid)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r.customStorage.Store(storageMap2)
|
r.customStorage.Store(storageMap2)
|
||||||
|
|
||||||
for _, s := range oldInfos {
|
for uid, crdInfo := range storageMap {
|
||||||
go r.tearDown(s)
|
if _, ok := storageMap2[uid]; !ok {
|
||||||
|
klog.V(4).Infof("Removing dead CRD storage for %s/%s", crdInfo.spec.Group, crdInfo.spec.Names.Kind)
|
||||||
|
go r.tearDown(crdInfo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user