Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9dd36a2

Browse files
refactor: skipping reconciliation for some of the presets
1 parent a78f0fc commit 9dd36a2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

coderd/prebuilds/preset_snapshot.go

+4
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

+9
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)