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

fix(deps): update to gcp-metadata and address envDetect performance issues #787

Merged
merged 3 commits into from Sep 17, 2019

Conversation

bcoe
Copy link
Contributor

@bcoe bcoe commented Sep 17, 2019

This pulls in an updated version of gcp-metadata which checks both IP and HOST; failing fast as soon as one of the endpoints fails to respond (this addresses issues with cloud run, vs., local environment).

Since only gcpMetadata.isAvailable() is currently fast pathed, this also performs a slight refactor on environment detection, we first detect isComputeEngine() hitting isAvailable, if we detect that we are in a compute engine environment, we next check if we're in kubernetes.

This results in one additional check, but improves cold-start performance in non-GCP environments drastically.

TODO: confirm with @JustinBeckwith, @stephenplusplus, etc., that gcpMetadata.isAvailable() is true for kubernetes.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 17, 2019
} else if (await isComputeEngine()) {
env = GCPEnv.COMPUTE_ENGINE;
if (await isKubernetesEngine()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we end up performing one more check for kubernetes, but we use the fast path gcpMetadata.isAvailable rather than the slow gcpMetadata.instance('attributes/cluster-name') for the initial check, correcting issues with @nodejs/logging performance.

@bcoe bcoe changed the title fix(deps): update to gcp-metadata that does not throw locally fix(deps): update to gcp-metadata and address envDetect performance issues Sep 17, 2019
@codecov
Copy link

codecov bot commented Sep 17, 2019

Codecov Report

Merging #787 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #787   +/-   ##
=======================================
  Coverage   84.34%   84.34%           
=======================================
  Files          17       17           
  Lines         952      952           
  Branches      211      211           
=======================================
  Hits          803      803           
  Misses         88       88           
  Partials       61       61
Impacted Files Coverage Δ
src/auth/envDetect.ts 89.28% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1d6718...c109d27. Read the comment docs.

@bcoe
Copy link
Contributor Author

bcoe commented Sep 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants