Skip to content

Commit 01b9f84

Browse files
committed
wip: Error: upstream ended with status code: 5
Fix ingress (workspaceId = instanceId :rolling_eyes:)
1 parent d9f2f7f commit 01b9f84

File tree

4 files changed

+301
-14
lines changed

4 files changed

+301
-14
lines changed
Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
annotations:
5+
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
6+
cni.projectcalico.org/containerID: 78c6692ea7cf6c22a6bf9cc704d99d8219e072f5f5eb36ae1691af7e5a0b9454
7+
cni.projectcalico.org/podIP: 10.96.0.199/32
8+
cni.projectcalico.org/podIPs: 10.96.0.199/32
9+
container.apparmor.security.beta.kubernetes.io/workspace: unconfined
10+
gitpod.io/annotation.baseref: eu.gcr.io/gitpod-core-dev/build/base-images:6e13a0b27c3f29aea0fc8d42b2380bc7f954ec20ca98e49272efdfe60511a870
11+
gitpod.io/annotation.ref: eu.gcr.io/gitpod-core-dev/build/workspace-images:19330680f27bc747638cfaafb972455e994c5ff8cdc0b6fceabb76a966dc49e7
12+
gitpod.io/nodeName: gke-core-dev-workspace-0-068e0fea-rnw6
13+
gitpod.io/requiredNodeServices: ws-daemon,registry-facade
14+
gitpod/admission: admit_owner_only
15+
gitpod/contentInitializer: EsYBCidodHRwczovL2dpdGh1Yi5jb20vZ2Vyb3BsL3JvYm9yYWxseS5naXQYASIoZjRmNjExY2NjMjFkNzVlYWIyMzk0NzE0OGE4OGJiZWQ2YjYyNWMzMioBLjJsEAIqaGh0dHBzOi8vZ3BsLTc4NzQtaW1hZ2VidWlsZC1sb2dzLnN0YWdpbmcuZ2l0cG9kLWRldi5jb20vYXBpL290cy9nZXQvNTczOTJjYWQtNjRkZi00YjJjLWIyZWQtNDRhNWZmMTczZTAx
16+
gitpod/customTimeout: 1h0m0s
17+
gitpod/id: dcbc91f9-f78f-408d-b473-6a910f59fecd
18+
gitpod/imageSpec: Cl5ldS5nY3IuaW8vZ2l0cG9kLWNvcmUtZGV2L2J1aWxkL2ltYWdlLWJ1aWxkZXItbWszL2JvYjpjNmZkYzhmMzZkZWZkNDZiMDdlZGUxZGQ3YTI5NDg0NmYxMDkzYzUxEl5ldS5nY3IuaW8vZ2l0cG9kLWNvcmUtZGV2L2J1aWxkL2ltYWdlLWJ1aWxkZXItbWszL2JvYjpjNmZkYzhmMzZkZWZkNDZiMDdlZGUxZGQ3YTI5NDg0NmYxMDkzYzUx
19+
gitpod/never-ready: "true"
20+
gitpod/ownerToken: PYqwDarFJ7fzRWkAk0TxZ-60FwedsXDT
21+
gitpod/servicePrefix: dcbc91f9-f78f-408d-b473-6a910f59fecd
22+
gitpod/url: https://dcbc91f9-f78f-408d-b473-6a910f59fecd.ws-dev.gpl-7874-imagebuild-logs.staging.gitpod-dev.com
23+
kubernetes.io/psp: staging-gpl-7874-imagebuild-logs-ns-workspace
24+
prometheus.io/path: /metrics
25+
prometheus.io/port: "23000"
26+
prometheus.io/scrape: "true"
27+
seccomp.security.alpha.kubernetes.io/pod: localhost/workspace_default_gpl-7874-imagebuild-logs.5.json
28+
creationTimestamp: "2022-01-28T15:21:24Z"
29+
finalizers:
30+
- gitpod.io/finalizer
31+
labels:
32+
app: gitpod
33+
component: workspace
34+
gitpod.io/networkpolicy: default
35+
gpwsman: "true"
36+
headless: "true"
37+
metaID: dcbc91f9-f78f-408d-b473-6a910f59fecd
38+
owner: image-builder
39+
workspaceID: dcbc91f9-f78f-408d-b473-6a910f59fecd
40+
workspaceType: imagebuild
41+
name: imagebuild-dcbc91f9-f78f-408d-b473-6a910f59fecd
42+
namespace: staging-gpl-7874-imagebuild-logs
43+
resourceVersion: "162293199"
44+
uid: 3daa17d6-d97a-42f2-855d-73c3a65d105c
45+
spec:
46+
affinity:
47+
nodeAffinity:
48+
requiredDuringSchedulingIgnoredDuringExecution:
49+
nodeSelectorTerms:
50+
- matchExpressions:
51+
- key: gitpod.io/workload_workspace_headless
52+
operator: Exists
53+
- key: gitpod.io/ws-daemon_ready_ns_staging-gpl-7874-imagebuild-logs
54+
operator: Exists
55+
- key: gitpod.io/registry-facade_ready_ns_staging-gpl-7874-imagebuild-logs
56+
operator: Exists
57+
- key: gitpod.io/workspace_0
58+
operator: Exists
59+
automountServiceAccountToken: false
60+
containers:
61+
- command:
62+
- /.supervisor/workspacekit
63+
- ring0
64+
env:
65+
- name: GITPOD_REPO_ROOT
66+
value: /workspace
67+
- name: GITPOD_CLI_APITOKEN
68+
value: -83OkRLY5gTgenlrHE447uqcWcJvfkXB
69+
- name: GITPOD_WORKSPACE_ID
70+
value: dcbc91f9-f78f-408d-b473-6a910f59fecd
71+
- name: GITPOD_INSTANCE_ID
72+
value: dcbc91f9-f78f-408d-b473-6a910f59fecd
73+
- name: GITPOD_THEIA_PORT
74+
value: "23000"
75+
- name: THEIA_WORKSPACE_ROOT
76+
value: /workspace/.gitpod
77+
- name: GITPOD_HOST
78+
value: https://gpl-7874-imagebuild-logs.staging.gitpod-dev.com
79+
- name: GITPOD_WORKSPACE_URL
80+
value: https://dcbc91f9-f78f-408d-b473-6a910f59fecd.ws-dev.gpl-7874-imagebuild-logs.staging.gitpod-dev.com
81+
- name: GITPOD_WORKSPACE_CLUSTER_HOST
82+
value: ws-dev.gpl-7874-imagebuild-logs.staging.gitpod-dev.com
83+
- name: THEIA_SUPERVISOR_ENDPOINT
84+
value: :22999
85+
- name: THEIA_WEBVIEW_EXTERNAL_ENDPOINT
86+
value: webview-{{hostname}}
87+
- name: THEIA_MINI_BROWSER_HOST_PATTERN
88+
value: browser-{{hostname}}
89+
- name: BOB_TARGET_REF
90+
value: localhost:8080/target:latest
91+
- name: BOB_BASE_REF
92+
value: localhost:8080/base:latest
93+
- name: BOB_BUILD_BASE
94+
value: "true"
95+
- name: BOB_DOCKERFILE_PATH
96+
value: /workspace/.gitpod/Dockerfile
97+
- name: BOB_CONTEXT_DIR
98+
value: /workspace/.gitpod
99+
- name: GITPOD_TASKS
100+
value: '[{"name": "build", "init": "sudo -E /app/bob build"}]'
101+
- name: WORKSPACEKIT_RING2_ENCLAVE
102+
value: /app/bob proxy
103+
- name: WORKSPACEKIT_BOBPROXY_BASEREF
104+
value: eu.gcr.io/gitpod-core-dev/build/base-images:6e13a0b27c3f29aea0fc8d42b2380bc7f954ec20ca98e49272efdfe60511a870
105+
- name: WORKSPACEKIT_BOBPROXY_TARGETREF
106+
value: eu.gcr.io/gitpod-core-dev/build/workspace-images:19330680f27bc747638cfaafb972455e994c5ff8cdc0b6fceabb76a966dc49e7
107+
- name: WORKSPACEKIT_BOBPROXY_AUTH
108+
valueFrom:
109+
secretKeyRef:
110+
key: .dockerconfigjson
111+
name: gcp-sa-registry-auth
112+
- name: SUPERVISOR_DEBUG_ENABLE
113+
value: "false"
114+
- name: GITPOD_INTERVAL
115+
value: "30000"
116+
- name: GITPOD_MEMORY
117+
value: "2147"
118+
- name: GITPOD_HEADLESS
119+
value: "true"
120+
image: reg.gpl-7874-imagebuild-logs.staging.gitpod-dev.com:30623/remote/dcbc91f9-f78f-408d-b473-6a910f59fecd
121+
imagePullPolicy: IfNotPresent
122+
name: workspace
123+
ports:
124+
- containerPort: 23000
125+
protocol: TCP
126+
readinessProbe:
127+
failureThreshold: 600
128+
httpGet:
129+
path: /_supervisor/v1/status/content/wait/true
130+
port: 22999
131+
scheme: HTTP
132+
initialDelaySeconds: 3
133+
periodSeconds: 1
134+
successThreshold: 1
135+
timeoutSeconds: 1
136+
resources:
137+
requests:
138+
cpu: "1"
139+
memory: 2Gi
140+
securityContext:
141+
allowPrivilegeEscalation: true
142+
capabilities:
143+
add:
144+
- AUDIT_WRITE
145+
- FSETID
146+
- KILL
147+
- NET_BIND_SERVICE
148+
- SYS_PTRACE
149+
drop:
150+
- SETPCAP
151+
- CHOWN
152+
- NET_RAW
153+
- DAC_OVERRIDE
154+
- FOWNER
155+
- SYS_CHROOT
156+
- SETFCAP
157+
- SETUID
158+
- SETGID
159+
privileged: false
160+
readOnlyRootFilesystem: false
161+
runAsGroup: 33333
162+
runAsNonRoot: true
163+
runAsUser: 33333
164+
terminationMessagePath: /dev/termination-log
165+
terminationMessagePolicy: File
166+
volumeMounts:
167+
- mountPath: /workspace
168+
mountPropagation: HostToContainer
169+
name: vol-this-workspace
170+
- mountPath: /.workspace
171+
mountPropagation: HostToContainer
172+
name: daemon-mount
173+
- mountPath: /usr/local/share/ca-certificates/gitpod-ca.crt
174+
name: gitpod-ca-certificate
175+
readOnly: true
176+
subPath: ca.crt
177+
dnsConfig:
178+
nameservers:
179+
- 1.1.1.1
180+
- 8.8.8.8
181+
dnsPolicy: None
182+
enableServiceLinks: false
183+
hostname: dcbc91f9-f78f-408d-b473-6a910f59fecd
184+
nodeName: gke-core-dev-workspace-0-068e0fea-rnw6
185+
preemptionPolicy: PreemptLowerPriority
186+
priority: 0
187+
restartPolicy: Never
188+
schedulerName: gke.io/optimize-utilization-scheduler
189+
securityContext:
190+
fsGroup: 1
191+
seccompProfile:
192+
localhostProfile: workspace_default_gpl-7874-imagebuild-logs.5.json
193+
type: Localhost
194+
supplementalGroups:
195+
- 1
196+
serviceAccount: workspace
197+
serviceAccountName: workspace
198+
terminationGracePeriodSeconds: 30
199+
tolerations:
200+
- effect: NoExecute
201+
key: node.kubernetes.io/disk-pressure
202+
operator: Exists
203+
- effect: NoExecute
204+
key: node.kubernetes.io/memory-pressure
205+
operator: Exists
206+
- effect: NoExecute
207+
key: node.kubernetes.io/network-unavailable
208+
operator: Exists
209+
tolerationSeconds: 30
210+
- effect: NoExecute
211+
key: node.kubernetes.io/not-ready
212+
operator: Exists
213+
tolerationSeconds: 300
214+
- effect: NoExecute
215+
key: node.kubernetes.io/unreachable
216+
operator: Exists
217+
tolerationSeconds: 300
218+
volumes:
219+
- hostPath:
220+
path: /var/gitpod/workspaces/dcbc91f9-f78f-408d-b473-6a910f59fecd
221+
type: DirectoryOrCreate
222+
name: vol-this-workspace
223+
- hostPath:
224+
path: /var/gitpod/workspaces/dcbc91f9-f78f-408d-b473-6a910f59fecd-daemon
225+
type: DirectoryOrCreate
226+
name: daemon-mount
227+
- name: gitpod-ca-certificate
228+
secret:
229+
defaultMode: 420
230+
items:
231+
- key: ca.crt
232+
path: ca.crt
233+
secretName: builtin-registry-facade-cert
234+
status:
235+
conditions:
236+
- lastProbeTime: null
237+
lastTransitionTime: "2022-01-28T15:21:24Z"
238+
status: "True"
239+
type: Initialized
240+
- lastProbeTime: null
241+
lastTransitionTime: "2022-01-28T15:21:28Z"
242+
status: "True"
243+
type: Ready
244+
- lastProbeTime: null
245+
lastTransitionTime: "2022-01-28T15:21:28Z"
246+
status: "True"
247+
type: ContainersReady
248+
- lastProbeTime: null
249+
lastTransitionTime: "2022-01-28T15:21:24Z"
250+
status: "True"
251+
type: PodScheduled
252+
containerStatuses:
253+
- containerID: containerd://2da82f31250b175fb9efc50dd44f784a9f01f56a5ff0972b5ba99e37ad62589f
254+
image: reg.gpl-7874-imagebuild-logs.staging.gitpod-dev.com:30623/remote/6e0074b5-01ca-4698-bd9e-d756d26ac58e:latest
255+
imageID: reg.gpl-7874-imagebuild-logs.staging.gitpod-dev.com:30623/remote/6e0074b5-01ca-4698-bd9e-d756d26ac58e@sha256:9252e17d266f6bd5014ff4d429744ce8261507a888d248887714c42adc05cc77
256+
lastState: {}
257+
name: workspace
258+
ready: true
259+
restartCount: 0
260+
started: true
261+
state:
262+
running:
263+
startedAt: "2022-01-28T15:21:25Z"
264+
hostIP: 10.132.0.11
265+
phase: Running
266+
podIP: 10.96.0.199
267+
podIPs:
268+
- ip: 10.96.0.199
269+
qosClass: Burstable
270+
startTime: "2022-01-28T15:21:24Z"

