@gitpod/gitpod-protocol 0.1.5-me-version.1 → 0.1.5-me-image.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/gitpod-schema.json +23 -4
- package/lib/accounting-protocol.d.ts +3 -6
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +10 -16
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +19 -4
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +2 -13
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +44 -0
- package/lib/analytics.d.ts.map +1 -0
- package/lib/analytics.js +10 -0
- package/lib/analytics.js.map +1 -0
- package/lib/context-url.d.ts +31 -0
- package/lib/context-url.d.ts.map +1 -0
- package/lib/context-url.js +102 -0
- package/lib/context-url.js.map +1 -0
- package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +4 -0
- package/lib/context-url.spec.d.ts.map +1 -0
- package/lib/context-url.spec.js +94 -0
- package/lib/context-url.spec.js.map +1 -0
- package/lib/email-protocol.d.ts +1 -2
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.js +4 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.js +19 -20
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -36
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.js +29 -43
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.js +25 -30
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +20 -21
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.js +25 -41
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +116 -116
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +108 -10
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +152 -295
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +8 -11
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +4 -7
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +105 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +8 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +27 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +30 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/messaging/browser/connection.d.ts +3 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +172 -35
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.js +35 -55
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +35 -0
- package/lib/messaging/client-call-metrics.d.ts.map +1 -0
- package/lib/messaging/client-call-metrics.js +83 -0
- package/lib/messaging/client-call-metrics.js.map +1 -0
- package/lib/messaging/error.d.ts +3 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +6 -2
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/node/connection.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +23 -59
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +2 -0
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +74 -159
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/permission.d.ts +7 -2
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +34 -15
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +1 -1
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +38 -57
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +72 -87
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +70 -115
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +3 -3
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +15 -12
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +113 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -0
- package/lib/teams-projects-protocol.js +30 -0
- package/lib/teams-projects-protocol.js.map +1 -0
- package/lib/util/analytics.d.ts +1 -26
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +36 -28
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.js +55 -133
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +8 -8
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.js +26 -39
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.js +58 -74
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +26 -46
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +30 -68
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +57 -78
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +44 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +93 -103
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +87 -135
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts +15 -0
- package/lib/util/grpc.d.ts.map +1 -0
- package/lib/util/grpc.js +18 -0
- package/lib/util/grpc.js.map +1 -0
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/util/{without.js → jaeger-client-types.js} +1 -1
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +49 -33
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +107 -110
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +2 -2
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +31 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +144 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.js +16 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +51 -5
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +197 -62
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- package/lib/util/workspace-port-authentication.js +2 -2
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +15 -4
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +21 -4
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +24 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.js +1 -1
- package/package.json +24 -13
- package/pkg-yarn.lock +14 -7
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +4 -10
- package/src/admin-protocol.ts +25 -7
- package/src/analytics.ts +52 -0
- package/src/context-url.spec.ts +53 -0
- package/src/context-url.ts +107 -0
- package/src/email-protocol.ts +2 -3
- package/src/env.ts +10 -10
- package/src/gitpod-service.ts +133 -22
- package/src/headless-workspace-log.ts +7 -11
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +5 -0
- package/src/installation-admin-protocol.ts +42 -0
- package/src/messaging/browser/connection.ts +176 -10
- package/src/messaging/client-call-metrics.ts +97 -0
- package/src/messaging/error.ts +8 -2
- package/src/messaging/handler.ts +12 -0
- package/src/messaging/node/connection.ts +21 -68
- package/src/messaging/proxy-factory.ts +13 -5
- package/src/oss-allowlist.ts +15 -0
- package/src/permission.ts +22 -4
- package/src/protocol.ts +105 -99
- package/src/snapshot-url.spec.ts +25 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +6 -4
- package/src/teams-projects-protocol.ts +147 -0
- package/src/util/analytics.ts +17 -30
- package/src/util/garbage-collected-cache.ts +7 -1
- package/src/util/generate-workspace-id.spec.ts +17 -0
- package/src/util/generate-workspace-id.ts +21 -2
- package/src/util/gitpod-cookie.ts +39 -0
- package/src/util/gitpod-host-url.ts +11 -11
- package/src/util/grpc.ts +15 -0
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +102 -38
- package/src/util/parse-workspace-id.spec.ts +21 -1
- package/src/util/parse-workspace-id.ts +32 -6
- package/src/util/repeat.ts +45 -0
- package/src/util/tracing.spec.ts +83 -0
- package/src/util/tracing.ts +183 -17
- package/src/workspace-cluster.ts +19 -5
- package/src/workspace-instance.ts +38 -6
- package/src/wsready.ts +1 -1
- package/lib/messaging/connection-error-handler.d.ts +0 -27
- package/lib/messaging/connection-error-handler.d.ts.map +0 -1
- package/lib/messaging/connection-error-handler.js +0 -46
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/util/context-url.d.ts +0 -13
- package/lib/util/context-url.d.ts.map +0 -1
- package/lib/util/context-url.js +0 -26
- package/lib/util/context-url.js.map +0 -1
- package/lib/util/context-url.spec.d.ts.map +0 -1
- package/lib/util/context-url.spec.js +0 -52
- package/lib/util/context-url.spec.js.map +0 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -118
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -34
- package/lib/util/safe-promise.js.map +0 -1
- package/lib/util/without.d.ts +0 -7
- package/lib/util/without.d.ts.map +0 -1
- package/lib/util/without.js.map +0 -1
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/util/context-url.spec.ts +0 -25
- package/src/util/context-url.ts +0 -23
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
- package/src/util/safe-promise.ts +0 -26
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}/;
|
|
8
|
+
const REGEX_WORKSPACE_ID_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID.source}$`);
|
|
9
|
+
// We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
|
|
10
|
+
const REGEX_WORKSPACE_ID_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID.source})\.ws`);
|
|
11
|
+
|
|
12
|
+
const REGEX_WORKSPACE_ID_LEGACY = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
|
|
13
|
+
const REGEX_WORKSPACE_ID_LEGACY_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID_LEGACY.source}$`);
|
|
14
|
+
const REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID_LEGACY.source})\.ws`);
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Hostname may be of the form:
|
|
@@ -13,17 +21,35 @@
|
|
|
13
21
|
* @param hostname The hostname the request is headed to
|
|
14
22
|
*/
|
|
15
23
|
export const parseWorkspaceIdFromHostname = function(hostname: string) {
|
|
16
|
-
|
|
17
|
-
const wsIdExpression = /([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8})\.ws/g;
|
|
18
|
-
const match = wsIdExpression.exec(hostname);
|
|
24
|
+
const match = REGEX_WORKSPACE_ID_FROM_HOSTNAME.exec(hostname);
|
|
19
25
|
if (match && match.length >= 2) {
|
|
20
26
|
return match[1];
|
|
21
27
|
} else {
|
|
22
|
-
const
|
|
23
|
-
const legacyMatch = legacyUrlFormat.exec(hostname);
|
|
28
|
+
const legacyMatch = REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME.exec(hostname);
|
|
24
29
|
if (legacyMatch && legacyMatch.length >= 2) {
|
|
25
30
|
return legacyMatch[1];
|
|
26
31
|
}
|
|
27
32
|
return undefined;
|
|
28
33
|
}
|
|
29
|
-
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Equalls UUIDv4 (and REGEX_WORKSPACE_ID_LEGACY!) */
|
|
37
|
+
const REGEX_INSTANCE_ID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
|
|
38
|
+
const REGEX_INSTANCE_ID_EXACT = new RegExp(`^${REGEX_INSTANCE_ID.source}$`);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param maybeId
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function(maybeId: string): boolean {
|
|
45
|
+
return REGEX_INSTANCE_ID_EXACT.test(maybeId)
|
|
46
|
+
|| REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param maybeWorkspaceId
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
export const matchesNewWorkspaceIdExactly = function(maybeWorkspaceId: string): boolean {
|
|
54
|
+
return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
|
|
55
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 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 { Disposable } from "..";
|
|
8
|
+
import { log } from "./logging";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This intends to be a drop-in replacement for 'setInterval' implemented with a 'setTimeout' chain
|
|
12
|
+
* to ensure we're not creating more timeouts than we can process.
|
|
13
|
+
* @param op
|
|
14
|
+
* @param everyMilliseconds
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export function repeat(op: () => Promise<void> | void, everyMilliseconds: number): Disposable {
|
|
18
|
+
let timer: NodeJS.Timeout | undefined = undefined;
|
|
19
|
+
let stopped = false;
|
|
20
|
+
const repeated = () => {
|
|
21
|
+
if (stopped) {
|
|
22
|
+
// in case we missed the clearTimeout i 'await'
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
timer = setTimeout(async () => {
|
|
27
|
+
try {
|
|
28
|
+
await op();
|
|
29
|
+
} catch (err) {
|
|
30
|
+
// catch error here to
|
|
31
|
+
log.error(err);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
repeated(); // chain ourselves - after the 'await'
|
|
35
|
+
}, everyMilliseconds);
|
|
36
|
+
};
|
|
37
|
+
repeated();
|
|
38
|
+
|
|
39
|
+
return Disposable.create(() => {
|
|
40
|
+
stopped = true;
|
|
41
|
+
if (timer) {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2021 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 { suite, test } from "mocha-typescript"
|
|
8
|
+
import * as chai from "chai"
|
|
9
|
+
import { TraceContext } from "./tracing";
|
|
10
|
+
import { MockTracer } from "opentracing";
|
|
11
|
+
|
|
12
|
+
const expect = chai.expect
|
|
13
|
+
|
|
14
|
+
@suite class TestTracing {
|
|
15
|
+
|
|
16
|
+
@test public async testTracingContext_addNestedTags() {
|
|
17
|
+
const tracer = new MockTracer();
|
|
18
|
+
const span = tracer.startSpan('testTracingContext_addNestedTags');
|
|
19
|
+
TraceContext.addNestedTags({ span }, {
|
|
20
|
+
rpc: {
|
|
21
|
+
system: "jsonrpc",
|
|
22
|
+
jsonrpc: {
|
|
23
|
+
version: "1.0",
|
|
24
|
+
method: "test",
|
|
25
|
+
parameters: ["abc", "def"],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const mockSpan = tracer.report().spans[0];
|
|
31
|
+
expect(mockSpan.tags()).to.deep.equal({
|
|
32
|
+
"rpc.system": "jsonrpc",
|
|
33
|
+
"rpc.jsonrpc.version": "1.0",
|
|
34
|
+
"rpc.jsonrpc.method": "test",
|
|
35
|
+
"rpc.jsonrpc.parameters.0": "abc",
|
|
36
|
+
"rpc.jsonrpc.parameters.1": "def",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@test public async testTracingContext_addNestedTags_null() {
|
|
41
|
+
const tracer = new MockTracer();
|
|
42
|
+
const span = tracer.startSpan('testTracingContext_addNestedTags_null');
|
|
43
|
+
TraceContext.addNestedTags({ span }, {
|
|
44
|
+
someShape: {
|
|
45
|
+
thisIsNull: null,
|
|
46
|
+
thisIsUndefined: undefined,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const mockSpan = tracer.report().spans[0];
|
|
51
|
+
expect(mockSpan.tags()).to.deep.equal({
|
|
52
|
+
"someShape.thisIsNull": null,
|
|
53
|
+
"someShape.thisIsUndefined": undefined,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@test public async testTracingContext_addJsonRPCParameters() {
|
|
58
|
+
const tracer = new MockTracer();
|
|
59
|
+
const span = tracer.startSpan('testTracingContext_addJsonRPCParameters');
|
|
60
|
+
const ctx = { span };
|
|
61
|
+
TraceContext.addJsonRPCParameters(ctx, {
|
|
62
|
+
one: "one",
|
|
63
|
+
two: {
|
|
64
|
+
name: "two",
|
|
65
|
+
some: "shape",
|
|
66
|
+
containing: "PII",
|
|
67
|
+
},
|
|
68
|
+
three: "three",
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const mockSpan = tracer.report().spans[0];
|
|
72
|
+
expect(mockSpan.tags()).to.deep.equal({
|
|
73
|
+
"rpc.jsonrpc.parameters.one": "one",
|
|
74
|
+
"rpc.jsonrpc.parameters.two.containing": "PII",
|
|
75
|
+
"rpc.jsonrpc.parameters.two.name": "two",
|
|
76
|
+
"rpc.jsonrpc.parameters.two.some": "shape",
|
|
77
|
+
"rpc.jsonrpc.parameters.three": "three",
|
|
78
|
+
"rpc.system": "jsonrpc",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
module.exports = new TestTracing()
|
package/src/util/tracing.ts
CHANGED
|
@@ -6,40 +6,184 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
import * as opentracing from 'opentracing';
|
|
9
|
-
import { TracingConfig, initTracerFromEnv
|
|
9
|
+
import { TracingConfig, initTracerFromEnv } from 'jaeger-client';
|
|
10
|
+
import { Sampler, SamplingDecision } from './jaeger-client-types';
|
|
10
11
|
import { initGlobalTracer } from 'opentracing';
|
|
11
12
|
import { injectable } from 'inversify';
|
|
13
|
+
import { ResponseError } from 'vscode-jsonrpc';
|
|
14
|
+
import { log, LogContext } from './logging';
|
|
12
15
|
|
|
13
16
|
export interface TraceContext {
|
|
14
17
|
span?: opentracing.Span
|
|
15
18
|
}
|
|
19
|
+
export type TraceContextWithSpan = TraceContext & {
|
|
20
|
+
span: opentracing.Span
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
export namespace TraceContext {
|
|
18
|
-
export function startSpan(operation: string,
|
|
19
|
-
const options: opentracing.SpanOptions = {
|
|
20
|
-
|
|
25
|
+
export function startSpan(operation: string, parentCtx?: TraceContext): opentracing.Span {
|
|
26
|
+
const options: opentracing.SpanOptions = {};
|
|
27
|
+
if (parentCtx && parentCtx.span && !!parentCtx.span.context().toSpanId()) {
|
|
28
|
+
options.childOf = parentCtx.span;
|
|
21
29
|
}
|
|
30
|
+
// TODO(gpl) references lead to a huge amount of errors in prod logs. Avoid those until we have time to figure out how to fix it.
|
|
31
|
+
// if (referencedSpans) {
|
|
32
|
+
// // note: allthough followsForm's type says it takes 'opentracing.Span | opentracing.SpanContext', it only works with SpanContext (typing mismatch)
|
|
33
|
+
// // note2: we need to filter out debug spans (spanId === "")
|
|
34
|
+
// options.references = referencedSpans.filter(s => s !== undefined)
|
|
35
|
+
// .filter(s => !!s!.context().toSpanId())
|
|
36
|
+
// .map(s => followsFrom(s!.context()));
|
|
37
|
+
// }
|
|
38
|
+
|
|
22
39
|
return opentracing.globalTracer().startSpan(operation, options);
|
|
23
40
|
}
|
|
24
41
|
|
|
25
|
-
export function
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
export function childContext(operation: string, parentCtx: TraceContext): TraceContextWithSpan {
|
|
43
|
+
const span = startSpan(operation, parentCtx);
|
|
44
|
+
return { span };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function withSpan(operation: string, callback: (ctx: TraceContext) => void, ctx?: TraceContext): void {
|
|
48
|
+
// if we don't have a parent span, don't create a trace here as those <trace-without-root-spans> are not useful.
|
|
49
|
+
if (!ctx || !ctx.span || !ctx.span.context()) {
|
|
50
|
+
callback({});
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const span = TraceContext.startSpan(operation, ctx);
|
|
55
|
+
try {
|
|
56
|
+
callback({span});
|
|
57
|
+
} catch (e) {
|
|
58
|
+
TraceContext.setError({span}, e);
|
|
59
|
+
throw e;
|
|
60
|
+
} finally {
|
|
61
|
+
span.finish();
|
|
29
62
|
}
|
|
30
|
-
return opentracing.globalTracer().startSpan(operation, options);
|
|
31
63
|
}
|
|
32
64
|
|
|
33
|
-
export function
|
|
65
|
+
export function setError(ctx: TraceContext, err: Error) {
|
|
34
66
|
if (!ctx.span) {
|
|
35
67
|
return;
|
|
36
68
|
}
|
|
37
69
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
70
|
+
TraceContext.addNestedTags(ctx, {
|
|
71
|
+
error: {
|
|
72
|
+
message: err.message,
|
|
73
|
+
stacktrace: err.stack,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
ctx.span.setTag("error", true);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function setJsonRPCMetadata(ctx: TraceContext, method?: string) {
|
|
80
|
+
if (!ctx.span) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const tags: { [key: string]: any } = {
|
|
85
|
+
rpc: {
|
|
86
|
+
system: "jsonrpc",
|
|
87
|
+
// version,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
if (method) {
|
|
91
|
+
tags.rpc.method = method;
|
|
92
|
+
}
|
|
93
|
+
addNestedTags(ctx, tags);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function setJsonRPCError(ctx: TraceContext, method: string, err: ResponseError<any>, withStatusCode: boolean = false) {
|
|
97
|
+
if (!ctx.span) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// not use setError bc this is (most likely) a working operation
|
|
101
|
+
|
|
102
|
+
setJsonRPCMetadata(ctx, method);
|
|
103
|
+
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/rpc.md#json-rpc
|
|
104
|
+
addNestedTags(ctx, {
|
|
105
|
+
rpc: {
|
|
106
|
+
jsonrpc: {
|
|
107
|
+
error_code: err.code,
|
|
108
|
+
error_message: err.message,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// the field "status_code" is used by honeycomb to derive insights like success rate, etc. Defaults to "0".
|
|
114
|
+
if (withStatusCode) {
|
|
115
|
+
ctx.span.setTag("status_code", err.code);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function addJsonRPCParameters(ctx: TraceContext, params: { [key: string]: any }) {
|
|
120
|
+
if (!ctx.span) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
setJsonRPCMetadata(ctx);
|
|
125
|
+
addNestedTags(ctx, {
|
|
126
|
+
rpc: {
|
|
127
|
+
jsonrpc: {
|
|
128
|
+
parameters: params,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Does what one would expect from `span.addTags`: Calls `span.addTag` for all keys in map, recursively for objects.
|
|
136
|
+
* Example:
|
|
137
|
+
* ```
|
|
138
|
+
* TraceContext.addNestedTags(ctx, {
|
|
139
|
+
* rpc: {
|
|
140
|
+
* system: "jsonrpc",
|
|
141
|
+
* jsonrpc: {
|
|
142
|
+
* version: "1.0",
|
|
143
|
+
* method: "test",
|
|
144
|
+
* parameters: ["abc", "def"],
|
|
145
|
+
* },
|
|
146
|
+
* },
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
* gives
|
|
150
|
+
* rpc.system = "jsonrpc"
|
|
151
|
+
* rpc.jsonrpc.version = "1.0"
|
|
152
|
+
* rpc.jsonrpc.method = "test"
|
|
153
|
+
* rpc.jsonrpc.parameters.0 = "abc"
|
|
154
|
+
* rpc.jsonrpc.parameters.1 = "def"
|
|
155
|
+
* @param ctx
|
|
156
|
+
* @param keyValueMap
|
|
157
|
+
* @returns
|
|
158
|
+
*/
|
|
159
|
+
export function addNestedTags(ctx: TraceContext, keyValueMap: { [key: string]: any }, _namespace?: string) {
|
|
160
|
+
if (!ctx.span) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const namespace = _namespace ? `${_namespace}.` : '';
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
for (const k of Object.keys(keyValueMap)) {
|
|
167
|
+
const v = keyValueMap[k];
|
|
168
|
+
if (v instanceof Object) {
|
|
169
|
+
addNestedTags(ctx, v, `${namespace}${k}`);
|
|
170
|
+
} else {
|
|
171
|
+
ctx.span.setTag(`${namespace}${k}`, v);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
// general resilience against odd shapes/parameters
|
|
176
|
+
log.error("Tracing.addNestedTags", err, { namespace });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function setOWI(ctx: TraceContext, owi: LogContext) {
|
|
181
|
+
if (!ctx.span) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
addNestedTags(ctx, {
|
|
185
|
+
context: owi,
|
|
186
|
+
});
|
|
43
187
|
}
|
|
44
188
|
}
|
|
45
189
|
|
|
@@ -56,11 +200,16 @@ export class TracingManager {
|
|
|
56
200
|
reporter: {
|
|
57
201
|
logSpans: false
|
|
58
202
|
},
|
|
59
|
-
serviceName
|
|
203
|
+
serviceName,
|
|
60
204
|
}
|
|
61
205
|
const t = initTracerFromEnv(config, {
|
|
62
|
-
logger: console
|
|
206
|
+
logger: console,
|
|
207
|
+
tags: {
|
|
208
|
+
'service.build.commit': process.env.GITPOD_BUILD_GIT_COMMIT,
|
|
209
|
+
'service.build.version': process.env.GITPOD_BUILD_VERSION,
|
|
210
|
+
}
|
|
63
211
|
});
|
|
212
|
+
|
|
64
213
|
if (opts) {
|
|
65
214
|
if (opts.perOpSampling) {
|
|
66
215
|
(t as any)._sampler = new PerOperationSampler((t as any)._sampler, opts.perOpSampling);
|
|
@@ -132,3 +281,20 @@ export class PerOperationSampler implements Sampler {
|
|
|
132
281
|
}
|
|
133
282
|
}
|
|
134
283
|
}
|
|
284
|
+
|
|
285
|
+
// Augment interfaces with an leading parameter "TraceContext" on every method
|
|
286
|
+
type IsValidArg<T> = T extends object ? keyof T extends never ? false : true : true;
|
|
287
|
+
type AddTraceContext<T> =
|
|
288
|
+
T extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E, f: infer F) => infer R ? (
|
|
289
|
+
IsValidArg<F> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E, f: F) => R :
|
|
290
|
+
IsValidArg<E> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D, e: E) => R :
|
|
291
|
+
IsValidArg<D> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C, d: D) => R :
|
|
292
|
+
IsValidArg<C> extends true ? (ctx: TraceContextWithSpan, a: A, b: B, c: C) => R :
|
|
293
|
+
IsValidArg<B> extends true ? (ctx: TraceContextWithSpan, a: A, b: B) => R :
|
|
294
|
+
IsValidArg<A> extends true ? (ctx: TraceContextWithSpan, a: A) => R :
|
|
295
|
+
(ctx: TraceContextWithSpan) => Promise<R>
|
|
296
|
+
) : never;
|
|
297
|
+
|
|
298
|
+
export type InterfaceWithTraceContext<T> = {
|
|
299
|
+
[P in keyof T]: AddTraceContext<T[P]>
|
|
300
|
+
};
|
package/src/workspace-cluster.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import * as fs from 'fs';
|
|
8
8
|
import { filePathTelepresenceAware } from './env';
|
|
9
9
|
import { DeepPartial } from "./util/deep-partial";
|
|
10
|
-
import { Without } from './util/without';
|
|
11
10
|
import { PermissionName } from './permission';
|
|
12
11
|
|
|
13
12
|
export interface WorkspaceCluster {
|
|
@@ -50,13 +49,28 @@ export interface TLSConfig {
|
|
|
50
49
|
export namespace TLSConfig {
|
|
51
50
|
export const loadFromBase64File = (path: string): string => fs.readFileSync(filePathTelepresenceAware(path)).toString("base64");
|
|
52
51
|
}
|
|
53
|
-
export type WorkspaceClusterWoTLS =
|
|
52
|
+
export type WorkspaceClusterWoTLS = Omit<WorkspaceCluster, "tls">;
|
|
54
53
|
export type WorkspaceManagerConnectionInfo = Pick<WorkspaceCluster, "name" | "url" | "tls">;
|
|
55
54
|
|
|
56
|
-
export type AdmissionConstraint = AdmissionConstraintFeaturePreview |
|
|
55
|
+
export type AdmissionConstraint = AdmissionConstraintFeaturePreview | AdmissionConstraintHasPermission | AdmissionConstraintHasUserLevel | AdmissionConstraintHasMoreResources;
|
|
57
56
|
export type AdmissionConstraintFeaturePreview = { type: "has-feature-preview" };
|
|
58
|
-
export type
|
|
59
|
-
|
|
57
|
+
export type AdmissionConstraintHasPermission = { type: "has-permission", permission: PermissionName };
|
|
58
|
+
export type AdmissionConstraintHasUserLevel = { type: "has-user-level", level: string };
|
|
59
|
+
export type AdmissionConstraintHasMoreResources = { type: "has-more-resources" };
|
|
60
|
+
|
|
61
|
+
export namespace AdmissionConstraint {
|
|
62
|
+
export function is(o: any): o is AdmissionConstraint {
|
|
63
|
+
return !!o
|
|
64
|
+
&& 'type' in o;
|
|
65
|
+
}
|
|
66
|
+
export function isHasPermissionConstraint(o: any): o is AdmissionConstraintHasPermission {
|
|
67
|
+
return is(o)
|
|
68
|
+
&& o.type === "has-permission";
|
|
69
|
+
}
|
|
70
|
+
export function hasPermission(ac: AdmissionConstraint, permission: PermissionName): boolean {
|
|
71
|
+
return isHasPermissionConstraint(ac) && ac.permission === permission;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
60
74
|
|
|
61
75
|
export const WorkspaceClusterDB = Symbol("WorkspaceClusterDB");
|
|
62
76
|
export interface WorkspaceClusterDB {
|
|
@@ -23,16 +23,22 @@ export interface WorkspaceInstance {
|
|
|
23
23
|
// The time an instance has switched phase to 'Running'
|
|
24
24
|
startedTime?: string;
|
|
25
25
|
|
|
26
|
+
// The time an instance has switched phase to 'Stopping' */
|
|
27
|
+
stoppingTime?: string;
|
|
28
|
+
|
|
26
29
|
// The time an instance has switched phase to 'Stopped' */
|
|
27
30
|
stoppedTime?: string;
|
|
28
31
|
|
|
29
32
|
// ideUrl is the URL at which the workspace is available on the internet
|
|
33
|
+
// Note: this is nitially empty, filled during starting process!
|
|
30
34
|
ideUrl: string;
|
|
31
35
|
|
|
32
36
|
// region is the name of the workspace cluster this instance runs in
|
|
37
|
+
// Note: this is nitially empty, filled during starting process!
|
|
33
38
|
region: string;
|
|
34
39
|
|
|
35
40
|
// workspaceImage is the name of the Docker image this instance runs
|
|
41
|
+
// Note: this is nitially empty, filled during starting process!
|
|
36
42
|
workspaceImage: string;
|
|
37
43
|
|
|
38
44
|
// status is the latest status of the instance that we're aware of
|
|
@@ -45,6 +51,11 @@ export interface WorkspaceInstance {
|
|
|
45
51
|
|
|
46
52
|
// instance is hard-deleted on the database and about to be collected by db-sync
|
|
47
53
|
readonly deleted?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Contains information about the image build, if there was any
|
|
57
|
+
*/
|
|
58
|
+
imageBuildInfo?: ImageBuildInfo;
|
|
48
59
|
}
|
|
49
60
|
|
|
50
61
|
// WorkspaceInstanceStatus describes the current state of a workspace instance
|
|
@@ -128,9 +139,6 @@ export interface WorkspaceInstanceConditions {
|
|
|
128
139
|
// PullingImages marks if the workspace is currently pulling its images. This condition can only be set during PhaseCreating
|
|
129
140
|
pullingImages?: boolean
|
|
130
141
|
|
|
131
|
-
// ServiceExists denotes if the workspace theia-/ports- services exist. This condition will be true if either of the two services exist.
|
|
132
|
-
serviceExists?: boolean
|
|
133
|
-
|
|
134
142
|
// deployed marks that a workspace instance was sent/deployed at a workspace manager
|
|
135
143
|
deployed?: boolean;
|
|
136
144
|
|
|
@@ -139,6 +147,12 @@ export interface WorkspaceInstanceConditions {
|
|
|
139
147
|
|
|
140
148
|
// ISO8601 timestamp when the first user activity was registered in the frontend. Only set if the workspace is running.
|
|
141
149
|
firstUserActivity?: string;
|
|
150
|
+
|
|
151
|
+
// headless_task_failed indicates that a headless workspace task failed
|
|
152
|
+
headlessTaskFailed?: string;
|
|
153
|
+
|
|
154
|
+
// stopped_by_request is true if the workspace was stopped using a StopWorkspace call
|
|
155
|
+
stoppedByRequest?: boolean;
|
|
142
156
|
}
|
|
143
157
|
|
|
144
158
|
// AdmissionLevel describes who can access a workspace instance and its ports.
|
|
@@ -152,9 +166,6 @@ export interface WorkspaceInstancePort {
|
|
|
152
166
|
// The outward-facing port number
|
|
153
167
|
port: number;
|
|
154
168
|
|
|
155
|
-
// An optional inward-facing port number. If not present we'll use port.
|
|
156
|
-
targetPort?: number;
|
|
157
|
-
|
|
158
169
|
// The visiblity of this port. Optional for backwards compatibility.
|
|
159
170
|
visibility?: PortVisibility;
|
|
160
171
|
|
|
@@ -200,4 +211,25 @@ export interface WorkspaceInstanceConfiguration {
|
|
|
200
211
|
|
|
201
212
|
// ideImage is the ref of the IDE image this instance uses.
|
|
202
213
|
ideImage: string;
|
|
214
|
+
|
|
215
|
+
// desktopIdeImage is the ref of the desktop IDE image this instance uses.
|
|
216
|
+
desktopIdeImage?: string
|
|
217
|
+
|
|
218
|
+
// supervisorImage is the ref of the supervisor image this instance uses.
|
|
219
|
+
supervisorImage?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Holds information about the image build (if there was one) for this WorkspaceInstance
|
|
224
|
+
*/
|
|
225
|
+
export interface ImageBuildInfo {
|
|
226
|
+
log?: ImageBuildLogInfo,
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Holds information about how to access logs for this an image build
|
|
231
|
+
*/
|
|
232
|
+
export interface ImageBuildLogInfo {
|
|
233
|
+
url: string,
|
|
234
|
+
headers: { [key: string]: string },
|
|
203
235
|
}
|
package/src/wsready.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
// generated using github.com/32leaves/bel on 2021-
|
|
7
|
+
// generated using github.com/32leaves/bel on 2021-11-04 12:16:53.917570766 +0000 UTC m=+0.006002884
|
|
8
8
|
// DO NOT MODIFY
|
|
9
9
|
|
|
10
10
|
export enum WorkspaceInitSource {
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Message } from "vscode-jsonrpc";
|
|
2
|
-
export interface ResolvedConnectionErrorHandlerOptions {
|
|
3
|
-
readonly serverName: string;
|
|
4
|
-
/**
|
|
5
|
-
* The maximum amount of errors allowed before stopping the server.
|
|
6
|
-
*/
|
|
7
|
-
readonly maxErrors: number;
|
|
8
|
-
/**
|
|
9
|
-
* The maimum amount of restarts allowed in the restart interval.
|
|
10
|
-
*/
|
|
11
|
-
readonly maxRestarts: number;
|
|
12
|
-
/**
|
|
13
|
-
* In minutes.
|
|
14
|
-
*/
|
|
15
|
-
readonly restartInterval: number;
|
|
16
|
-
}
|
|
17
|
-
export declare type ConnectionErrorHandlerOptions = Partial<ResolvedConnectionErrorHandlerOptions> & {
|
|
18
|
-
readonly serverName: string;
|
|
19
|
-
};
|
|
20
|
-
export declare class ConnectionErrorHandler {
|
|
21
|
-
protected readonly options: ResolvedConnectionErrorHandlerOptions;
|
|
22
|
-
constructor(options: ConnectionErrorHandlerOptions);
|
|
23
|
-
shouldStop(error: Error, message?: Message, count?: number): boolean;
|
|
24
|
-
protected readonly restarts: number[];
|
|
25
|
-
shouldRestart(): boolean;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=connection-error-handler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-error-handler.d.ts","sourceRoot":"","sources":["../../src/messaging/connection-error-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,MAAM,WAAW,qCAAqC;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CACnC;AAED,oBAAY,6BAA6B,GAAG,OAAO,CAAC,qCAAqC,CAAC,GAAG;IACzF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC9B,CAAC;AAEF,qBAAa,sBAAsB;IAE/B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,qCAAqC,CAAC;gBACtD,OAAO,EAAE,6BAA6B;IASlD,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;IAIpE,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAM;IAC3C,aAAa,IAAI,OAAO;CAc3B"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (C) 2017 TypeFox and others.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
*/
|
|
8
|
-
var __assign = (this && this.__assign) || function () {
|
|
9
|
-
__assign = Object.assign || function(t) {
|
|
10
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11
|
-
s = arguments[i];
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
}
|
|
15
|
-
return t;
|
|
16
|
-
};
|
|
17
|
-
return __assign.apply(this, arguments);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.ConnectionErrorHandler = void 0;
|
|
21
|
-
var logging_1 = require("../util/logging");
|
|
22
|
-
var ConnectionErrorHandler = /** @class */ (function () {
|
|
23
|
-
function ConnectionErrorHandler(options) {
|
|
24
|
-
this.restarts = [];
|
|
25
|
-
this.options = __assign({ maxErrors: 3, maxRestarts: 5, restartInterval: 3 }, options);
|
|
26
|
-
}
|
|
27
|
-
ConnectionErrorHandler.prototype.shouldStop = function (error, message, count) {
|
|
28
|
-
return !count || count > this.options.maxErrors;
|
|
29
|
-
};
|
|
30
|
-
ConnectionErrorHandler.prototype.shouldRestart = function () {
|
|
31
|
-
this.restarts.push(Date.now());
|
|
32
|
-
if (this.restarts.length <= this.options.maxRestarts) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
var diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
|
|
36
|
-
if (diff <= this.options.restartInterval * 60 * 1000) {
|
|
37
|
-
logging_1.log.error("Server " + this.options.serverName + " crashed " + this.options.maxRestarts + " times in the last " + this.options.restartInterval + " minutes. Will not restart");
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
this.restarts.shift();
|
|
41
|
-
return true;
|
|
42
|
-
};
|
|
43
|
-
return ConnectionErrorHandler;
|
|
44
|
-
}());
|
|
45
|
-
exports.ConnectionErrorHandler = ConnectionErrorHandler;
|
|
46
|
-
//# sourceMappingURL=connection-error-handler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection-error-handler.js","sourceRoot":"","sources":["../../src/messaging/connection-error-handler.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;AAGH,2CAAsC;AAsBtC;IAGI,gCAAY,OAAsC;QAa/B,aAAQ,GAAa,EAAE,CAAC;QAZvC,IAAI,CAAC,OAAO,cACR,SAAS,EAAE,CAAC,EACZ,WAAW,EAAE,CAAC,EACd,eAAe,EAAE,CAAC,IACf,OAAO,CACb,CAAC;IACN,CAAC;IAED,2CAAU,GAAV,UAAW,KAAY,EAAE,OAAiB,EAAE,KAAc;QACtD,OAAO,CAAC,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACpD,CAAC;IAGD,8CAAa,GAAb;QACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YAClD,OAAO,IAAI,CAAC;SACf;QACD,IAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,GAAG,EAAE,GAAG,IAAI,EAAE;YAClD,aAAG,CAAC,KAAK,CAAC,YAAU,IAAI,CAAC,OAAO,CAAC,UAAU,iBAAY,IAAI,CAAC,OAAO,CAAC,WAAW,2BAAsB,IAAI,CAAC,OAAO,CAAC,eAAe,+BAA4B,CAAC,CAAC;YAC/J,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEL,6BAAC;AAAD,CAAC,AA/BD,IA+BC;AA/BY,wDAAsB"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2020 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
|
-
* The field "contextUrl" might contain prefixes like:
|
|
8
|
-
* - envvar1=value1/...
|
|
9
|
-
* - prebuild/...
|
|
10
|
-
* This is the analogon to the (Prefix)ContextParser structure in "server".
|
|
11
|
-
*/
|
|
12
|
-
export declare function contextUrlToUrl(contextUrl: string | undefined): URL | undefined;
|
|
13
|
-
//# sourceMappingURL=context-url.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-url.d.ts","sourceRoot":"","sources":["../../src/util/context-url.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,GAAG,SAAS,CAU/E"}
|