Skip to content

Commit

Permalink
[server, bridge] Bump grpc-js and authzed clients (#19849)
Browse files Browse the repository at this point in the history
* [yarn] Bump @grpc/grpc-js to 1.10.8 and @authzed/authzed-node to 0.15.0

* [server] SpiceDB: explicit re-try on UNAVAILABLE

We tried to configured this inside the SpiceDBClientProvider already, but somehow it still surfaced.

* [server, bridge] Configure "grpc.dns_min_time_between_resolutions_ms" to be 2s instead of 30s
  • Loading branch information
geropl authored Jun 6, 2024
1 parent c1a18a3 commit 2686bc2
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 75 deletions.
2 changes: 1 addition & 1 deletion components/content-service-api/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lib"
],
"dependencies": {
"@grpc/grpc-js": "1.9.1",
"@grpc/grpc-js": "1.10.8",
"google-protobuf": "^3.19.1",
"inversify": "^6.0.1",
"opentracing": "^0.14.4"
Expand Down
2 changes: 1 addition & 1 deletion components/gitpod-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"src"
],
"devDependencies": {
"@grpc/grpc-js": "1.9.1",
"@grpc/grpc-js": "1.10.8",
"@testdeck/mocha": "^0.3.3",
"@types/analytics-node": "^3.1.9",
"@types/chai-subset": "^1.3.3",
Expand Down
2 changes: 2 additions & 0 deletions components/gitpod-protocol/src/util/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const defaultGRPCOptions = {
"grpc-node.max_session_memory": 50,
"grpc.max_reconnect_backoff_ms": 5000,
"grpc.max_receive_message_length": 1024 * 1024 * 16,
// default is 30s, which is too long for us during rollouts (where service DNS entries are updated)
"grpc.dns_min_time_between_resolutions_ms": 2000,
};

export type GrpcMethodType = "unary" | "client_stream" | "server_stream" | "bidi_stream";
Expand Down
2 changes: 1 addition & 1 deletion components/ide-metrics-api/typescript-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lib"
],
"dependencies": {
"@grpc/grpc-js": "1.9.1",
"@grpc/grpc-js": "1.10.8",
"google-protobuf": "^3.19.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions components/ide-service-api/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"long": "4.0.0",
"nice-grpc": "^2.0.0",
"ts-proto": "^1.153.0"
"nice-grpc": "^2.1.8",
"ts-proto": "^1.176.2"
},
"devDependencies": {
"grpc-tools": "^1.12.4",
Expand Down
2 changes: 1 addition & 1 deletion components/image-builder-api/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@gitpod/content-service": "0.1.5",
"@gitpod/gitpod-protocol": "0.1.5",
"@grpc/grpc-js": "1.9.1",
"@grpc/grpc-js": "1.10.8",
"google-protobuf": "^3.19.1",
"inversify": "^6.0.1",
"opentracing": "^0.14.4"
Expand Down
5 changes: 1 addition & 4 deletions components/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"/src"
],
"dependencies": {
"@authzed/authzed-node": "^0.12.1",
"@authzed/authzed-node": "^0.15.0",
"@connectrpc/connect-express": "1.1.2",
"@connectrpc/connect": "1.1.2",
"@gitbeaker/rest": "^39.12.0",
Expand Down Expand Up @@ -152,8 +152,5 @@
"ts-node": "^10.4.0",
"typescript": "~4.4.2",
"watch": "^1.0.2"
},
"resolutions": {
"@authzed/authzed-node/**/@grpc/grpc-js": "1.9.1"
}
}
2 changes: 2 additions & 0 deletions components/server/src/authorization/authorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ export class Authorizer {
}),
relationshipFilter: {
resourceType: relation.resource?.objectType || "",
optionalResourceIdPrefix: "",
optionalResourceId: relation.resource?.objectId || "",
optionalRelation: relation.relation,
optionalSubjectFilter: relation.subject?.object && {
Expand All @@ -534,6 +535,7 @@ export class Authorizer {
}),
relationshipFilter: {
resourceType: relation.resource?.objectType || "",
optionalResourceIdPrefix: "",
optionalResourceId: relation.resource?.objectId || "",
optionalRelation: relation.relation,
optionalSubjectFilter: relation.subject?.object && {
Expand Down
30 changes: 22 additions & 8 deletions components/server/src/authorization/spicedb-authorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,33 @@ async function tryThree<T>(errMessage: string, code: (attempt: number) => Promis
try {
return await code(attempt);
} catch (err) {
if ((err.code === grpc.status.INTERNAL || err.code === grpc.status.DEADLINE_EXCEEDED) && attempt < 3) {
if (
(err.code === grpc.status.INTERNAL ||
err.code === grpc.status.DEADLINE_EXCEEDED ||
err.code === grpc.status.UNAVAILABLE) &&
attempt < 3
) {
let delay = 500 * attempt;
if (err.code === grpc.status.DEADLINE_EXCEEDED) {
// we already waited for timeout, so let's try again immediately
delay = 0;
}

log.warn(errMessage, err, {
attempt,
delay,
code: err.code,
});
} else {
log.error(errMessage, err, {
attempt,
code: err.code,
});
// we don't try again on other errors
throw err;
await new Promise((resolve) => setTimeout(resolve, delay));
continue;
}

log.error(errMessage, err, {
attempt,
code: err.code,
});
// we don't try again on other errors
throw err;
}
}
throw new Error("unreachable");
Expand Down
5 changes: 4 additions & 1 deletion components/server/src/authorization/spicedb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ export class SpiceDBClientProvider {
},
],
}),

"grpc.enable_retries": 1, //TODO enabled by default

// Governs how log DNS resolution results are cached (at minimum!)
// default is 30s, which is too long for us during rollouts (where service DNS entries are updated)
"grpc.dns_min_time_between_resolutions_ms": 2000,
interceptors: this.interceptors,
},
) as Client;
Expand Down
4 changes: 2 additions & 2 deletions components/spicedb/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"dependencies": {
"long": "4.0.0",
"nice-grpc": "^2.0.0",
"ts-proto": "^1.153.0"
"nice-grpc": "^2.1.8",
"ts-proto": "^1.176.2"
},
"devDependencies": {
"@types/long": "4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion components/supervisor-api/typescript-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lib"
],
"dependencies": {
"@grpc/grpc-js": "1.9.1",
"@grpc/grpc-js": "1.10.8",
"google-protobuf": "^3.19.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions components/usage-api/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"dependencies": {
"long": "4.0.0",
"nice-grpc": "^2.0.0",
"ts-proto": "^1.153.0"
"nice-grpc": "^2.1.8",
"ts-proto": "^1.176.2"
},
"devDependencies": {
"@types/long": "4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion components/ws-daemon-api/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"dependencies": {
"@gitpod/content-service": "0.1.5",
"@grpc/grpc-js": "1.9.1",
"@grpc/grpc-js": "1.10.8",
"google-protobuf": "^3.19.1",
"inversify": "^6.0.1",
"opentracing": "^0.14.4"
Expand Down
2 changes: 1 addition & 1 deletion components/ws-manager-api/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"dependencies": {
"@gitpod/content-service": "0.1.5",
"@gitpod/gitpod-protocol": "0.1.5",
"@grpc/grpc-js": "1.9.1",
"@grpc/grpc-js": "1.10.8",
"google-protobuf": "^3.19.1",
"inversify": "^6.0.1",
"opentracing": "^0.14.4"
Expand Down
2 changes: 1 addition & 1 deletion components/ws-manager-bridge-api/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lib"
],
"dependencies": {
"@grpc/grpc-js": "1.9.1",
"@grpc/grpc-js": "1.10.8",
"google-protobuf": "^3.19.1",
"inversify": "^6.0.1",
"opentracing": "^0.14.4"
Expand Down
Loading

0 comments on commit 2686bc2

Please sign in to comment.