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

#682 APP_PORT not injected into app container #685

Merged
merged 12 commits into from
Jun 5, 2022

Conversation

akhilac1
Copy link
Contributor

@akhilac1 akhilac1 commented Jun 4, 2022

Signed-off-by: akhilac1 chetlapalle.akhila@gmail.com

Description

  1. Added default value for APP_PORT in case it cannot be fetched from environment variables
  2. Updated yaml to include addition of environment variable for APP_PORT [ until the dapr.io/app_port annotation issue is fixed dapr.io/app_port annotation does not get injected into environment variable in K8s mode #684 ]
  3. Default command to run the app in observability quickstart ALWAYS uses port 5000. Updated quickstarts/tutorials/observability/python/Dockerfile to use python3 app.py as launch command and use specified port

Issue reference

We strive to have all PRs being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #682

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • The quickstart code compiles correctly
  • You've tested new builds of the quickstart if you changed quickstart code
  • You've updated the quickstart's README if necessary
  • If you have changed the steps for a quickstart be sure that you have updated the automated validation accordingly. All of our quickstarts have annotations that allow them to be executed automatically as code. For more information see mechanical-markdown. For user guide with examples see Examples.

akhilac1 and others added 8 commits June 4, 2022 12:59
Signed-off-by: akhilac1 <chetlapalle.akhila@gmail.com>
Signed-off-by: akhilac1 <chetlapalle.akhila@gmail.com>
Signed-off-by: akhilac1 <chetlapalle.akhila@gmail.com>
…lac1/quickstarts into hotfix_quickstarts_app_port

Signed-off-by: akhilac1 <chetlapalle.akhila@gmail.com>
Signed-off-by: akhilac1 <chetlapalle.akhila@gmail.com>
Signed-off-by: akhilac1 <chetlapalle.akhila@gmail.com>
@akhilac1
Copy link
Contributor Author

akhilac1 commented Jun 4, 2022

@paulyuk @msfussell @berndverst - The ubuntu tutorials are failing due to python app in distributed calculator. This app needs the updated docker image to pass - since the existing docker image uses flask and the app never comes up on 5001. It works on my local test with updated Docker image. My understanding is that test does not build Docker files - rather it is using old Docker file in which case this test would not pass until the image is updated.
Also am unable to fix the DCO error due to merge conflicts [ added and reverted some code]. Can this be overridden by the maintainer and merged?

Attaching my local execution log for reference -
distributedCaculator_multiplyPod.txt

@paulyuk
Copy link
Contributor

paulyuk commented Jun 5, 2022

Hi @akhilac1 - thank you for this. The DCO issue is separate from the Docker build and push to registry. For DCO I suggest you do every commit via a git commit -s -p or at least -s as a part of your commit. This will sign with DCO and pass that. I will sign it this time. Also you're right there's a chicken and egg problem here. The action as written needs the docker images for python, distribute calculator, etc published to GHCR before the tests will pass. So basically we test these in prod, and rely on the review to decide if we should let it in. I will do that now.

Copy link
Contributor

@paulyuk paulyuk left a comment

Choose a reason for hiding this comment

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

Hi - just a few things to look at please. thank you for updating all this.

console.log('[error]: --app-port is not set. Re-run dapr run with -p or --app-port.\nUsage: https://docs.dapr.io/getting-started/quickstarts/pubsub-quickstart/\n');
process.exit(1);
}
const APP_PORT = process.env.APP_PORT || 5001;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const APP_PORT = process.env.APP_PORT || 5001;
const APP_PORT = process.env.APP_PORT ?? '5001';

Prefer we use ?? operator which covers more cases for false that come up in Javascript. I. believe we want port to be a string too.

tutorials/bindings/nodeapp/app.js Outdated Show resolved Hide resolved
tutorials/distributed-calculator/node/app.js Outdated Show resolved Hide resolved
@@ -32,4 +30,4 @@ def multiply():
print(f"Calculating {operand_one} * {operand_two}", flush=True)
return jsonify(math.ceil(operand_one * operand_two * 100000)/100000)

app.run(port=appPort)
app.run(host="0.0.0.0",port=appPort)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need "0.0.0.0" host ip?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulyuk - to make the value being used explicit.

tutorials/hello-world/node/app.js Outdated Show resolved Hide resolved
@@ -37,4 +35,4 @@ def multiply():
print(f"Calculating {operand_one} * {operand_two}", flush=True)
return jsonify(math.ceil(operand_one * operand_two * 100000)/100000)

app.run(port)
app.run(host="0.0.0.0",port=port)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking we need to set host?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulyuk - It is not mandatory. This makes the value being used explicit.

Copy link
Contributor

Choose a reason for hiding this comment

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

@akhilac1 ok, I just want to make sure that still works in a few environments that might have benefited from defaults. E.g. have you tried this on Windows, WSL, and Mac? have you tried with Ipv6?

The other way to ask is are we fixing a problem with this change? if not we might have lower risk of regressions by not making the change, since this has worked this way for a few years.

Copy link
Contributor

Choose a reason for hiding this comment

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

That said, I'll take it and let's monitor

akhilac1 and others added 4 commits June 5, 2022 18:43
Co-authored-by: Paul Yuknewicz <paulyuk@microsoft.com>
Co-authored-by: Paul Yuknewicz <paulyuk@microsoft.com>
Co-authored-by: Paul Yuknewicz <paulyuk@microsoft.com>
Co-authored-by: Paul Yuknewicz <paulyuk@microsoft.com>
Copy link
Contributor

@paulyuk paulyuk left a comment

Choose a reason for hiding this comment

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

LGTM

@paulyuk
Copy link
Contributor

paulyuk commented Jun 5, 2022

Tests are all clean except for Validate Tutorials which is expected. I'm merging.

@paulyuk paulyuk merged commit 2f37181 into dapr:master Jun 5, 2022
@yaron2 yaron2 added this to the 1.8 milestone Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants