MCPcopy
hub / github.com/istio/istio / connect

Method connect

pkg/test/framework/components/echo/kube/workload.go:247–282  ·  view source on GitHub ↗
(pod corev1.Pod)

Source from the content-addressed store, hash-verified

245}
246
247func (w *workload) connect(pod corev1.Pod) (err error) {
248 defer func() {
249 if err != nil {
250 _ = w.disconnect()
251 }
252 }()
253
254 // Create a forwarder to the command port of the app.
255 if err = retry.UntilSuccess(func() error {
256 w.forwarder, err = w.cluster.NewPortForwarder(pod.Name, pod.Namespace, "", 0, int(w.grpcPort))
257 if err != nil {
258 return fmt.Errorf("failed creating new port forwarder for pod %s/%s: %v",
259 pod.Namespace, pod.Name, err)
260 }
261 if err = w.forwarder.Start(); err != nil {
262 return fmt.Errorf("failed starting port forwarder for pod %s/%s: %v",
263 pod.Namespace, pod.Name, err)
264 }
265 return nil
266 }, retry.BackoffDelay(100*time.Millisecond), retry.Timeout(10*time.Second)); err != nil {
267 return err
268 }
269
270 // Create a gRPC client to this workload.
271 w.client, err = echoClient.New(w.forwarder.Address(), w.tls)
272 if err != nil {
273 return fmt.Errorf("failed connecting to grpc client to pod %s/%s : %v",
274 pod.Namespace, pod.Name, err)
275 }
276
277 if w.hasSidecar {
278 w.sidecar = newSidecar(pod, w.cluster)
279 }
280
281 return nil
282}
283
284func (w *workload) disconnect() (err error) {
285 if w.client != nil {

Callers 3

UpdateMethod · 0.95
ratings.jsFile · 0.80
watchPortForwardFunction · 0.80

Calls 10

disconnectMethod · 0.95
UntilSuccessFunction · 0.92
BackoffDelayFunction · 0.92
TimeoutFunction · 0.92
newSidecarFunction · 0.85
NewPortForwarderMethod · 0.65
ErrorfMethod · 0.65
StartMethod · 0.65
NewMethod · 0.65
AddressMethod · 0.65

Tested by

no test coverage detected