mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #86514 from yutedz/linear-rm-dead
Perform dead storage removal linearly
This commit is contained in:
		@@ -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 uid, s := range storageMap2 {
 | 
					 | 
				
			||||||
		found := false
 | 
					 | 
				
			||||||
	for _, crd := range allCustomResourceDefinitions {
 | 
						for _, crd := range allCustomResourceDefinitions {
 | 
				
			||||||
			if crd.UID == uid {
 | 
							if _, ok := storageMap[crd.UID]; ok {
 | 
				
			||||||
				found = true
 | 
								storageMap2[crd.UID] = storageMap[crd.UID]
 | 
				
			||||||
				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)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user