components/image-builder-api/typescript/src/sugar.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export class PromisifiedImageBuilderClient {
170170
resultResp.baseRef = resp.getBaseRef();
171171
}
172172

173-
log.warn(`BUILDINFO: ${JSON.stringify(resp.getInfo()?.toObject(), undefined, 2)}`)
174173
if (resp.hasInfo() && !logInfo.isResolved) {
175174
// assumes that log info stays stable for instance lifetime
176175
const info = resp.getInfo()

components/server/src/workspace/gitpod-server-impl.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,33 +1113,45 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
11131113
traceWI(ctx, { workspaceId });
11141114

11151115
const user = this.checkAndBlockUser("watchWorkspaceImageBuildLogs", undefined, { workspaceId });
1116-
const logCtx: LogContext = { userId: user.id, workspaceId };
1117-
11181116
const client = this.client;
11191117
if (!client) {
11201118
return;
11211119
}
11221120

1123-
const { instance, workspace } = await this.internGetCurrentWorkspaceInstance(ctx, workspaceId);
1121+
const logCtx: LogContext = { userId: user.id, workspaceId };
1122+
let { instance, workspace } = await this.internGetCurrentWorkspaceInstance(ctx, workspaceId);
11241123
if (!instance) {
11251124
log.debug(logCtx, `No running instance for workspaceId.`);
11261125
return;
11271126
}
11281127
traceWI(ctx, { instanceId: instance.id });
1129-
if (!workspace.imageNameResolved) {
1130-
log.debug(logCtx, `No imageNameResolved set for workspaceId, cannot watch logs.`);
1131-
return;
1132-
}
11331128
const teamMembers = await this.getTeamMembersByProject(workspace.projectId);
11341129
await this.guardAccess({ kind: "workspaceInstance", subject: instance, workspace, teamMembers }, "get");
11351130

1136-
if (!workspace.imageBuildLogInfo) {
1137-
log.warn(logCtx, "imageBuildLogInfo: fallback!");
1131+
// wait for up to 20s for imageBuildLogInfo to appear due to:
1132+
// - db-sync round-trip times
1133+
// - but also: wait until the image build actually started (image pull!), and log info is available!
1134+
for (let i = 0; i < 10; i++) {
1135+
if (workspace.imageBuildLogInfo) {
1136+
break;
1137+
}
1138+
await new Promise(resolve => setTimeout(resolve, 2000));
11381139

1140+
const ws = await this.workspaceDb.trace(ctx).findById(workspaceId);
1141+
if (!ws) {
1142+
log.warn(logCtx, `no workspace for workspaceId.`);
1143+
return;
1144+
}
1145+
workspace = ws;
1146+
}
1147+
1148+
if (!workspace.imageBuildLogInfo) {
11391149
// during roll-out this is our fall-back case.
1140-
// Afterwards we might want to do some spinning-lock and re-check for a certain perdio (30s?) to give db-sync
1150+
// Afterwards we might want to do some spinning-lock and re-check for a certain period (30s?) to give db-sync
11411151
// a change to move the imageBuildLogInfo across the globe.
1142-
await this.deprecatedDoWatchWorkspaceImageBuildLogs(ctx, logCtx, workspace.imageNameResolved);
1152+
1153+
log.warn(logCtx, "imageBuildLogInfo: fallback!");
1154+
await this.deprecatedDoWatchWorkspaceImageBuildLogs(ctx, logCtx, workspace);
11431155
return;
11441156
}
11451157

@@ -1177,12 +1189,17 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
11771189
}
11781190
}
11791191

