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

Go os.LookupEnv is not working as expected #19

Closed
franck-boullier opened this issue Feb 3, 2020 · 3 comments
Closed

Go os.LookupEnv is not working as expected #19

franck-boullier opened this issue Feb 3, 2020 · 3 comments

Comments

@franck-boullier
Copy link
Member

Overview:

We need variables that are stored in the AWS parameter store.
Getting these variables can take a lot of time up to the point where some tests are timing out.
The solution is to declare these variables as environment variables <-- avoid costly AWS Parameter store queries.

The aws.env script:

In PR #16 we have created a bash script aws.env. That script's ONLY objective is to optimize our code --> avoid querying the AWS parameter store again and again.

See how it work in the Travis CI build of the unit repo (WIP)

You can see that the environment variables are correctly set in the OS:
image

The problem:

We are using the go module/package os and the function os.LookupEnv in our main.go file (see an example here).

Expected result:

Since the Environment variable (ex: BUGZILLA_DB_USER) has been set, there should be NO NEED for a call to the AWS parameter store.
The INFO on the Travis CI build should be something like
"BUGZILLA_DB_USER overridden by local env: xxxx"

Actual result:

The message in the travis build is
INFO[0002] BUGZILLA_DB_USER is unset as an environment variable. The value is **bugzilla** in AWS Parameter store

This tells us that the main.go script had to query AWS to get that variable <-- NOT GOOD

See screenshot from the Travis CI build
image

Context:

In the current PR #16 to facilitate and speed up debugging, we have temporarily imported some of the code that will eventually be part of the uneet/env repo.
The key functions we need and that are supposed to be in the uneet/env repo are:

@kaihendry
Copy link
Contributor

Where are you intending to optimise these parameter store lookups?

  • when the function is run?
  • on CI?
  • on go test? Can you show a build where this is slow?

When the function is run probably makes the most sense and you can set that with up env. But then you would need to build this into the deployment process.

@franck-boullier
Copy link
Member Author

Where are you intending to optimize these parameter store lookups?

Ideally each time the function has to run (but I don't know how to do that yet, still experimenting so any idea/suggestion is welcomed 😅

@franck-boullier
Copy link
Member Author

The solution was to declare ./aws.env as the source for the variables in the .travis.yml file.

See b156eea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants