diff --git a/pkg/dev/podmandev/reconcile.go b/pkg/dev/podmandev/reconcile.go index bb8ae4b7fb4..6780359c9a4 100644 --- a/pkg/dev/podmandev/reconcile.go +++ b/pkg/dev/podmandev/reconcile.go @@ -119,12 +119,11 @@ func (o *DevClient) reconcile( // Check that the application is actually listening on the ports declared in the Devfile, so we are sure that port-forwarding will work appReadySpinner := log.Spinner("Waiting for the application to be ready") - defer appReadySpinner.End(false) - err = o.checkAppPorts(pod.Name, fwPorts) + err = o.checkAppPorts(ctx, pod.Name, fwPorts) + appReadySpinner.End(err == nil) if err != nil { - return err + log.Warningf("port-forwarding might not work correctly: %v", err) } - appReadySpinner.End(true) // By default, Podman will not forward to container applications listening on the loopback interface. // So we are trying to detect such cases and act accordingly. @@ -225,12 +224,12 @@ func (o *DevClient) deployPod(ctx context.Context, options dev.StartOptions) (*c return pod, fwPorts, nil } -func (o *DevClient) checkAppPorts(podName string, portsToFwd []api.ForwardedPort) error { +func (o *DevClient) checkAppPorts(ctx context.Context, podName string, portsToFwd []api.ForwardedPort) error { containerPortsMapping := make(map[string][]int) for _, p := range portsToFwd { containerPortsMapping[p.ContainerName] = append(containerPortsMapping[p.ContainerName], p.ContainerPort) } - return port.CheckAppPortsListening(o.execClient, podName, containerPortsMapping, 1*time.Minute) + return port.CheckAppPortsListening(ctx, o.execClient, podName, containerPortsMapping, 1*time.Minute) } // handleLoopbackPorts tries to detect if any of the ports to forward (in fwPorts) is actually bound to the loopback interface within the specified pod. diff --git a/pkg/devfile/adapters/kubernetes/component/adapter.go b/pkg/devfile/adapters/kubernetes/component/adapter.go index 9ae4ae1e5d5..0e287801921 100644 --- a/pkg/devfile/adapters/kubernetes/component/adapter.go +++ b/pkg/devfile/adapters/kubernetes/component/adapter.go @@ -344,12 +344,11 @@ func (a Adapter) Push(ctx context.Context, parameters adapters.PushParameters, c // Check that the application is actually listening on the ports declared in the Devfile, so we are sure that port-forwarding will work appReadySpinner := log.Spinner("Waiting for the application to be ready") - defer appReadySpinner.End(false) - err = a.checkAppPorts(pod.Name, portsToForward) + err = a.checkAppPorts(ctx, pod.Name, portsToForward) + appReadySpinner.End(err == nil) if err != nil { - return err + log.Warningf("port-forwarding might not work correctly: %v", err) } - appReadySpinner.End(true) err = a.portForwardClient.StartPortForwarding(a.Devfile, a.ComponentName, parameters.Debug, parameters.RandomPorts, log.GetStdout(), parameters.ErrOut, nil) if err != nil { @@ -766,14 +765,14 @@ func (a Adapter) deleteServiceBindingSecrets(serviceBindingSecretsToRemove []uns return nil } -func (a *Adapter) checkAppPorts(podName string, portsToFwd map[string][]devfilev1.Endpoint) error { +func (a *Adapter) checkAppPorts(ctx context.Context, podName string, portsToFwd map[string][]devfilev1.Endpoint) error { containerPortsMapping := make(map[string][]int) for c, ports := range portsToFwd { for _, p := range ports { containerPortsMapping[c] = append(containerPortsMapping[c], p.TargetPort) } } - return port.CheckAppPortsListening(a.execClient, podName, containerPortsMapping, 1*time.Minute) + return port.CheckAppPortsListening(ctx, a.execClient, podName, containerPortsMapping, 1*time.Minute) } // PushCommandsMap stores the commands to be executed as per their types.