@@ -83,21 +83,20 @@ func execWithoutTimeout(clientConfig *rest.Config, bundlePath string, execCollec
83
83
}
84
84
85
85
if len (pods ) > 0 {
86
- for _ , pod := range pods {
87
- stdout , stderr , execErrors := getExecOutputs (ctx , clientConfig , client , pod , execCollector )
88
-
89
- path := filepath .Join (execCollector .Name , pod .Namespace , pod .Name )
90
- if len (stdout ) > 0 {
91
- output .SaveResult (bundlePath , filepath .Join (path , execCollector .CollectorName + "-stdout.txt" ), bytes .NewBuffer (stdout ))
92
- }
93
- if len (stderr ) > 0 {
94
- output .SaveResult (bundlePath , filepath .Join (path , execCollector .CollectorName + "-stderr.txt" ), bytes .NewBuffer (stderr ))
95
- }
96
-
97
- if len (execErrors ) > 0 {
98
- output .SaveResult (bundlePath , filepath .Join (path , execCollector .CollectorName + "-errors.json" ), marshalErrors (execErrors ))
99
- continue
100
- }
86
+ // When the selector refers to more than one replica of a pod, the exec collector will execute in only one of the pods
87
+ pod := pods [0 ]
88
+ stdout , stderr , execErrors := getExecOutputs (ctx , clientConfig , client , pod , execCollector )
89
+
90
+ path := filepath .Join (execCollector .Name , pod .Namespace , pod .Name )
91
+ if len (stdout ) > 0 {
92
+ output .SaveResult (bundlePath , filepath .Join (path , execCollector .CollectorName + "-stdout.txt" ), bytes .NewBuffer (stdout ))
93
+ }
94
+ if len (stderr ) > 0 {
95
+ output .SaveResult (bundlePath , filepath .Join (path , execCollector .CollectorName + "-stderr.txt" ), bytes .NewBuffer (stderr ))
96
+ }
97
+
98
+ if len (execErrors ) > 0 {
99
+ output .SaveResult (bundlePath , filepath .Join (path , execCollector .CollectorName + "-errors.json" ), marshalErrors (execErrors ))
101
100
}
102
101
}
103
102
0 commit comments