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

Validate port-forwards by attempting to bind to port #2345

Merged
merged 2 commits into from
Jun 26, 2019

Conversation

briandealwis
Copy link
Member

Skaffold's port-forwarding now attempts a GET on forwarded-ports to verify that the port-forward was successful, but this breaks JVM debugging (non-HTTP based) and causes spurious log messages. (It also introduces latency when dealing with remote clusters.)

This patch changes the port-forwarding validation check to attempt to bind to the port instead, which is expected to fail.

$ cd examples/jib; ../../cmd/skaffold/skaffold debug --port-forward
...
Forwarding container web-586567d484-j6st9/web to local port 5006.
Port Forwarding pod/web-586567d484-j6st9 5005 -> 5006
[web-586567d484-j6st9 web] Debugger failed to attach: handshake failed - received >GET / HTTP/1.1< - expected >JDWP-Handshake<
[web-586567d484-j6st9 web] Debugger failed to attach: handshake failed - received >GET / HTTP/1.1< - expected >JDWP-Handshake<
[...repeated...]

@priyawadhwa
Copy link
Contributor

Looks like a linting error

Gofmt errors in files:
./pkg/skaffold/kubernetes/portforward/kubectl_forwarder.go
diff -u ./pkg/skaffold/kubernetes/portforward/kubectl_forwarder.go.orig ./pkg/skaffold/kubernetes/portforward/kubectl_forwarder.go
--- ./pkg/skaffold/kubernetes/portforward/kubectl_forwarder.go.orig	2019-06-26 14:26:36.391552089 +0000
+++ ./pkg/skaffold/kubernetes/portforward/kubectl_forwarder.go	2019-06-26 14:26:36.391552089 +0000
@@ -63,7 +63,7 @@
 	// creating a listening port should not succeed
 	if ln, err := net.Listen("tcp", fmt.Sprintf("%s:%d", util.Loopback, port)); err == nil {
 		ln.Close()
-		return errors.New("port-forward failed") 
+		return errors.New("port-forward failed")
 	}
 	return nil
 }
FAILED hack/gofmt.sh

@codecov
Copy link

codecov bot commented Jun 26, 2019

Codecov Report

Merging #2345 into master will decrease coverage by 0.01%.
The diff coverage is 0%.

Impacted Files Coverage Δ
...affold/kubernetes/portforward/kubectl_forwarder.go 0% <0%> (ø) ⬆️

@balopat balopat merged commit 8e89a34 into GoogleContainerTools:master Jun 26, 2019
@briandealwis briandealwis deleted the tweak-2215 branch June 27, 2019 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants