Skip to content

Commit f6ea98b

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

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

enterprise/coderd/prebuilds/reconcile.go

Lines changed: 9 additions & 7 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{
@@ -456,6 +450,14 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
456450
actions.Create = desired
457451
}
458452

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

461463
for range actions.Create {

0 commit comments

Comments
 (0)