Skip to content

Commit

Permalink
Update worker-manager dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lotas committed Apr 29, 2024
1 parent 9f493c5 commit 926f11b
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 21 deletions.
6 changes: 6 additions & 0 deletions changelog/issue-6761.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
audience: developers
level: patch
reference: issue 6761
---

Switching from `googleapis` package to a smaller `@googleapis/*` libraries to reduce startup time and avoid loading APIs we don't use.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"@azure/ms-rest-azure-js": "^2.0.1",
"@azure/ms-rest-js": "^2.6.6",
"@azure/ms-rest-nodeauth": "^3.0.5",
"@google-cloud/compute": "^4.4.0",
"@google-cloud/iam-credentials": "^3.2.0",
"@googleapis/compute": "^10.0.0",
"@googleapis/iam": "^16.0.0",
"@graphql-tools/schema": "^10.0.3",
"@octokit/auth-app": "^4.0.7",
"@octokit/core": "^3.0.0",
Expand Down
11 changes: 6 additions & 5 deletions services/worker-manager/src/providers/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import slugid from 'slugid';
import _ from 'lodash';
import taskcluster from 'taskcluster-client';
import * as uuid from 'uuid';
import { google } from 'googleapis';
import gcpCompute from '@googleapis/compute';
import gcpIam from '@googleapis/iam';
import { ApiError, Provider } from './provider.js';
import { CloudAPI } from './cloudapi.js';
import { WorkerPool, Worker } from '../data.js';
Expand Down Expand Up @@ -64,20 +65,20 @@ export class GoogleProvider extends Provider {
}

