Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print portforward stdio only on error #1527

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/validate/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"io"
"net/http"
"net/url"
"os"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -335,14 +334,18 @@ func checkPortForward(c internalapi.RuntimeService, portForwardSeverURL string,
framework.ExpectNoError(err, "failed to create spdy round tripper")
parsedURL := parseURL(c, portForwardSeverURL)
dialer := spdy.NewDialer(upgrader, &http.Client{Transport: transport}, "POST", parsedURL)
pf, err := portforward.New(dialer, []string{fmt.Sprintf("%d:%d", hostPort, containerPort)}, stopChan, readyChan, os.Stdout, os.Stderr)

stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}

pf, err := portforward.New(dialer, []string{fmt.Sprintf("%d:%d", hostPort, containerPort)}, stopChan, readyChan, stdout, stderr)
framework.ExpectNoError(err, "failed to create port forward for %q", portForwardSeverURL)

go func() {
defer GinkgoRecover()
By("start port forward")
err = pf.ForwardPorts()
framework.ExpectNoError(err, "failed to start port forward for %q", portForwardSeverURL)
err := pf.ForwardPorts()
framework.ExpectNoError(err, "failed to start port forward for %q, stdout: %s, stderr: %s", portForwardSeverURL, stdout.String(), stderr.String())
}()

By(fmt.Sprintf("check if we can get nginx main page via localhost:%d", hostPort))
Expand Down
Loading