@gitpod/gitpod-protocol 0.1.5-me-ingress.20 → 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 +12 -0
- package/lib/admin-protocol.d.ts +10 -0
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +4 -5
- package/lib/analytics.d.ts.map +1 -1
- package/lib/context-url.d.ts +18 -5
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +58 -5
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts +2 -0
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +25 -4
- package/lib/context-url.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +23 -2
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +4 -2
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +17 -0
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +20 -1
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-protocol.d.ts +24 -0
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -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/error.d.ts +1 -0
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +2 -0
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/node/connection.d.ts +1 -7
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +20 -18
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/permission.d.ts +7 -1
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +24 -4
- package/lib/permission.js.map +1 -1
- package/lib/protocol.d.ts +32 -38
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +16 -4
- package/lib/protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +3 -0
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +7 -0
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +1 -0
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +1 -0
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts +0 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +0 -3
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/tracing.d.ts +2 -1
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +29 -6
- package/lib/util/tracing.js.map +1 -1
- package/lib/workspace-cluster.d.ts +9 -7
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +18 -1
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +19 -0
- package/lib/workspace-instance.d.ts.map +1 -1
- package/package.json +2 -2
- package/pkg-yarn.lock +2 -2
- package/provenance-bundle.jsonl +1 -1
- package/src/admin-protocol.ts +17 -4
- package/src/analytics.ts +4 -6
- package/src/context-url.spec.ts +18 -4
- package/src/context-url.ts +62 -6
- package/src/gitpod-service.ts +33 -6
- package/src/headless-workspace-log.ts +24 -0
- package/src/ide-frontend-service.ts +1 -1
- package/src/ide-protocol.ts +27 -0
- package/src/index.ts +1 -0
- package/src/installation-admin-protocol.ts +42 -0
- package/src/messaging/error.ts +3 -0
- package/src/messaging/node/connection.ts +20 -23
- package/src/permission.ts +22 -3
- package/src/protocol.ts +48 -42
- package/src/teams-projects-protocol.ts +7 -1
- package/src/util/generate-workspace-id.spec.ts +1 -0
- package/src/util/generate-workspace-id.ts +1 -0
- package/src/util/gitpod-host-url.ts +1 -5
- package/src/util/tracing.ts +29 -7
- package/src/workspace-cluster.ts +17 -9
- package/src/workspace-instance.ts +20 -0
- 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 -34
- package/lib/messaging/connection-error-handler.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 -31
- package/lib/util/safe-promise.js.map +0 -1
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/util/safe-promise.ts +0 -26
package/src/protocol.ts
CHANGED
|
@@ -119,6 +119,7 @@ export type IDESettings = {
|
|
|
119
119
|
defaultIde?: string
|
|
120
120
|
useDesktopIde?: boolean
|
|
121
121
|
defaultDesktopIde?: string
|
|
122
|
+
useLatestVersion?: boolean
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
export interface UserPlatform {
|
|
@@ -154,12 +155,23 @@ export interface UserFeatureSettings {
|
|
|
154
155
|
export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
|
|
155
156
|
export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
|
|
156
157
|
|
|
157
|
-
export interface
|
|
158
|
-
id?: string;
|
|
158
|
+
export interface EnvVarWithValue {
|
|
159
159
|
name: string;
|
|
160
|
-
repositoryPattern: string;
|
|
161
160
|
value: string;
|
|
162
161
|
}
|
|
162
|
+
|
|
163
|
+
export interface ProjectEnvVarWithValue extends EnvVarWithValue {
|
|
164
|
+
id: string;
|
|
165
|
+
projectId: string;
|
|
166
|
+
censored: boolean;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, 'value'>;
|
|
170
|
+
|
|
171
|
+
export interface UserEnvVarValue extends EnvVarWithValue {
|
|
172
|
+
id?: string;
|
|
173
|
+
repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
174
|
+
}
|
|
163
175
|
export interface UserEnvVar extends UserEnvVarValue {
|
|
164
176
|
id: string;
|
|
165
177
|
userId: string;
|
|
@@ -168,10 +180,12 @@ export interface UserEnvVar extends UserEnvVarValue {
|
|
|
168
180
|
|
|
169
181
|
export namespace UserEnvVar {
|
|
170
182
|
|
|
183
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
171
184
|
export function normalizeRepoPattern(pattern: string) {
|
|
172
185
|
return pattern.toLocaleLowerCase();
|
|
173
186
|
}
|
|
174
187
|
|
|
188
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
175
189
|
export function score(value: UserEnvVarValue): number {
|
|
176
190
|
// We use a score to enforce precedence:
|
|
177
191
|
// value/value = 0
|
|
@@ -194,6 +208,7 @@ export namespace UserEnvVar {
|
|
|
194
208
|
return score;
|
|
195
209
|
}
|
|
196
210
|
|
|
211
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
197
212
|
export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
|
|
198
213
|
let result = vars.filter(e => {
|
|
199
214
|
const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
|
|
@@ -241,10 +256,11 @@ export namespace UserEnvVar {
|
|
|
241
256
|
return result;
|
|
242
257
|
}
|
|
243
258
|
|
|
259
|
+
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
244
260
|
export function splitRepositoryPattern(repositoryPattern: string): string[] {
|
|
245
261
|
const patterns = repositoryPattern.split('/');
|
|
246
|
-
const repoPattern = patterns.
|
|
247
|
-
const ownerPattern = patterns
|
|
262
|
+
const repoPattern = patterns.slice(1).join('/')
|
|
263
|
+
const ownerPattern = patterns[0];
|
|
248
264
|
return [ownerPattern, repoPattern];
|
|
249
265
|
}
|
|
250
266
|
}
|
|
@@ -591,6 +607,7 @@ export interface GithubAppPrebuildConfig {
|
|
|
591
607
|
branches?: boolean
|
|
592
608
|
pullRequests?: boolean
|
|
593
609
|
pullRequestsFromForks?: boolean
|
|
610
|
+
addCheck?: boolean | 'prevent-merge-on-error'
|
|
594
611
|
addBadge?: boolean
|
|
595
612
|
addLabel?: boolean | string
|
|
596
613
|
addComment?: boolean
|
|
@@ -662,6 +679,17 @@ export namespace PrebuiltWorkspace {
|
|
|
662
679
|
}
|
|
663
680
|
}
|
|
664
681
|
|
|
682
|
+
export interface PrebuiltWorkspaceUpdatable {
|
|
683
|
+
id: string;
|
|
684
|
+
prebuiltWorkspaceId: string;
|
|
685
|
+
owner: string;
|
|
686
|
+
repo: string;
|
|
687
|
+
isResolved: boolean;
|
|
688
|
+
installationId: string;
|
|
689
|
+
issue?: string;
|
|
690
|
+
contextUrl?: string;
|
|
691
|
+
}
|
|
692
|
+
|
|
665
693
|
export interface WhitelistedRepository {
|
|
666
694
|
url: string
|
|
667
695
|
name: string
|
|
@@ -787,15 +815,14 @@ export namespace WithSnapshot {
|
|
|
787
815
|
}
|
|
788
816
|
}
|
|
789
817
|
|
|
790
|
-
export interface WithPrebuild {
|
|
791
|
-
snapshotBucketId: string;
|
|
818
|
+
export interface WithPrebuild extends WithSnapshot {
|
|
792
819
|
prebuildWorkspaceId: string;
|
|
793
820
|
wasPrebuilt: true;
|
|
794
821
|
}
|
|
795
822
|
export namespace WithPrebuild {
|
|
796
823
|
export function is(context: any): context is WithPrebuild {
|
|
797
824
|
return context
|
|
798
|
-
&&
|
|
825
|
+
&& WithSnapshot.is(context)
|
|
799
826
|
&& 'prebuildWorkspaceId' in context
|
|
800
827
|
&& 'wasPrebuilt' in context;
|
|
801
828
|
}
|
|
@@ -864,8 +891,20 @@ export namespace PrebuiltWorkspaceContext {
|
|
|
864
891
|
}
|
|
865
892
|
}
|
|
866
893
|
|
|
894
|
+
export interface WithReferrerContext extends WorkspaceContext {
|
|
895
|
+
referrer: string
|
|
896
|
+
referrerIde?: string
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
export namespace WithReferrerContext {
|
|
900
|
+
export function is(context: any): context is WithReferrerContext {
|
|
901
|
+
return context
|
|
902
|
+
&& 'referrer' in context;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
867
906
|
export interface WithEnvvarsContext extends WorkspaceContext {
|
|
868
|
-
envvars:
|
|
907
|
+
envvars: EnvVarWithValue[];
|
|
869
908
|
}
|
|
870
909
|
|
|
871
910
|
export namespace WithEnvvarsContext {
|
|
@@ -1163,39 +1202,6 @@ export namespace AuthProviderEntry {
|
|
|
1163
1202
|
}
|
|
1164
1203
|
}
|
|
1165
1204
|
|
|
1166
|
-
export interface Branding {
|
|
1167
|
-
readonly name: string;
|
|
1168
|
-
readonly favicon?: string;
|
|
1169
|
-
/** Either including domain OR absolute path (interpreted relative to host URL) */
|
|
1170
|
-
readonly logo: string;
|
|
1171
|
-
readonly startupLogo: string;
|
|
1172
|
-
readonly showProductivityTips: boolean;
|
|
1173
|
-
readonly redirectUrlIfNotAuthenticated?: string;
|
|
1174
|
-
readonly redirectUrlAfterLogout?: string;
|
|
1175
|
-
readonly homepage: string;
|
|
1176
|
-
readonly ide?: {
|
|
1177
|
-
readonly logo: string;
|
|
1178
|
-
readonly showReleaseNotes: boolean;
|
|
1179
|
-
readonly helpMenu: Branding.Link[];
|
|
1180
|
-
}
|
|
1181
|
-
readonly links: {
|
|
1182
|
-
readonly header: Branding.Link[];
|
|
1183
|
-
readonly footer: Branding.Link[];
|
|
1184
|
-
readonly social: Branding.SocialLink[];
|
|
1185
|
-
readonly legal: Branding.Link[];
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
export namespace Branding {
|
|
1189
|
-
export interface Link {
|
|
1190
|
-
readonly name: string;
|
|
1191
|
-
readonly url: string;
|
|
1192
|
-
}
|
|
1193
|
-
export interface SocialLink {
|
|
1194
|
-
readonly type: string;
|
|
1195
|
-
readonly url: string;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
1205
|
export interface Configuration {
|
|
1200
1206
|
readonly daysBeforeGarbageCollection: number;
|
|
1201
1207
|
readonly garbageCollectionStartDate: number;
|
|
@@ -42,7 +42,13 @@ export namespace Project {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface Overview {
|
|
45
|
-
branches: BranchDetails[]
|
|
45
|
+
branches: BranchDetails[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export namespace Overview {
|
|
49
|
+
export function is(data?: any): data is Project.Overview {
|
|
50
|
+
return Array.isArray(data?.branches);
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
export interface BranchDetails {
|
|
@@ -34,6 +34,7 @@ const expect = chai.expect
|
|
|
34
34
|
['gitpod-io','gitpod','gitpodio-gitpod-'],
|
|
35
35
|
['this is rather long and has some "§$"% special chars','also here pretty long and needs abbreviation','thisisratherlon-alsohere-'],
|
|
36
36
|
['breatheco-de', 'python-flask-api-tutorial', 'breathecode-pythonflaska-'],
|
|
37
|
+
['UPPER', "CaSe", "upper-case-"]
|
|
37
38
|
]
|
|
38
39
|
for (const d of data) {
|
|
39
40
|
const id = await generateWorkspaceID(d[0], d[1]);
|
|
@@ -15,6 +15,7 @@ function clean(segment: string | undefined, maxChars: number = 15) {
|
|
|
15
15
|
if (!segment) {
|
|
16
16
|
return undefined;
|
|
17
17
|
}
|
|
18
|
+
segment = segment.toLowerCase();
|
|
18
19
|
let result = '';
|
|
19
20
|
for (let i =0; i < segment.length; i++) {
|
|
20
21
|
if (characters.indexOf(segment[i]) !== -1) {
|
|
@@ -108,10 +108,6 @@ export class GitpodHostUrl {
|
|
|
108
108
|
return this.with(url => ({ pathname: '/preferences' }));
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
asGraphQLApi(): GitpodHostUrl {
|
|
112
|
-
return this.with(url => ({ pathname: '/graphql/' }));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
111
|
asStart(workspaceId = this.workspaceId): GitpodHostUrl {
|
|
116
112
|
return this.withoutWorkspacePrefix().with({
|
|
117
113
|
pathname: '/start/',
|
|
@@ -154,7 +150,7 @@ export class GitpodHostUrl {
|
|
|
154
150
|
return undefined;
|
|
155
151
|
}
|
|
156
152
|
|
|
157
|
-
get blobServe(): boolean
|
|
153
|
+
get blobServe(): boolean {
|
|
158
154
|
const hostSegments = this.url.host.split(".");
|
|
159
155
|
if (hostSegments[0] === 'blobserve') {
|
|
160
156
|
return true;
|
package/src/util/tracing.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as opentracing from 'opentracing';
|
|
9
9
|
import { TracingConfig, initTracerFromEnv } from 'jaeger-client';
|
|
10
10
|
import { Sampler, SamplingDecision } from './jaeger-client-types';
|
|
11
|
-
import {
|
|
11
|
+
import { initGlobalTracer } from 'opentracing';
|
|
12
12
|
import { injectable } from 'inversify';
|
|
13
13
|
import { ResponseError } from 'vscode-jsonrpc';
|
|
14
14
|
import { log, LogContext } from './logging';
|
|
@@ -22,15 +22,19 @@ export type TraceContextWithSpan = TraceContext & {
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
export namespace TraceContext {
|
|
25
|
-
export function startSpan(operation: string, parentCtx?: TraceContext
|
|
25
|
+
export function startSpan(operation: string, parentCtx?: TraceContext): opentracing.Span {
|
|
26
26
|
const options: opentracing.SpanOptions = {};
|
|
27
|
-
if (parentCtx) {
|
|
27
|
+
if (parentCtx && parentCtx.span && !!parentCtx.span.context().toSpanId()) {
|
|
28
28
|
options.childOf = parentCtx.span;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
// }
|
|
34
38
|
|
|
35
39
|
return opentracing.globalTracer().startSpan(operation, options);
|
|
36
40
|
}
|
|
@@ -40,6 +44,24 @@ export namespace TraceContext {
|
|
|
40
44
|
return { span };
|
|
41
45
|
}
|
|
42
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();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
43
65
|
export function setError(ctx: TraceContext, err: Error) {
|
|
44
66
|
if (!ctx.span) {
|
|
45
67
|
return;
|
package/src/workspace-cluster.ts
CHANGED
|
@@ -35,9 +35,6 @@ export interface WorkspaceCluster {
|
|
|
35
35
|
|
|
36
36
|
// An optional set of constraints that limit who can start workspaces on the cluster
|
|
37
37
|
admissionConstraints?: AdmissionConstraint[];
|
|
38
|
-
|
|
39
|
-
// An optional set of admission preferences that guide cluster selection
|
|
40
|
-
admissionPreferences?: AdmissionPreference[];
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
export type WorkspaceClusterState = "available" | "cordoned" | "draining";
|
|
@@ -55,14 +52,25 @@ export namespace TLSConfig {
|
|
|
55
52
|
export type WorkspaceClusterWoTLS = Omit<WorkspaceCluster, "tls">;
|
|
56
53
|
export type WorkspaceManagerConnectionInfo = Pick<WorkspaceCluster, "name" | "url" | "tls">;
|
|
57
54
|
|
|
58
|
-
export type AdmissionConstraint = AdmissionConstraintFeaturePreview |
|
|
55
|
+
export type AdmissionConstraint = AdmissionConstraintFeaturePreview | AdmissionConstraintHasPermission | AdmissionConstraintHasUserLevel | AdmissionConstraintHasMoreResources;
|
|
59
56
|
export type AdmissionConstraintFeaturePreview = { type: "has-feature-preview" };
|
|
60
|
-
export type
|
|
57
|
+
export type AdmissionConstraintHasPermission = { type: "has-permission", permission: PermissionName };
|
|
61
58
|
export type AdmissionConstraintHasUserLevel = { type: "has-user-level", level: string };
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export
|
|
65
|
-
|
|
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
|
+
}
|
|
66
74
|
|
|
67
75
|
export const WorkspaceClusterDB = Symbol("WorkspaceClusterDB");
|
|
68
76
|
export interface WorkspaceClusterDB {
|
|
@@ -51,6 +51,11 @@ export interface WorkspaceInstance {
|
|
|
51
51
|
|
|
52
52
|
// instance is hard-deleted on the database and about to be collected by db-sync
|
|
53
53
|
readonly deleted?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Contains information about the image build, if there was any
|
|
57
|
+
*/
|
|
58
|
+
imageBuildInfo?: ImageBuildInfo;
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
// WorkspaceInstanceStatus describes the current state of a workspace instance
|
|
@@ -213,3 +218,18 @@ export interface WorkspaceInstanceConfiguration {
|
|
|
213
218
|
// supervisorImage is the ref of the supervisor image this instance uses.
|
|
214
219
|
supervisorImage?: string;
|
|
215
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 },
|
|
235
|
+
}
|
|
@@ -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,34 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ConnectionErrorHandler = void 0;
|
|
10
|
-
const logging_1 = require("../util/logging");
|
|
11
|
-
class ConnectionErrorHandler {
|
|
12
|
-
constructor(options) {
|
|
13
|
-
this.restarts = [];
|
|
14
|
-
this.options = Object.assign({ maxErrors: 3, maxRestarts: 5, restartInterval: 3 }, options);
|
|
15
|
-
}
|
|
16
|
-
shouldStop(error, message, count) {
|
|
17
|
-
return !count || count > this.options.maxErrors;
|
|
18
|
-
}
|
|
19
|
-
shouldRestart() {
|
|
20
|
-
this.restarts.push(Date.now());
|
|
21
|
-
if (this.restarts.length <= this.options.maxRestarts) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
const diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
|
|
25
|
-
if (diff <= this.options.restartInterval * 60 * 1000) {
|
|
26
|
-
logging_1.log.error(`Server ${this.options.serverName} crashed ${this.options.maxRestarts} times in the last ${this.options.restartInterval} minutes. Will not restart`);
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
this.restarts.shift();
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.ConnectionErrorHandler = ConnectionErrorHandler;
|
|
34
|
-
//# 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,6CAAsC;AAsBtC,MAAa,sBAAsB;IAG/B,YAAY,OAAsC;QAa/B,aAAQ,GAAa,EAAE,CAAC;QAZvC,IAAI,CAAC,OAAO,mBACR,SAAS,EAAE,CAAC,EACZ,WAAW,EAAE,CAAC,EACd,eAAe,EAAE,CAAC,IACf,OAAO,CACb,CAAC;IACN,CAAC;IAED,UAAU,CAAC,KAAY,EAAE,OAAiB,EAAE,KAAc;QACtD,OAAO,CAAC,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACpD,CAAC;IAGD,aAAa;QACT,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,MAAM,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,UAAU,IAAI,CAAC,OAAO,CAAC,UAAU,YAAY,IAAI,CAAC,OAAO,CAAC,WAAW,sBAAsB,IAAI,CAAC,OAAO,CAAC,eAAe,4BAA4B,CAAC,CAAC;YAC/J,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ;AA/BD,wDA+BC"}
|
|
@@ -1,11 +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
|
-
import { LogContext } from './logging';
|
|
7
|
-
export declare class SafePromise {
|
|
8
|
-
static catchAndLog<T>(p: Promise<T>, logCtx?: LogContext): Promise<T>;
|
|
9
|
-
static catch<T>(p: Promise<T>, handler: (err: any) => void): Promise<T>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=safe-promise.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safe-promise.d.ts","sourceRoot":"","sources":["../../src/util/safe-promise.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAO,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,qBAAa,WAAW;WACN,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,UAAU;WASjD,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC;CAMjF"}
|
package/lib/util/safe-promise.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
4
|
-
* Licensed under the GNU Affero General Public License (AGPL).
|
|
5
|
-
* See License-AGPL.txt in the project root for license information.
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.SafePromise = void 0;
|
|
9
|
-
const logging_1 = require("./logging");
|
|
10
|
-
class SafePromise {
|
|
11
|
-
static catchAndLog(p, logCtx) {
|
|
12
|
-
return SafePromise.catch(p, (err) => {
|
|
13
|
-
if (logCtx) {
|
|
14
|
-
logging_1.log.error(logCtx, err);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
logging_1.log.error(err);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
;
|
|
22
|
-
static catch(p, handler) {
|
|
23
|
-
return p.catch((err) => {
|
|
24
|
-
handler(err);
|
|
25
|
-
return {}; // Nobody will ever see this value as the Promise already failed. It's just there to please the compiler
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
;
|
|
29
|
-
}
|
|
30
|
-
exports.SafePromise = SafePromise;
|
|
31
|
-
//# sourceMappingURL=safe-promise.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"safe-promise.js","sourceRoot":"","sources":["../../src/util/safe-promise.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,uCAA4C;AAE5C,MAAa,WAAW;IACb,MAAM,CAAC,WAAW,CAAI,CAAa,EAAE,MAAmB;QAC3D,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;YAChC,IAAI,MAAM,EAAE;gBACR,aAAG,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;aAC1B;iBAAM;gBACH,aAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aAClB;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAAA,CAAC;IACK,MAAM,CAAC,KAAK,CAAI,CAAa,EAAE,OAA2B;QAC7D,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,OAAO,CAAC,GAAG,CAAC,CAAC;YACb,OAAO,EAAO,CAAC,CAAC,wGAAwG;QAC5H,CAAC,CAAC,CAAC;IACP,CAAC;IAAA,CAAC;CACL;AAhBD,kCAgBC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (C) 2017 TypeFox and others.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
5
|
-
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { Message } from "vscode-jsonrpc";
|
|
9
|
-
import { log } from '../util/logging';
|
|
10
|
-
|
|
11
|
-
export interface ResolvedConnectionErrorHandlerOptions {
|
|
12
|
-
readonly serverName: string
|
|
13
|
-
/**
|
|
14
|
-
* The maximum amount of errors allowed before stopping the server.
|
|
15
|
-
*/
|
|
16
|
-
readonly maxErrors: number
|
|
17
|
-
/**
|
|
18
|
-
* The maimum amount of restarts allowed in the restart interval.
|
|
19
|
-
*/
|
|
20
|
-
readonly maxRestarts: number
|
|
21
|
-
/**
|
|
22
|
-
* In minutes.
|
|
23
|
-
*/
|
|
24
|
-
readonly restartInterval: number
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type ConnectionErrorHandlerOptions = Partial<ResolvedConnectionErrorHandlerOptions> & {
|
|
28
|
-
readonly serverName: string
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export class ConnectionErrorHandler {
|
|
32
|
-
|
|
33
|
-
protected readonly options: ResolvedConnectionErrorHandlerOptions;
|
|
34
|
-
constructor(options: ConnectionErrorHandlerOptions) {
|
|
35
|
-
this.options = {
|
|
36
|
-
maxErrors: 3,
|
|
37
|
-
maxRestarts: 5,
|
|
38
|
-
restartInterval: 3,
|
|
39
|
-
...options
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
shouldStop(error: Error, message?: Message, count?: number): boolean {
|
|
44
|
-
return !count || count > this.options.maxErrors;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected readonly restarts: number[] = [];
|
|
48
|
-
shouldRestart(): boolean {
|
|
49
|
-
this.restarts.push(Date.now());
|
|
50
|
-
if (this.restarts.length <= this.options.maxRestarts) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
const diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
|
|
54
|
-
if (diff <= this.options.restartInterval * 60 * 1000) {
|
|
55
|
-
log.error(`Server ${this.options.serverName} crashed ${this.options.maxRestarts} times in the last ${this.options.restartInterval} minutes. Will not restart`);
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
this.restarts.shift();
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}
|
package/src/util/safe-promise.ts
DELETED
|
@@ -1,26 +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
|
-
|
|
8
|
-
import { log, LogContext } from './logging';
|
|
9
|
-
|
|
10
|
-
export class SafePromise {
|
|
11
|
-
public static catchAndLog<T>(p: Promise<T>, logCtx?: LogContext) {
|
|
12
|
-
return SafePromise.catch(p, (err) => {
|
|
13
|
-
if (logCtx) {
|
|
14
|
-
log.error(logCtx, err);
|
|
15
|
-
} else {
|
|
16
|
-
log.error(err);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
public static catch<T>(p: Promise<T>, handler: (err: any) => void): Promise<T> {
|
|
21
|
-
return p.catch((err) => {
|
|
22
|
-
handler(err);
|
|
23
|
-
return {} as T; // Nobody will ever see this value as the Promise already failed. It's just there to please the compiler
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
}
|