Skip to content

Commit 2667684

Browse files
fix: hard-limiting should only apply to creation of prebuilds
1 parent a1a4f2a commit 2667684

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

enterprise/coderd/prebuilds/reconcile.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,16 +365,10 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
365365
c.metrics.trackHardLimitedStatus(ps.Preset.OrganizationName, ps.Preset.TemplateName, ps.Preset.Name, ps.IsHardLimited)
366366
}
367367

368-
// If the preset was previously hard-limited, log it and exit early.
369-
if ps.Preset.PrebuildStatus == database.PrebuildStatusHardLimited {
370-
logger.Warn(ctx, "skipping hard limited preset")
371-
return nil
372-
}
373-
374368
// If the preset reached the hard failure limit for the first time during this iteration:
375369
// - Mark it as hard-limited in the database
376370
// - Send notifications to template admins
377-
if ps.IsHardLimited {
371+
if ps.Preset.PrebuildStatus != database.PrebuildStatusHardLimited && ps.IsHardLimited {
378372
logger.Warn(ctx, "skipping hard limited preset")
379373

380374
err := c.store.UpdatePresetPrebuildStatus(ctx, database.UpdatePresetPrebuildStatusParams{
@@ -388,10 +382,7 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
388382
err = c.notifyPrebuildFailureLimitReached(ctx, ps)
389383
if err != nil {
390384
logger.Error(ctx, "failed to notify that number of prebuild failures reached the limit", slog.Error(err))
391-
return nil
392385
}
393-
394-
return nil
395386
}
396387

397388
state := ps.CalculateState()
@@ -456,6 +447,14 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
456447
actions.Create = desired
457448
}
458449

450+
if actions.Create > 0 {
451+
// If the preset is hard-limited, log it and exit early.
452+
if ps.Preset.PrebuildStatus == database.PrebuildStatusHardLimited || ps.IsHardLimited {
453+
logger.Warn(ctx, "skipping hard limited preset")
454+
return nil
455+
}
456+
}
457+
459458
var multiErr multierror.Error
460459

461460
for range actions.Create {

0 commit comments

Comments
 (0)