Skip to content

Commit f7a28c3

Browse files
author
Antonio Ojea
committed
Revert "Merge pull request kubernetes#93837 from jayunit100/DialFromContainerB"
This reverts commit 61490bb, reversing changes made to 9ecab1b. Some methods from the networking e2e tools are dialing from a containter to another container, and failing the test if there was no connectivity. This PR modified the methods to return an error instead of failing the test. However, these methods were used by other tests in the framework, and they are not checking if the method returns an error, expecting that the method fail the test. With this change, any connectivity problem will go unnoticed on the tests that are not asserting the error, so we need to revert to previous state.
1 parent 0b8c2bf commit f7a28c3

File tree

2 files changed

+16
-57
lines changed

2 files changed

+16
-57
lines changed

test/e2e/common/networking.go

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package common
1818

1919
import (
2020
"github.com/onsi/ginkgo"
21-
v1 "k8s.io/api/core/v1"
2221
"k8s.io/apimachinery/pkg/util/sets"
2322
"k8s.io/kubernetes/test/e2e/framework"
2423
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
@@ -29,45 +28,6 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() {
2928

3029
ginkgo.Describe("Granular Checks: Pods", func() {
3130

32-
checkNodeConnectivity := func(config *e2enetwork.NetworkingTestConfig, protocol string, port int) {
33-
// breadth first poll to quickly estimate failure.
34-
failedPodsByHost := map[string][]*v1.Pod{}
35-
// First time, we'll quickly try all pods, breadth first.
36-
for _, endpointPod := range config.EndpointPods {
37-
framework.Logf("Breadth first check of %v on host %v...", endpointPod.Status.PodIP, endpointPod.Status.HostIP)
38-
if err := config.DialFromTestContainer(protocol, endpointPod.Status.PodIP, port, 1, 0, sets.NewString(endpointPod.Name)); err != nil {
39-
if _, ok := failedPodsByHost[endpointPod.Status.HostIP]; !ok {
40-
failedPodsByHost[endpointPod.Status.HostIP] = []*v1.Pod{}
41-
}
42-
failedPodsByHost[endpointPod.Status.HostIP] = append(failedPodsByHost[endpointPod.Status.HostIP], endpointPod)
43-
framework.Logf("...failed...will try again in next pass")
44-
}
45-
}
46-
errors := []error{}
47-
// Second time, we pass through pods more carefully...
48-
framework.Logf("Going to retry %v out of %v pods....", len(failedPodsByHost), len(config.EndpointPods))
49-
for host, failedPods := range failedPodsByHost {
50-
framework.Logf("Doublechecking %v pods in host %v which werent seen the first time.", len(failedPods), host)
51-
for _, endpointPod := range failedPods {
52-
framework.Logf("Now attempting to probe pod [[[ %v ]]]", endpointPod.Status.PodIP)
53-
if err := config.DialFromTestContainer(protocol, endpointPod.Status.PodIP, port, config.MaxTries, 0, sets.NewString(endpointPod.Name)); err != nil {
54-
errors = append(errors, err)
55-
} else {
56-
framework.Logf("Was able to reach %v on %v ", endpointPod.Status.PodIP, endpointPod.Status.HostIP)
57-
}
58-
framework.Logf("... Done probing pod [[[ %v ]]]", endpointPod.Status.PodIP)
59-
}
60-
framework.Logf("succeeded at polling %v out of %v connections", len(config.EndpointPods)-len(errors), len(config.EndpointPods))
61-
}
62-
if len(errors) > 0 {
63-
framework.Logf("pod polling failure summary:")
64-
for _, e := range errors {
65-
framework.Logf("Collected error: %v", e)
66-
}
67-
framework.Failf("failed, %v out of %v connections failed", len(errors), len(config.EndpointPods))
68-
}
69-
}
70-
7131
// Try to hit all endpoints through a test container, retry 5 times,
7232
// expect exactly one unique hostname. Each of these endpoints reports
7333
// its own hostname.
@@ -79,7 +39,9 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() {
7939
*/
8040
framework.ConformanceIt("should function for intra-pod communication: http [NodeConformance]", func() {
8141
config := e2enetwork.NewCoreNetworkingTestConfig(f, false)
82-
checkNodeConnectivity(config, "http", e2enetwork.EndpointHTTPPort)
42+
for _, endpointPod := range config.EndpointPods {
43+
config.DialFromTestContainer("http", endpointPod.Status.PodIP, e2enetwork.EndpointHTTPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
44+
}
8345
})
8446

8547
/*
@@ -90,7 +52,9 @@ var _ = ginkgo.Describe("[sig-network] Networking", func() {
9052
*/
9153
framework.ConformanceIt("should function for intra-pod communication: udp [NodeConformance]", func() {
9254
config := e2enetwork.NewCoreNetworkingTestConfig(f, false)
93-
checkNodeConnectivity(config, "udp", e2enetwork.EndpointUDPPort)
55+
for _, endpointPod := range config.EndpointPods {
56+
config.DialFromTestContainer("udp", endpointPod.Status.PodIP, e2enetwork.EndpointUDPPort, config.MaxTries, 0, sets.NewString(endpointPod.Name))
57+
}
9458
})
9559

9660
/*

test/e2e/framework/network/utils.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ type NetexecDialResponse struct {
167167
}
168168

169169
// DialFromEndpointContainer executes a curl via kubectl exec in an endpoint container.
170-
func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error {
171-
return config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps)
170+
func (config *NetworkingTestConfig) DialFromEndpointContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) {
171+
config.DialFromContainer(protocol, echoHostname, config.EndpointPods[0].Status.PodIP, targetIP, EndpointHTTPPort, targetPort, maxTries, minTries, expectedEps)
172172
}
173173

174174
// DialFromTestContainer executes a curl via kubectl exec in a test container.
175-
func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) error {
176-
return config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps)
175+
func (config *NetworkingTestConfig) DialFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, expectedEps sets.String) {
176+
config.DialFromContainer(protocol, echoHostname, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedEps)
177177
}
178178

179179
// DialEchoFromTestContainer executes a curl via kubectl exec in a test container. The response is expected to match the echoMessage.
180-
func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) error {
180+
func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP string, targetPort, maxTries, minTries int, echoMessage string) {
181181
expectedResponse := sets.NewString()
182182
expectedResponse.Insert(echoMessage)
183183
var dialCommand string
@@ -191,7 +191,7 @@ func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP
191191
} else {
192192
dialCommand = fmt.Sprintf("echo%%20%s", echoMessage)
193193
}
194-
return config.DialFromContainer(protocol, dialCommand, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedResponse)
194+
config.DialFromContainer(protocol, dialCommand, config.TestContainerPod.Status.PodIP, targetIP, testContainerHTTPPort, targetPort, maxTries, minTries, expectedResponse)
195195
}
196196

197197
// diagnoseMissingEndpoints prints debug information about the endpoints that
@@ -248,8 +248,7 @@ func makeCURLDialCommand(ipPort, dialCmd, protocol, targetIP string, targetPort
248248
// maxTries == minTries will confirm that we see the expected endpoints and no
249249
// more for maxTries. Use this if you want to eg: fail a readiness check on a
250250
// pod and confirm it doesn't show up as an endpoint.
251-
// Returns nil if no error, or error message if failed after trying maxTries.
252-
func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) error {
251+
func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, containerIP, targetIP string, containerHTTPPort, targetPort, maxTries, minTries int, expectedResponses sets.String) {
253252
ipPort := net.JoinHostPort(containerIP, strconv.Itoa(containerHTTPPort))
254253
cmd := makeCURLDialCommand(ipPort, dialCommand, protocol, targetIP, targetPort)
255254

@@ -274,19 +273,16 @@ func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, con
274273

275274
// Check against i+1 so we exit if minTries == maxTries.
276275
if (responses.Equal(expectedResponses) || responses.Len() == 0 && expectedResponses.Len() == 0) && i+1 >= minTries {
277-
framework.Logf("reached %v after %v/%v tries", targetIP, i, maxTries)
278-
return nil
276+
return
279277
}
280278
// TODO: get rid of this delay #36281
281279
time.Sleep(hitEndpointRetryDelay)
282280
}
281+
283282
if dialCommand == echoHostname {
284283
config.diagnoseMissingEndpoints(responses)
285284
}
286-
returnMsg := fmt.Errorf("did not find expected responses... \nTries %d\nCommand %v\nretrieved %v\nexpected %v", maxTries, cmd, responses, expectedResponses)
287-
framework.Logf("encountered error during dial (%v)", returnMsg)
288-
return returnMsg
289-
285+
framework.Failf("Failed to find expected responses:\nTries %d\nCommand %v\nretrieved %v\nexpected %v\n", maxTries, cmd, responses, expectedResponses)
290286
}
291287

292288
// GetEndpointsFromTestContainer executes a curl via kubectl exec in a test container.
@@ -681,7 +677,6 @@ func (config *NetworkingTestConfig) setupCore(selector map[string]string) {
681677

682678
epCount := len(config.EndpointPods)
683679
config.MaxTries = epCount*epCount + testTries
684-
framework.Logf("Setting MaxTries for pod polling to %v for networking test based on endpoint count %v", config.MaxTries, epCount)
685680
}
686681

687682
// setup includes setupCore and also sets up services

0 commit comments

Comments
 (0)