@@ -167,17 +167,17 @@ type NetexecDialResponse struct {
167
167
}
168
168
169
169
// 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 ) {
171
- 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 ) error {
171
+ return config .DialFromContainer (protocol , echoHostname , config .EndpointPods [0 ].Status .PodIP , targetIP , EndpointHTTPPort , targetPort , maxTries , minTries , expectedEps )
172
172
}
173
173
174
174
// 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 ) {
176
- 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 ) error {
176
+ return config .DialFromContainer (protocol , echoHostname , config .TestContainerPod .Status .PodIP , targetIP , testContainerHTTPPort , targetPort , maxTries , minTries , expectedEps )
177
177
}
178
178
179
179
// 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 ) {
180
+ func (config * NetworkingTestConfig ) DialEchoFromTestContainer (protocol , targetIP string , targetPort , maxTries , minTries int , echoMessage string ) error {
181
181
expectedResponse := sets .NewString ()
182
182
expectedResponse .Insert (echoMessage )
183
183
var dialCommand string
@@ -191,7 +191,7 @@ func (config *NetworkingTestConfig) DialEchoFromTestContainer(protocol, targetIP
191
191
} else {
192
192
dialCommand = fmt .Sprintf ("echo%%20%s" , echoMessage )
193
193
}
194
- config .DialFromContainer (protocol , dialCommand , config .TestContainerPod .Status .PodIP , targetIP , testContainerHTTPPort , targetPort , maxTries , minTries , expectedResponse )
194
+ return config .DialFromContainer (protocol , dialCommand , config .TestContainerPod .Status .PodIP , targetIP , testContainerHTTPPort , targetPort , maxTries , minTries , expectedResponse )
195
195
}
196
196
197
197
// diagnoseMissingEndpoints prints debug information about the endpoints that
@@ -248,7 +248,8 @@ func makeCURLDialCommand(ipPort, dialCmd, protocol, targetIP string, targetPort
248
248
// maxTries == minTries will confirm that we see the expected endpoints and no
249
249
// more for maxTries. Use this if you want to eg: fail a readiness check on a
250
250
// pod and confirm it doesn't show up as an endpoint.
251
- func (config * NetworkingTestConfig ) DialFromContainer (protocol , dialCommand , containerIP , targetIP string , containerHTTPPort , targetPort , maxTries , minTries int , expectedResponses sets.String ) {
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 {
252
253
ipPort := net .JoinHostPort (containerIP , strconv .Itoa (containerHTTPPort ))
253
254
cmd := makeCURLDialCommand (ipPort , dialCommand , protocol , targetIP , targetPort )
254
255
@@ -273,16 +274,19 @@ func (config *NetworkingTestConfig) DialFromContainer(protocol, dialCommand, con
273
274
274
275
// Check against i+1 so we exit if minTries == maxTries.
275
276
if (responses .Equal (expectedResponses ) || responses .Len () == 0 && expectedResponses .Len () == 0 ) && i + 1 >= minTries {
276
- return
277
+ framework .Logf ("reached %v after %v/%v tries" , targetIP , i , maxTries )
278
+ return nil
277
279
}
278
280
// TODO: get rid of this delay #36281
279
281
time .Sleep (hitEndpointRetryDelay )
280
282
}
281
-
282
283
if dialCommand == echoHostname {
283
284
config .diagnoseMissingEndpoints (responses )
284
285
}
285
- framework .Failf ("Failed to find expected responses:\n Tries %d\n Command %v\n retrieved %v\n expected %v\n " , maxTries , cmd , responses , expectedResponses )
286
+ returnMsg := fmt .Errorf ("did not find expected responses... \n Tries %d\n Command %v\n retrieved %v\n expected %v" , maxTries , cmd , responses , expectedResponses )
287
+ framework .Logf ("encountered error during dial (%v)" , returnMsg )
288
+ return returnMsg
289
+
286
290
}
287
291
288
292
// GetEndpointsFromTestContainer executes a curl via kubectl exec in a test container.
@@ -677,6 +681,7 @@ func (config *NetworkingTestConfig) setupCore(selector map[string]string) {
677
681
678
682
epCount := len (config .EndpointPods )
679
683
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 )
680
685
}
681
686
682
687
// setup includes setupCore and also sets up services
0 commit comments