File tree 1 file changed +11
-15
lines changed
1 file changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -325,29 +325,25 @@ func (g *GenericPLEG) relist() {
325
325
func getContainersFromPods (pods ... * kubecontainer.Pod ) []* kubecontainer.Container {
326
326
cidSet := sets .NewString ()
327
327
var containers []* kubecontainer.Container
328
- for _ , p := range pods {
329
- if p == nil {
330
- continue
331
- }
332
- for _ , c := range p .Containers {
333
- cid := string (c .ID .ID )
328
+ fillCidSet := func (cs []* kubecontainer.Container ) {
329
+ for _ , c := range cs {
330
+ cid := c .ID .ID
334
331
if cidSet .Has (cid ) {
335
332
continue
336
333
}
337
334
cidSet .Insert (cid )
338
335
containers = append (containers , c )
339
336
}
337
+ }
338
+
339
+ for _ , p := range pods {
340
+ if p == nil {
341
+ continue
342
+ }
343
+ fillCidSet (p .Containers )
340
344
// Update sandboxes as containers
341
345
// TODO: keep track of sandboxes explicitly.
342
- for _ , c := range p .Sandboxes {
343
- cid := string (c .ID .ID )
344
- if cidSet .Has (cid ) {
345
- continue
346
- }
347
- cidSet .Insert (cid )
348
- containers = append (containers , c )
349
- }
350
-
346
+ fillCidSet (p .Sandboxes )
351
347
}
352
348
return containers
353
349
}
You can’t perform that action at this time.
0 commit comments