mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #109227 from Monokaix/refactor-pleg/getContainersFromPods
refactor: pleg/getContainersFromPods
This commit is contained in:
		@@ -325,29 +325,25 @@ func (g *GenericPLEG) relist() {
 | 
			
		||||
func getContainersFromPods(pods ...*kubecontainer.Pod) []*kubecontainer.Container {
 | 
			
		||||
	cidSet := sets.NewString()
 | 
			
		||||
	var containers []*kubecontainer.Container
 | 
			
		||||
	fillCidSet := func(cs []*kubecontainer.Container) {
 | 
			
		||||
		for _, c := range cs {
 | 
			
		||||
			cid := c.ID.ID
 | 
			
		||||
			if cidSet.Has(cid) {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			cidSet.Insert(cid)
 | 
			
		||||
			containers = append(containers, c)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, p := range pods {
 | 
			
		||||
		if p == nil {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
		for _, c := range p.Containers {
 | 
			
		||||
			cid := string(c.ID.ID)
 | 
			
		||||
			if cidSet.Has(cid) {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			cidSet.Insert(cid)
 | 
			
		||||
			containers = append(containers, c)
 | 
			
		||||
		}
 | 
			
		||||
		fillCidSet(p.Containers)
 | 
			
		||||
		// Update sandboxes as containers
 | 
			
		||||
		// TODO: keep track of sandboxes explicitly.
 | 
			
		||||
		for _, c := range p.Sandboxes {
 | 
			
		||||
			cid := string(c.ID.ID)
 | 
			
		||||
			if cidSet.Has(cid) {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			cidSet.Insert(cid)
 | 
			
		||||
			containers = append(containers, c)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		fillCidSet(p.Sandboxes)
 | 
			
		||||
	}
 | 
			
		||||
	return containers
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user