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

change debugport in container if its different from env_info #4785

Merged

Conversation

girishramnani
Copy link
Contributor

@girishramnani girishramnani commented Jun 8, 2021

What type of PR is this?
/kind bug

What does this PR do / why we need it:
change debugport in container if its different from env_info, also added debug command for converted devfiles.

Which issue(s) this PR fixes:

Fixes #4615

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

  • Update changelog

  • I have read the test guidelines

How to test changes / Special notes to the reviewer:

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 8, 2021
Comment on lines +215 to +219
for i, envVar := range container.Env {
if envVar.Name == adaptersCommon.EnvDebugPort {
if envVar.ValueFrom == nil && (envVar.Value != strconv.Itoa(devfileDebugPort)) {
container.Env[i].Value = strconv.Itoa(devfileDebugPort)
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Copy link
Contributor

@mik-dass mik-dass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 10, 2021
@girishramnani
Copy link
Contributor Author

@mik-dass the lgtmer has to approve also, please can approve it as well.

@mik-dass
Copy link
Contributor

@mik-dass the lgtmer has to approve also, please can approve it as well.

I think, in a recent discussion, it was decided to have two reviewers on each PR.

@girishramnani
Copy link
Contributor Author

@mik-dass the lgtmer has to approve also, please can approve it as well.

I think, in a recent discussion, it was decided to have two reviewers on each PR.

Ack, thank you for reminding

@dharmit
Copy link
Member

dharmit commented Jun 11, 2021

@girishramnani I followed the below steps:

$ git clone https://github.com/odo-devfiles/nodejs-ex
$ cd nodejs-ex
$ odo create --s2i nodejs node-s2i

$ odo env set DebugPort 8888
$ cat .odo/env/env.yaml
ComponentSettings:
  Name: node-s2i
  Project: myproject
  AppName: app
  DebugPort: 8888
  RunMode: run

$ odo push

$ odo exec -- env | grep DEBUG
DEBUG_PORT=5858

$ grep DEBUG_PORT devfile.yaml
    - name: DEBUG_PORT
      value: "5858"

There are two concerns I have:

  • Pushed component's env var still shows 5858 as the DebugPort
  • devfile contains 5858 as the value for DEBUG_PORT

DebugPort and DEBUG_PORT are the same things, right? Or am I looking at this the wrong way?

Am I testing this the right way?

cc @kadel

@dharmit
Copy link
Member

dharmit commented Jun 11, 2021

DebugPort and DEBUG_PORT are the same things, right? Or am I looking at this the wrong way?

#4615 (comment) gives me an impression that these two are different things. 😕

@girishramnani
Copy link
Contributor Author

@girishramnani I followed the below steps:

$ git clone https://github.com/odo-devfiles/nodejs-ex
$ cd nodejs-ex
$ odo create --s2i nodejs node-s2i

$ odo env set DebugPort 8888
$ cat .odo/env/env.yaml
ComponentSettings:
  Name: node-s2i
  Project: myproject
  AppName: app
  DebugPort: 8888
  RunMode: run

$ odo push

$ odo exec -- env | grep DEBUG
DEBUG_PORT=5858

$ grep DEBUG_PORT devfile.yaml
    - name: DEBUG_PORT
      value: "5858"

There are two concerns I have:

  • Pushed component's env var still shows 5858 as the DebugPort
  • devfile contains 5858 as the value for DEBUG_PORT

DebugPort and DEBUG_PORT are the same things, right? Or am I looking at this the wrong way?

Am I testing this the right way?

cc @kadel

@dharmit the debug port only gets changed in devfile when you provide odo push --debug.

You can still see the debug port in the env because its part of the original env of the s2i and gets passed to the devfile.

Please follow the same steps but with odo push --debug and you will see that the debug port gets changed in the pod.

@dharmit
Copy link
Member

dharmit commented Jun 11, 2021

@dharmit the debug port only gets changed in devfile when you provide odo push --debug.
You can still see the debug port in the env because its part of the original env of the s2i and gets passed to the devfile.
Please follow the same steps but with odo push --debug and you will see that the debug port gets changed in the pod.

That works. But should we also change the DEBUG_PORT value in devfile.yaml when user does odo env set DebugPort? I am asking this because there are different values (and even different naming style - DEBUG_PORT vs. DebugPort) for debug port in devfile vs. that in env.yaml.

I think env.yaml is for environment specific information and it can have values different from devfile. But I would like to be sure.

@dharmit
Copy link
Member

dharmit commented Jun 11, 2021

@dharmit the debug port only gets changed in devfile when you provide odo push --debug.

From UX perspective, how do we convey this to the user that they must do odo push --debug for this env var value to actually take effect in the component? Or should the user be aware of it already since odo push --debug is the only way to start the component in debug mode?

@girishramnani
Copy link
Contributor Author

@dharmit the debug port only gets changed in devfile when you provide odo push --debug.

From UX perspective, how do we convey this to the user that they must do odo push --debug for this env var value to actually take effect in the component? Or should the user be aware of it already since odo push --debug is the only way to start the component in debug mode?

This been a standard set in devfile already since a while now

@girishramnani
Copy link
Contributor Author

@dharmit the debug port only gets changed in devfile when you provide odo push --debug.
You can still see the debug port in the env because its part of the original env of the s2i and gets passed to the devfile.
Please follow the same steps but with odo push --debug and you will see that the debug port gets changed in the pod.

That works. But should we also change the DEBUG_PORT value in devfile.yaml when user does odo env set DebugPort? I am asking this because there are different values (and even different naming style - DEBUG_PORT vs. DebugPort) for debug port in devfile vs. that in env.yaml.

I think env.yaml is for environment specific information and it can have values different from devfile. But I would like to be sure.

Technically you can but changing debug port from what it is using odo env set DebugPort probably feels like it should affect env.yml and doesn’t get persisted to devfile.

its feels more of a tool to override the value in devfile for your local setup only?

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jun 13, 2021
@openshift-ci openshift-ci bot removed lgtm Indicates that a PR is ready to be merged. Required by Prow. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. labels Jun 13, 2021
@dharmit
Copy link
Member

dharmit commented Jun 14, 2021

@dharmit the debug port only gets changed in devfile when you provide odo push --debug.

Not sure if I'm nitpicking here. Let me know if so.

When I do odo push --debug, the debugport env does reflect correctly in the pod. But devfile still shows 5858. Based on above comment, I expected it to change in devfile as well. Or is that a wrong expectation?

@dharmit
Copy link
Member

dharmit commented Jun 14, 2021

@dharmit the debug port only gets changed in devfile when you provide odo push --debug.

From UX perspective, how do we convey this to the user that they must do odo push --debug for this env var value to actually take effect in the component? Or should the user be aware of it already since odo push --debug is the only way to start the component in debug mode?

This been a standard set in devfile already since a while now

OK. I find it unintuitive that user isn't notified about using odo push --debug. I'm not sure if this is something we should cover in the docs or in the cli messaging.

Just to be clear, I don't mean we address it in this PR. We should do it separately.

@dharmit
Copy link
Member

dharmit commented Jun 14, 2021

Technically you can but changing debug port from what it is using odo env set DebugPort probably feels like it should affect env.yml and doesn’t get persisted to devfile.

Agree. odo env commands shouldn't touch anything in devfile. That would be an even bigger problem. 👍🏾

@dharmit
Copy link
Member

dharmit commented Jun 14, 2021

/approve
/lgtm

Doing both since lgtm was removed by rebase - #4785 (comment)

/override ci/prow/psi-unit-test-mac

@openshift-ci
Copy link

openshift-ci bot commented Jun 14, 2021

@dharmit: Overrode contexts on behalf of dharmit: ci/prow/psi-unit-test-mac

In response to this:

/approve
/lgtm

Doing both since lgtm was removed by rebase - #4785 (comment)

/override ci/prow/psi-unit-test-mac

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 14, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jun 14, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dharmit

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Jun 14, 2021
@openshift-merge-robot openshift-merge-robot merged commit a08eec3 into redhat-developer:main Jun 14, 2021
@girishramnani girishramnani deleted the debug_port_fix branch June 14, 2021 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

odo env set DebugPort doesn't work for converted devfile
4 participants