-
Notifications
You must be signed in to change notification settings - Fork 244
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
odo experimental debug port-forward command #2043
odo experimental debug port-forward command #2043
Conversation
a16b0e2
to
405b44b
Compare
b74692c
to
8b5fb92
Compare
@kadel forgot to add the debug port config in the env variable, will add that ASAP. rest can be tested |
I'm confused. How this can be used?
@girishramnani how did you test it? Even running it as |
When a component is created on the cluster (during odo push), the DEBUG_PORT env variable needs to be populated based on DebugPort config |
b64a4de
to
2daba90
Compare
@kadel added debug_port in the env variable list |
@girishramnani Once the pr is ready i will review and verify it with respect to test. |
@amitkrout @kadel added odo debug tests |
pkg/debug/portforward.go
Outdated
k8sgenclioptions "k8s.io/kubernetes/pkg/kubectl/genericclioptions" | ||
) | ||
|
||
type PortForwarder interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a comment explaining what is a purpose of this interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment doesn't provide much more clarification than the title itself :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove the interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done removed
@kadel seeing this error on travis CI.
and this is not showing up locally |
/test v4.2-integration |
script: | ||
- ./scripts/oc-cluster.sh | ||
- make bin | ||
- sudo cp odo /usr/bin | ||
- odo login -u developer | ||
- travis_wait make test-cmd-pref-config | ||
- travis_wait make test-cmd-url | ||
- travis_wait make test-cmd-debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for name test-cmd-debug
tests/integration/cmd_debug_test.go
Outdated
helper.CmdShouldPass("odo", "push", "--context", context) | ||
|
||
go func() { | ||
helper.CmdShouldRunWithTimeout(20*time.Second, "odo", "debug", "port-forward", "--local-port", "5050", "--context", context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@girishramnani Can you please explain the background of this command, i mean what it does while executing the debug command with a timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comment on the function explains it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ odo debug port-forward -h
Forward a local port to a remote port on the pod where the application is listening for a debugger.
By default the local port and the remote port will be same but that can be changed using --local-port.
Usage:
odo debug port-forward [flags]
Examples:
# Listen on default port on all addresses, forwarding to the default port in the pod
odo debug port-forward
# Listen on the 5000 port locally, forwarding to default port in the pod
odo debug port-forward --local-port 5000
Flags:
[...]
Global Flags:
[...]
@girishramnani you have only implemented one scenario. Can you implement the missing scenario in integration test.
BeforeEach(func() { | ||
SetDefaultEventuallyTimeout(10 * time.Minute) | ||
SetDefaultConsistentlyDuration(30 * time.Second) | ||
context = helper.CreateNewContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@girishramnani Update the global config path, like we have done in other test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
// This is before every spec (It) | ||
BeforeEach(func() { | ||
SetDefaultEventuallyTimeout(10 * time.Minute) | ||
SetDefaultConsistentlyDuration(30 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, IMO keeping failure timeout won't hurt us though there is no failure command test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@girishramnani No doc reference found for this feature. Can you please add a doc reference of how to uses it, what are the parameters need to be taken care, how to disable/enable it etc..
|
pkg/odo/cli/debug/portforward.go
Outdated
} | ||
}() | ||
|
||
req := o.Client.BuildPortForwardReq(pod.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasoning same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
}() | ||
|
||
// debug port | ||
helper.HttpWaitForWithStatus("http://localhost:5858", "WebSockets request was expected", 12, 5, 400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments here to describe why are we expecting 400 in this test scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
if err != nil { | ||
return err | ||
} | ||
transport, upgrader, err := spdy.RoundTripperFor(conf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe some comments explaining the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RoundTripperFor
has comments to explain it
We discussed this with @girishramnani. We couldn't come up with easy way how to test this for Java component, we settled down on just NodeJS for now. The issue was that we don't know how to verify that there actually is a Java debugger on the other side without introducing new dependencies into the tests.
@amitkrout Do you think that it would make sense to have such test? Not sure if will actually test something :-( Compared to NodeJS one where at least we can verify that there is something using WebSockets |
/approve but @mik-dass and @amitkrout still have some good points, that need to be addressed. Leaving the rest of the discussion up to you @mik-dass and @amitkrout. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kadel The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I can think about adding java tests in a follow up PR. |
@girishramnani TBH i was not aware of java test complexity, however as per @kadel suggestion atleast we can add the basic java scenario. |
I would prefer to add that in a follow up PR |
Anyway way you have some more review comment to address, so in the mean time you can try basic java scenario ;) or else i won't mind if you take this in a very next pr. |
resolved all comments other then adding tests @amitkrout, I will add java tests in a follow up PR |
opened a follow up issue #2153 @amitkrout |
resolved all your comments @mik-dass |
} | ||
|
||
if pod.Status.Phase != corev1.PodRunning { | ||
return fmt.Errorf("unable to forward port because pod is not running. Current status=%v", pod.Status.Phase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the pod is not running then
[mrinaldas@localhost nodejs-ex]$ odo debug port-forward
Started port forwarding at ports - 5858:5858
✗ unable to forward port because pod is not running. Current status=Pending
the output looks weird as first it says started port forwarding started and then crashes, maybe a helper function for checking and then starting port forward?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, resolving
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
works for me, cool stuff 👍
What is the purpose of this change? What does it change?
see $SUBJECT
Need to consider having a
debug
branch in theopenshift/odo
repo for merging all debug command PRsNote: very early PR so that any issue can be caught early.
Was the change discussed in an issue?
fixes #2012
How to test changes?
then follow https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_setting-up-an-attach-configuration in VS code
or