Skip to content

Commit b041e54

Browse files
authored
Merge pull request kubernetes#124644 from aroradaman/temp-pod-logs
e2e/network: stream pod logs for debugging
2 parents 6abdfb9 + d70f96f commit b041e54

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/e2e/network/networking.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package network
1818

1919
import (
20+
"bufio"
2021
"context"
2122
"fmt"
2223
"strconv"
@@ -327,6 +328,37 @@ var _ = common.SIGDescribe("Networking", func() {
327328

328329
ginkgo.It("should update endpoints: http", func(ctx context.Context) {
329330
config := e2enetwork.NewNetworkingTestConfig(ctx, f)
331+
332+
// start of intermittent code snippet to understand the reason for flaky behaviour
333+
// TODO @aroradaman @aojea remove this once issue #123760 is resolved
334+
// streaming logs for netserver-0 which will be deleted during the test
335+
// (ref: https://github.com/kubernetes/kubernetes/issues/123760)
336+
pod0name := config.EndpointPods[0].Name
337+
go func() {
338+
defer ginkgo.GinkgoRecover()
339+
readCloser, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).GetLogs(pod0name, &v1.PodLogOptions{
340+
Follow: true,
341+
}).Stream(ctx)
342+
343+
// silently ignoring error, we don't want to disturb the original test
344+
if err != nil {
345+
return
346+
}
347+
defer func() {
348+
_ = readCloser.Close()
349+
}()
350+
351+
scanner := bufio.NewScanner(readCloser)
352+
var lines []string
353+
for scanner.Scan() {
354+
lines = append(lines, "\t\t"+scanner.Text())
355+
}
356+
framework.Logf("================ start of pod log for %s ================", pod0name)
357+
framework.Logf("\n%s", strings.Join(lines, "\n"))
358+
framework.Logf("================ end of pod log for %s ================", pod0name)
359+
}()
360+
// end of intermittent code snippet
361+
330362
ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort))
331363
err := config.DialFromTestContainer(ctx, "http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames())
332364
if err != nil {

0 commit comments

Comments
 (0)