@@ -368,31 +368,13 @@ export class WorkspaceStarter {
368
368
workspace . context ,
369
369
) ;
370
370
371
- const forceRebuild = ! ! workspace . context . forceImageBuild ;
372
- try {
373
- // if we need to build the workspace image we must not wait for actuallyStartWorkspace to return as that would block the
374
- // frontend until the image is built.
375
- const additionalAuth = await this . getAdditionalImageAuth ( envVars ) ;
376
- const needsImageBuild =
377
- forceRebuild || ( await this . needsImageBuild ( ctx , user , workspace , instance , additionalAuth ) ) ;
378
- if ( needsImageBuild ) {
379
- instance . status . conditions = {
380
- neededImageBuild : true ,
381
- } ;
382
- }
383
- ctx . span ?. setTag ( "needsImageBuild" , needsImageBuild ) ;
384
- } catch ( err ) {
385
- // if we fail to check if the workspace needs an image build (e.g. becuase the image builder is unavailable),
386
- // we must properly fail the workspace instance, i.e. set its status to stopped, deal with prebuilds etc.
387
- //
388
- // Once we've reached actuallyStartWorkspace that function will take care of failing the instance.
389
- await this . failInstanceStart ( ctx , err , workspace , instance , abortSignal ) ;
390
- throw err ;
391
- }
392
-
393
- await this . actuallyStartWorkspace ( ctx , instance , workspace , user , envVars , abortSignal , forceRebuild ) ;
371
+ await this . actuallyStartWorkspace ( ctx , instance , workspace , user , envVars , abortSignal ) ;
394
372
} catch ( err ) {
395
- log . error ( { instanceId } , "error in reconcileWorkspaceStart" , err ) ;
373
+ this . logAndTraceStartWorkspaceError (
374
+ ctx ,
375
+ { userId : user . id , workspaceId : workspace . id , instanceId } ,
376
+ err ,
377
+ ) ;
396
378
} finally {
397
379
ctx . span . finish ( ) ;
398
380
}
@@ -532,7 +514,6 @@ export class WorkspaceStarter {
532
514
user : User ,
533
515
envVars : ResolvedEnvVars ,
534
516
abortSignal : RedlockAbortSignal ,
535
- forceRebuild ?: boolean ,
536
517
) : Promise < void > {
537
518
const span = TraceContext . startSpan ( "actuallyStartWorkspace" , ctx ) ;
538
519
const region = instance . configuration . regionPreference ;
@@ -543,6 +524,7 @@ export class WorkspaceStarter {
543
524
organizationId : workspace . organizationId ,
544
525
workspaceId : workspace . id ,
545
526
} ;
527
+ const forceRebuild = ! ! workspace . context . forceImageBuild ;
546
528
log . info ( logCtx , "Attempting to start workspace" , {
547
529
forceRebuild : forceRebuild ,
548
530
} ) ;
@@ -1216,6 +1198,18 @@ export class WorkspaceStarter {
1216
1198
const span = TraceContext . startSpan ( "buildWorkspaceImage" , ctx ) ;
1217
1199
1218
1200
try {
1201
+ // TODO(gpl) I looks like we really don't need the whole "needsImageBuild" anymore:
1202
+ // Before we used it to distinguish between sync/async, now we are always async.
1203
+ // Still keeping it here for now to understand whether there are any side effects in image-builder-mk3
1204
+ const needsImageBuild =
1205
+ forceRebuild || ( await this . needsImageBuild ( ctx , user , workspace , instance , additionalAuth ) ) ;
1206
+ if ( needsImageBuild ) {
1207
+ instance . status . conditions = {
1208
+ neededImageBuild : true ,
1209
+ } ;
1210
+ }
1211
+ ctx . span ?. setTag ( "needsImageBuild" , needsImageBuild ) ;
1212
+
1219
1213
// Start build...
1220
1214
const client = await this . getImageBuilderClient ( user , workspace , instance , region ) ;
1221
1215
const { src, auth, disposable } = await this . prepareBuildRequest (
@@ -1352,7 +1346,11 @@ export class WorkspaceStarter {
1352
1346
await this . failInstanceStart ( { span } , err , workspace , instance , abortSignal ) ;
1353
1347
1354
1348
const looksLikeUserError = ( msg : string ) : boolean => {
1355
- return msg . startsWith ( "build failed:" ) || msg . includes ( "headless task failed:" ) ;
1349
+ return (
1350
+ msg . startsWith ( "build failed:" ) ||
1351
+ msg . includes ( "headless task failed:" ) ||
1352
+ msg . includes ( "cannot resolve image" )
1353
+ ) ;
1356
1354
} ;
1357
1355
if ( looksLikeUserError ( message ) ) {
1358
1356
log . info (
0 commit comments