Skip to content

Commit 952d922

Browse files
committed
[WorspaceStarter] Don't fail on temporary gRPC errors
1 parent 5fa2acc commit 952d922

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

components/gitpod-protocol/src/util/grpc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,7 @@ export function createClientCallMetricsInterceptor(metrics: IClientCallMetrics):
105105
return new grpc.InterceptingCall(nextCall(options), requester);
106106
};
107107
}
108+
109+
export function isGrpcError(err: any): err is grpc.StatusObject {
110+
return err.code && err.details;
111+
}

components/server/src/workspace/workspace-service.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { goDurationToHumanReadable } from "@gitpod/gitpod-protocol/lib/util/time
6060
import { HeadlessLogEndpoint, HeadlessLogService } from "./headless-log-service";
6161
import { Deferred } from "@gitpod/gitpod-protocol/lib/util/deferred";
6262
import { OrganizationService } from "../orgs/organization-service";
63+
import { isGrpcError } from "@gitpod/gitpod-protocol/lib/util/grpc";
6364

6465
export interface StartWorkspaceOptions extends StarterStartWorkspaceOptions {
6566
/**
@@ -901,10 +902,6 @@ export class WorkspaceService {
901902

902903
// TODO(gpl) Make private after FGA rollout
903904
export function mapGrpcError(err: Error): Error {
904-
function isGrpcError(err: any): err is grpc.StatusObject {
905-
return err.code && err.details;
906-
}
907-
908905
if (!isGrpcError(err)) {
909906
return err;
910907
}

components/server/src/workspace/workspace-starter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ import { SYSTEM_USER } from "../authorization/authorizer";
131131
import { EnvVarService, ResolvedEnvVars } from "../user/env-var-service";
132132
import { RedlockAbortSignal } from "redlock";
133133
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
134+
import { isGrpcError } from "@gitpod/gitpod-protocol/lib/util/grpc";
134135

135136
export interface StartWorkspaceOptions extends GitpodServer.StartWorkspaceOptions {
136137
excludeFeatureFlags?: NamedWorkspaceFeatureFlag[];
@@ -658,7 +659,9 @@ export class WorkspaceStarter {
658659
});
659660
}
660661
} catch (err) {
661-
if (!(err instanceof StartInstanceError)) {
662+
if (isGrpcError(err) && (err.code === grpc.status.UNAVAILABLE || err.code === grpc.status.ALREADY_EXISTS)) {
663+
// fall-through: we don't want to fail but retry/wait for future updates to resolve this
664+
} else if (!(err instanceof StartInstanceError)) {
662665
// fallback in case we did not already handle this error
663666
await this.failInstanceStart({ span }, err, workspace, instance, abortSignal);
664667
err = new StartInstanceError("other", err); // don't throw because there's nobody catching it. We just want to log/trace it.

0 commit comments

Comments
 (0)