1180-
protected async deprecatedDoWatchWorkspaceImageBuildLogs(ctx: TraceContext, logCtx: LogContext, imageNameResolved: string) {
1192+
protected async deprecatedDoWatchWorkspaceImageBuildLogs(ctx: TraceContext, logCtx: LogContext, workspace: Workspace) {
1193+
if (!workspace.imageNameResolved) {
1194+
log.debug(logCtx, `No imageNameResolved set for workspaceId, cannot watch logs.`);
1195+
return;
1196+
}
1197+
11811198
try {
11821199
const imgbuilder = this.imageBuilderClientProvider.getDefault();
11831200
const req = new LogsRequest();
11841201
req.setCensored(true);
1185-
req.setBuildRef(imageNameResolved);
1202+
req.setBuildRef(workspace.imageNameResolved);
11861203

11871204
let lineCount = 0;
11881205
imgbuilder.logs(ctx, req, data => {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ export class WorkspaceStarter {
572572
// Make sure we persist logInfo as soon as we retrieve it
573573
const imageBuildLogInfo = new Deferred<ImageBuildLogInfo>();
574574
imageBuildLogInfo.promise.then(async logInfo => {
575+
log.warn("IMAGE_BUILD_INFO resolved!");
575576
await this.workspaceDb.trace({span}).updatePartial(workspace.id, {
576577
imageBuildLogInfo: logInfo,
577578
}).catch(err => log.error("error writing image build log info to the DB", err));

0 commit comments

Comments
 (0)