Skip to content

Commit 641d824

Browse files
akosyakovfelladrinAndrea Falzetti
committed
[gp-run] experimental workspace config debug mode
Co-authored-by: Anton Kosyakov <[email protected]> Co-authored-by: Victor Nogueira <[email protected]> Co-authored-by: Andrea Falzetti <[email protected]>
1 parent 9e6f741 commit 641d824

File tree

45 files changed

+913
-433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+913
-433
lines changed

WORKSPACE.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defaultArgs:
77
publishToNPM: true
88
publishToJBMarketplace: true
99
localAppVersion: unknown
10-
codeCommit: 05e928f3d900f8b27574d846d46d2ca4a10c2ffd
10+
codeCommit: 8ee664e58e31e81e9dd9da10fb31809e249f0d61
1111
codeVersion: 1.75.0
1212
codeQuality: stable
1313
noVerifyJBPlugin: false

components/gitpod-cli/pkg/supervisor/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type SupervisorClientOption struct {
3030
Address string
3131
}
3232

33-
func New(ctx context.Context, options ...SupervisorClientOption) (*SupervisorClient, error) {
33+
func New(ctx context.Context, options ...*SupervisorClientOption) (*SupervisorClient, error) {
3434
address := util.GetSupervisorAddress()
3535
for _, option := range options {
3636
if option.Address != "" {

components/gitpod-protocol/src/util/gitpod-host-url.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ const baseWorkspaceIDRegex =
1616
"(([a-f][0-9a-f]{7}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}))";
1717

1818
// this pattern matches v4 UUIDs as well as the new generated workspace ids (e.g. pink-panda-ns35kd21)
19-
const workspaceIDRegex = RegExp(`^${baseWorkspaceIDRegex}$`);
19+
const workspaceIDRegex = RegExp(`^(?:debug-)?${baseWorkspaceIDRegex}$`);
2020

2121
// this pattern matches URL prefixes of workspaces
22-
const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${baseWorkspaceIDRegex}\\.`);
22+
const workspaceUrlPrefixRegex = RegExp(`^(([0-9]{4,6}|debug)-)?${baseWorkspaceIDRegex}\\.`);
2323

2424
export namespace StartOptions {
2525
export const WORKSPACE_CLASS = "workspaceClass";
@@ -174,14 +174,18 @@ export class GitpodHostUrl {
174174
return result;
175175
}
176176

177+
get debugWorkspace(): boolean {
178+
return this.url.host.match(workspaceUrlPrefixRegex)?.[2] === "debug";
179+
}
180+
177181
get workspaceId(): string | undefined {
178182
const hostSegs = this.url.host.split(".");
179183
if (hostSegs.length > 1) {
180184
const matchResults = hostSegs[0].match(workspaceIDRegex);
181185
if (matchResults) {
182186
// URL has a workspace prefix
183187
// port prefixes are excluded
184-
return matchResults[0];
188+
return matchResults[1];
185189
}
186190
}
187191

components/ide/code/leeway.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ RUN yarn --cwd extensions compile \
7878
# Check pkg/blobserve/blobserve.go, `inlineVars` method
7979
RUN cp /vscode-web/out/vs/gitpod/browser/workbench/workbench.html /vscode-web/index.html \
8080
&& cp /vscode-web/out/vs/gitpod/browser/workbench/callback.html /vscode-web/callback.html \
81+
# TODO: remove next line when workbench.html changes are merged to gp-code/main
8182
&& sed -i -e 's#static/##g' /vscode-web/index.html \
83+
&& sed -i -e 's#baseUrl =.*;#baseUrl = window.location.origin;#g' /vscode-web/index.html \
84+
&& sed -i -e 's#{{WORKBENCH_WEB_BASE_URL}}#.#g' /vscode-web/index.html \
8285
&& sed -i -e "s/{{VERSION}}/$CODE_QUALITY-$CODE_COMMIT/g" /vscode-web/index.html
8386

8487
# cli config: alises to gitpod-code

components/proxy/conf/Caddyfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,18 @@ https://*.*.{$GITPOD_DOMAIN} {
397397
}
398398
}
399399

400+
# experimental debug workspace route
401+
@debug_workspace header_regexp host Host ^debug-(?P<workspaceID>[a-z0-9][0-9a-z\-]+).ws(?P<location>-[a-z0-9]+)?.{$GITPOD_DOMAIN}
402+
handle @debug_workspace {
403+
reverse_proxy https://ws-proxy.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:9090 {
404+
import workspace_transport
405+
import upstream_headers
406+
407+
header_up X-Gitpod-WorkspaceId {re.host.workspaceID}
408+
header_up X-WSProxy-Host {http.request.host}
409+
}
410+
}
411+
400412
@workspace header_regexp host Host ^(?P<workspaceID>[a-z0-9][0-9a-z\-]+).ws(?P<location>-[a-z0-9]+)?.{$GITPOD_DOMAIN}
401413
handle @workspace {
402414
reverse_proxy https://ws-proxy.{$KUBE_NAMESPACE}.{$KUBE_DOMAIN}:9090 {

components/supervisor/cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var runCmd = &cobra.Command{
2323
Short: "starts the supervisor",
2424

2525
Run: func(cmd *cobra.Command, args []string) {
26-
log.Init(ServiceName, Version, true, os.Getenv("SUPERVISOR_DEBUG_ENABLE") == "true")
26+
log.Init(ServiceName, Version, !runOpts.RunGP, os.Getenv("SUPERVISOR_DEBUG_ENABLE") == "true")
2727
common_grpc.SetupLogging()
2828
supervisor.Version = Version
2929
supervisor.Run(supervisor.WithRunGP(runOpts.RunGP))
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License.AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { DisposableCollection } from "@gitpod/gitpod-protocol/lib/util/disposable";
8+
import * as IDEFrontendService from "./ide/ide-frontend-service-impl";
9+
import * as IDEWorker from "./ide/ide-worker";
10+
import * as IDEWebSocket from "./ide/ide-web-socket";
11+
import { SupervisorServiceClient } from "./ide/supervisor-service-client";
12+
13+
Object.assign(window, { gitpod: {} });
14+
IDEWorker.install();
15+
IDEWebSocket.install();
16+
IDEWebSocket.connectWorkspace();
17+
const ideService = IDEFrontendService.create();
18+
const loadingIDE = new Promise((resolve) => window.addEventListener("DOMContentLoaded", resolve, { once: true }));
19+
const toStop = new DisposableCollection();
20+
21+
(async () => {
22+
const supervisorServiceClient = SupervisorServiceClient.get(Promise.resolve());
23+
const [ideStatus] = await Promise.all([
24+
supervisorServiceClient.ideReady,
25+
supervisorServiceClient.contentReady,
26+
loadingIDE,
27+
]);
28+
// TODO(desktop support)
29+
// const isDesktopIde = ideStatus && ideStatus.desktop && ideStatus.desktop.link;
30+
// if (!isDesktopIde) {
31+
toStop.push(ideService.start());
32+
// }
33+
})();

components/supervisor/frontend/src/ide/ide-metrics-service-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ interface ReportErrorParam {
3131
properties?: Record<string, string>;
3232
}
3333
export class IDEMetricsServiceClient {
34-
static workspaceId? = workspaceUrl.workspaceId;
34+
static workspaceId = workspaceUrl.workspaceId;
35+
static debugWorkspace = workspaceUrl.debugWorkspace;
3536
static gitpodServiceClient?: GitpodServiceClient;
3637

3738
static get instanceId(): string {
@@ -70,6 +71,7 @@ export class IDEMetricsServiceClient {
7071
const p = Object.assign({}, properties);
7172
p.error_name = error.name;
7273
p.error_message = error.message;
74+
p.debug_workspace = String(this.debugWorkspace);
7375

7476
const url = `${MetricsUrl}/reportError`;
7577
const params: ReportErrorParam = {

components/supervisor/frontend/src/ide/supervisor-service-client.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,18 @@ import { GitpodHostUrl } from "@gitpod/gitpod-protocol/lib/util/gitpod-host-url"
1414

1515
export class SupervisorServiceClient {
1616
private static _instance: SupervisorServiceClient | undefined;
17-
static get(gitpodServiceClient: GitpodServiceClient): SupervisorServiceClient {
17+
static get(gitpodAuth: Promise<void>): SupervisorServiceClient {
1818
if (!SupervisorServiceClient._instance) {
19-
SupervisorServiceClient._instance = new SupervisorServiceClient(gitpodServiceClient);
19+
SupervisorServiceClient._instance = new SupervisorServiceClient(gitpodAuth);
2020
}
2121
return SupervisorServiceClient._instance;
2222
}
2323

2424
readonly supervisorReady = this.checkReady("supervisor");
2525
readonly ideReady = this.supervisorReady.then(() => this.checkReady("ide"));
26-
readonly contentReady = Promise.all([this.supervisorReady, this.gitpodServiceClient.auth]).then(() =>
27-
this.checkReady("content"),
28-
);
26+
readonly contentReady = Promise.all([this.supervisorReady, this.gitpodAuth]).then(() => this.checkReady("content"));
2927

30-
private constructor(private readonly gitpodServiceClient: GitpodServiceClient) {}
28+
private constructor(private readonly gitpodAuth: Promise<void>) {}
3129

3230
private async checkReady(kind: "content" | "ide" | "supervisor", delay?: boolean): Promise<any> {
3331
if (delay) {

0 commit comments

Comments
 (0)