Skip to content

Commit

Permalink
Merge pull request #124644 from aroradaman/temp-pod-logs
Browse files Browse the repository at this point in the history
e2e/network: stream pod logs for debugging
  • Loading branch information
k8s-ci-robot committed May 1, 2024
2 parents 6abdfb9 + d70f96f commit b041e54
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/e2e/network/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package network

import (
"bufio"
"context"
"fmt"
"strconv"
Expand Down Expand Up @@ -327,6 +328,37 @@ var _ = common.SIGDescribe("Networking", func() {

ginkgo.It("should update endpoints: http", func(ctx context.Context) {
config := e2enetwork.NewNetworkingTestConfig(ctx, f)

// start of intermittent code snippet to understand the reason for flaky behaviour
// TODO @aroradaman @aojea remove this once issue #123760 is resolved
// streaming logs for netserver-0 which will be deleted during the test
// (ref: https://github.com/kubernetes/kubernetes/issues/123760)
pod0name := config.EndpointPods[0].Name
go func() {
defer ginkgo.GinkgoRecover()
readCloser, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).GetLogs(pod0name, &v1.PodLogOptions{
Follow: true,
}).Stream(ctx)

// silently ignoring error, we don't want to disturb the original test
if err != nil {
return
}
defer func() {
_ = readCloser.Close()
}()

scanner := bufio.NewScanner(readCloser)
var lines []string
for scanner.Scan() {
lines = append(lines, "\t\t"+scanner.Text())
}
framework.Logf("================ start of pod log for %s ================", pod0name)
framework.Logf("\n%s", strings.Join(lines, "\n"))
framework.Logf("================ end of pod log for %s ================", pod0name)
}()
// end of intermittent code snippet

ginkgo.By(fmt.Sprintf("dialing(http) %v --> %v:%v (config.clusterIP)", config.TestContainerPod.Name, config.ClusterIP, e2enetwork.ClusterHTTPPort))
err := config.DialFromTestContainer(ctx, "http", config.ClusterIP, e2enetwork.ClusterHTTPPort, config.MaxTries, 0, config.EndpointHostnames())
if err != nil {
Expand Down

0 comments on commit b041e54

Please sign in to comment.