mirror of
https://github.com/coder/coder.git
synced 2026-09-21 20:51:01 +08:00
refactor: skip reconciliation for some presets (#17595)
This commit is contained in:
@@ -72,6 +72,10 @@ type ReconciliationActions struct {
|
||||
BackoffUntil time.Time
|
||||
}
|
||||
|
||||
func (ra *ReconciliationActions) IsNoop() bool {
|
||||
return ra.Create == 0 && len(ra.DeleteIDs) == 0 && ra.BackoffUntil.IsZero()
|
||||
}
|
||||
|
||||
// CalculateState computes the current state of prebuilds for a preset, including:
|
||||
// - Actual: Number of currently running prebuilds
|
||||
// - Desired: Number of prebuilds desired as defined in the preset
|
||||
|
||||
@@ -310,6 +310,15 @@ func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.Pres
|
||||
return nil
|
||||
}
|
||||
|
||||
// Nothing has to be done.
|
||||
if !ps.Preset.UsingActiveVersion && actions.IsNoop() {
|
||||
logger.Debug(ctx, "skipping reconciliation for preset - nothing has to be done",
|
||||
slog.F("template_id", ps.Preset.TemplateID.String()), slog.F("template_name", ps.Preset.TemplateName),
|
||||
slog.F("template_version_id", ps.Preset.TemplateVersionID.String()), slog.F("template_version_name", ps.Preset.TemplateVersionName),
|
||||
slog.F("preset_id", ps.Preset.ID.String()), slog.F("preset_name", ps.Preset.Name))
|
||||
return nil
|
||||
}
|
||||
|
||||
// nolint:gocritic // ReconcilePreset needs Prebuilds Orchestrator permissions.
|
||||
prebuildsCtx := dbauthz.AsPrebuildsOrchestrator(ctx)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user