this.ownClientEmail = creds.client_email;
const client = google.auth.fromJSON(creds);
const client = gcpCompute.auth.fromJSON(creds);
client.scopes = [
'https://www.googleapis.com/auth/compute', // For configuring instance templates, groups, etc
'https://www.googleapis.com/auth/iam', // For fetching service account name
];
this.compute = google.compute({
this.compute = gcpCompute.compute({
version: 'v1',
auth: client,
});
this.iam = google.iam({
this.iam = gcpIam.iam({
version: 'v1',
auth: client,
});
this.oauth2 = new google.auth.OAuth2();
this.oauth2 = new gcpCompute.auth.OAuth2();
}

async setup() {
Expand Down
9 changes: 5 additions & 4 deletions services/worker-manager/test/fakes/google.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { FakeCloud } from './fake.js';
import { strict as assert } from 'assert';
import slugid from 'slugid';
import { google } from 'googleapis';
import google from '@googleapis/compute';
import gcpIam from '@googleapis/iam';

const WORKER_SERVICE_ACCOUNT_ID = '12345';
const PROJECT = 'testy';
Expand All @@ -10,8 +11,8 @@ const PROJECT = 'testy';
* Fake the Google SDK.
*
* This fakes `google.auth`, `google.compute`, where `google` is imported from the
* `googleapis` package. The results of the fake `google.compute()` and
* `google.iam()` calls are `fake.compute` and `fake.iam`.
* `@googleapis/compute` package. The results of the fake `google.compute()` and
* `gcpIam.iam()` calls are `fake.compute` and `fake.iam`.
*
* The `google.auth.OAuth2` class is defined by the `FakeOAuth2` class below, and
* the instance returned from the constructor is available at `fake.oauth2`.
Expand Down Expand Up @@ -45,7 +46,7 @@ export class FakeGoogle extends FakeCloud {
return this.compute;
});

this.sinon.stub(google, 'iam').callsFake(({ version, auth }) => {
this.sinon.stub(gcpIam, 'iam').callsFake(({ version, auth }) => {
assert.equal(version, 'v1');
assert(auth.fake);
assert.deepEqual(auth.scopes, [
Expand Down
80 changes: 69 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1503,15 +1503,6 @@ __metadata:
languageName: node
linkType: hard

"@google-cloud/compute@npm:^4.4.0":
version: 4.4.0
resolution: "@google-cloud/compute@npm:4.4.0"
dependencies:
google-gax: "npm:^4.0.3"
checksum: 10c0/c21a84d78f0018a4d4c16aa25580b84ff2865f4a9a559fab41bae31a2bf5355cc5118b1c3e986e0ee9a64fb3260a61a49b59d531650a6417e51af89f36d632ed
languageName: node
linkType: hard

"@google-cloud/iam-credentials@npm:^3.2.0":
version: 3.2.0
resolution: "@google-cloud/iam-credentials@npm:3.2.0"
Expand All @@ -1521,6 +1512,24 @@ __metadata:
languageName: node
linkType: hard

"@googleapis/compute@npm:^10.0.0":
version: 10.0.0
resolution: "@googleapis/compute@npm:10.0.0"
dependencies:
googleapis-common: "npm:^7.0.0"
checksum: 10c0/8291c14a6d8c3016fa359e01b4b2d29c15403d7fb6c55f517804b0d1c6f2a3c899666997cb16c95aa1d991bb9f5a5a43733b5de4d71982a25deadc03dd1c51fd
languageName: node
linkType: hard

"@googleapis/iam@npm:^16.0.0":
version: 16.0.0
resolution: "@googleapis/iam@npm:16.0.0"
dependencies:
googleapis-common: "npm:^7.0.0"
checksum: 10c0/2cb7478294455c44b60252fd36e12b345c5209f54193234b571347317168010ae64a18c5cd4c789c92c2693c63b87229dfc08622f8be5e0947986e2078026334
languageName: node
linkType: hard

"@graphql-tools/merge@npm:^8.4.1":
version: 8.4.2
resolution: "@graphql-tools/merge@npm:8.4.2"
Expand Down Expand Up @@ -6519,6 +6528,19 @@ __metadata:
languageName: node
linkType: hard

"gaxios@npm:^6.0.3":
version: 6.5.0
resolution: "gaxios@npm:6.5.0"
dependencies:
extend: "npm:^3.0.2"
https-proxy-agent: "npm:^7.0.1"
is-stream: "npm:^2.0.0"
node-fetch: "npm:^2.6.9"
uuid: "npm:^9.0.1"
checksum: 10c0/4c377ab27045aef82228dd41c81c53cf4c0c8de848065a150b82912979bd4f0a804d1270c6a98557f8a37a6c227254b51f7767d80a85baaa866f2c4fa9a7778a
languageName: node
linkType: hard

"gcp-metadata@npm:^6.1.0":
version: 6.1.0
resolution: "gcp-metadata@npm:6.1.0"
Expand Down Expand Up @@ -6711,6 +6733,20 @@ __metadata:
languageName: node
linkType: hard

"google-auth-library@npm:^9.7.0":
version: 9.9.0
resolution: "google-auth-library@npm:9.9.0"
dependencies:
base64-js: "npm:^1.3.0"
ecdsa-sig-formatter: "npm:^1.0.11"
gaxios: "npm:^6.1.1"
gcp-metadata: "npm:^6.1.0"
gtoken: "npm:^7.0.0"
jws: "npm:^4.0.0"
checksum: 10c0/4dcd2b3542fb8cf68db00c46b65a386bdfdc3e4f6e626197e497fe9fbc1b92d9ea1ff2c28fcfe9653a79828e5cc90f904afbb48a6b189e19ea54d209c71efbd6
languageName: node
linkType: hard

"google-gax@npm:^4.0.3":
version: 4.3.1
resolution: "google-gax@npm:4.3.1"
Expand All @@ -6731,6 +6767,20 @@ __metadata:
languageName: node
linkType: hard

"googleapis-common@npm:^7.0.0":
version: 7.1.0
resolution: "googleapis-common@npm:7.1.0"
dependencies:
extend: "npm:^3.0.2"
gaxios: "npm:^6.0.3"
google-auth-library: "npm:^9.7.0"
qs: "npm:^6.7.0"
url-template: "npm:^2.0.8"
uuid: "npm:^9.0.0"
checksum: 10c0/6ef780c3b26a41cb4d4934978271c39154264d1843901021593c4ef72f9fce02bfbab6a837bf45019ce1612cab3c57f1742da5f28ce50e0f4d1ff22404d8b45e
languageName: node
linkType: hard

"gopd@npm:^1.0.1":
version: 1.0.1
resolution: "gopd@npm:1.0.1"
Expand Down Expand Up @@ -10114,7 +10164,7 @@ __metadata:
languageName: node
linkType: hard

"qs@npm:^6.12.0":
"qs@npm:^6.12.0, qs@npm:^6.7.0":
version: 6.12.1
resolution: "qs@npm:6.12.1"
dependencies:
Expand Down Expand Up @@ -11738,8 +11788,9 @@ __metadata:
"@azure/ms-rest-azure-js": "npm:^2.0.1"
"@azure/ms-rest-js": "npm:^2.6.6"
"@azure/ms-rest-nodeauth": "npm:^3.0.5"
"@google-cloud/compute": "npm:^4.4.0"
"@google-cloud/iam-credentials": "npm:^3.2.0"
"@googleapis/compute": "npm:^10.0.0"
"@googleapis/iam": "npm:^16.0.0"
"@graphql-tools/schema": "npm:^10.0.3"
"@octokit/auth-app": "npm:^4.0.7"
"@octokit/core": "npm:^3.0.0"
Expand Down Expand Up @@ -12275,6 +12326,13 @@ __metadata:
languageName: node
linkType: hard

"url-template@npm:^2.0.8":
version: 2.0.8
resolution: "url-template@npm:2.0.8"
checksum: 10c0/56a15057eacbcf05d52b0caed8279c8451b3dd9d32856a1fdd91c6dc84dcb1646f12bafc756b7ade62ca5b1564da8efd7baac5add35868bafb43eb024c62805b
languageName: node
linkType: hard

"util-deprecate@npm:^1.0.1, util-deprecate@npm:~1.0.1":
version: 1.0.2
resolution: "util-deprecate@npm:1.0.2"
Expand Down

0 comments on commit 926f11b

Please sign in to comment.