Skip to content

Commit 02b2de9

Browse files
refactor: skip reconciliation for some presets (#17595)
1 parent 268a50c commit 02b2de9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

coderd/prebuilds/preset_snapshot.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ type ReconciliationActions struct {
7272
BackoffUntil time.Time
7373
}
7474

75+
func (ra *ReconciliationActions) IsNoop() bool {
76+
return ra.Create == 0 && len(ra.DeleteIDs) == 0 && ra.BackoffUntil.IsZero()
77+
}
78+
7579
// CalculateState computes the current state of prebuilds for a preset, including:
7680
// - Actual: Number of currently running prebuilds
7781
// - Desired: Number of prebuilds desired as defined in the preset

enterprise/coderd/prebuilds/reconcile.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
310310
return nil
311311
}
312312

313+
// Nothing has to be done.
314+
if !ps.Preset.UsingActiveVersion && actions.IsNoop() {
315+
logger.Debug(ctx, "skipping reconciliation for preset - nothing has to be done",
316+
slog.F("template_id", ps.Preset.TemplateID.String()), slog.F("template_name", ps.Preset.TemplateName),
317+
slog.F("template_version_id", ps.Preset.TemplateVersionID.String()), slog.F("template_version_name", ps.Preset.TemplateVersionName),
318+
slog.F("preset_id", ps.Preset.ID.String()), slog.F("preset_name", ps.Preset.Name))
319+
return nil
320+
}
321+
313322
// nolint:gocritic // ReconcilePreset needs Prebuilds Orchestrator permissions.
314323
prebuildsCtx := dbauthz.AsPrebuildsOrchestrator(ctx)
315324

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy