googleapis / nodejs-common

🚀🐢 A set of classes and utilities used in Google npm modules.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing projectId after upgrading to 0.16.0

nolanmar511 opened this issue · comments

Environment details

  • OS: Linux (running on GCE instance)
  • Node.js version: 8.9.4
  • npm version: 5.6.0
  • @google-cloud/common version: 0.16.0

Steps to reproduce

I updated the version of google-cloud/common to 0.16.0 in google-cloud/profiler (repo here). Then when running the profiler on a GCE instance without specifying the projectId, I got this error message:

Error: Sorry, we cannot connect to Cloud Services without a project ID. You may specify one with an environment variable named "GCLOUD_PROJECT". See https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/authentication for a detailed guide on creating an authenticated connection.

I switched the version back to 0.15.1 of google-cloud/common and no longer saw this error.

I'm not sure if this is an intended change with the latest release, but it felt surprising to me.

Did the 0.16.0 release have a version bump of the google-auth-library? From version x? to y?

It looks like google-auto-auth stayed on google-auth-library 0.12.0 through this release, so I'm not sure if this was a change down there that started causing it.

From 0.15.1 to 0.16, we went from using google-auto-auth@^0.8 to ^0.9. In that span, google-auto-auth only had one commit: stephenplusplus/google-auto-auth@423cf05

It looks like this is what is eventually given to google-auto-auth: https://github.com/GoogleCloudPlatform/cloud-profiler-nodejs/blob/4417ff5ba7e33db788aafb2cb6906b0af6855718/ts/src/index.ts#L59-- what value is that on GCE? If it's a project ID, g-a-a should use that. If it's nothing, g-a-a tries to get the project ID from google-auth-library in the same way it did in 0.8. So, I'm not able to see yet the trouble that linked commit causes.

And just to confirm, 0.15.1 works? Could your local install have pulled from cache and got 0.15.0? Because there was a much bigger change between 0.15.0 and 0.15.1, when we went from google-auto-auth@^0.7 to 0.8. In 0.8, we started using a new method from google-auth-library, "getCredentials()". We have another issue where that method might be the problem: googleapis/nodejs-logging#53 (comment):

@ofrobots I would guess that this problem relates to google-auto-auth and/or google-auth-library. In @google-cloud/logging 1.1.1, we used google-auto-auth@^0.7.1. In 1.1.2 (when the problem originates), we use google-auto-auth@^0.9.0. In that release span, g-a-a started using google-auth-library's "getCredentials" method. Is it possible that method doesn't support GKE environments?

Just confirmed -- 0.15.1 works, and 0.16.0 does not.

This is the diff from my package-lock.json when upgrading from 0.15.1 to 0.16.0:

 "dependencies": {
     "@google-cloud/common": {
-      "version": "0.15.1",
-      "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.15.1.tgz",
-      "integrity": "sha512-cnVtHLvyiSQvb1RzXWDp7PA1sA8Jmc47+wp/xwHwdGOlQZfKog5iluZ0C/LB8iklFXpcTwlNMorqLu
Z/qH0DDA==",
+      "version": "0.16.0",
+      "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.16.0.tgz",
+      "integrity": "sha512-ApY0Qcmjt48i1SyScskKzU/VGYVtBzWD98ylQvmw/GjRwPu/fB/3Z2WX5MCdgV9/EjgjNBN3hVDraQ
bzRe0rHg==",
       "requires": {
         "array-uniq": "1.0.3",
         "arrify": "1.0.1",
@@ -16,7 +16,7 @@
         "duplexify": "3.5.3",
         "ent": "2.2.0",
         "extend": "3.0.1",
-        "google-auto-auth": "0.8.2",
+        "google-auto-auth": "0.9.3",
         "is": "3.2.1",
         "log-driver": "1.2.5",
         "methmeth": "1.1.0",
@@ -1121,25 +1121,14 @@
       }
     },
     "google-auto-auth": {
-      "version": "0.8.2",
-      "resolved": "https://registry.npmjs.org/google-auto-auth/-/google-auto-auth-0.8.2.tgz",
-      "integrity": "sha512-W91J1paFbyG45gpDWdTu9tKDxbiTDWYkOAxytNVF4oHVVgTCBV/8+lWdjj/6ldjN3eb+sEd9PKJBjm0kmCxvcw==",
+      "version": "0.9.3",
+      "resolved": "https://registry.npmjs.org/google-auto-auth/-/google-auto-auth-0.9.3.tgz",
+      "integrity": "sha512-TbOZZs0WJOolrRmdQLK5qmWdOJQFG1oPnxcIBbAwL7XCWcv3XgZ9gHJ6W4byrdEZT8TahNFgMfkHd73mqxM9dw==",
       "requires": {
         "async": "2.6.0",
-        "gcp-metadata": "0.3.1",
+        "gcp-metadata": "0.4.1",
         "google-auth-library": "0.12.0",
         "request": "2.83.0"
-      },
-      "dependencies": {
-        "gcp-metadata": {
-          "version": "0.3.1",
-          "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-0.3.1.tgz",
-          "integrity": "sha512-5kJPX/RXuqoLmHiOOgkSDk/LI0QaXpEvZ3pvQP4ifjGGDKZKVSOjL/GcDjXA5kLxppFCOjmmsu0Uoop9d1upaQ==",
-          "requires": {
-            "extend": "3.0.1",
-            "retry-request": "3.3.1"
-          }
-        }
       }
     },

Thank you for that! Is it possible for you to show a small script I can run on GCE to see the error? I'm not very familiar with the profiling library.

This is the script I'm running:

const profiler = require(@google-cloud/profiler).start({
  serviceContext: {
    service: 'service',
  }
});

function busy() {
   setTimeout(busy, 1000);
}

busy();

Reproduced and found a fix. PR coming shortly.

@stephenplusplus is this in google-auto-auth, or google-auth-library?

PR sent #32