MCPcopy Create free account
hub / github.com/coder/coder / CanSkipReconciliation

Method CanSkipReconciliation

coderd/prebuilds/preset_snapshot.go:92–126  ·  view source on GitHub ↗

CanSkipReconciliation returns true if this preset can safely be skipped during the reconciliation loop. This is a performance optimization to avoid spawning goroutines for presets that have no work to do. It only returns true for presets from inactive template versions that have no running workspac

()

Source from the content-addressed store, hash-verified

90// template versions that have no running workspaces, no pending jobs, and no
91// in-progress builds.
92func (p PresetSnapshot) CanSkipReconciliation() bool {
93 // Active presets are never skipped. Presets from active template versions always
94 // go through the reconciliation loop to ensure desired_instances is maintained correctly.
95 if p.isActive() {
96 return false
97 }
98
99 // Inactive presets with running prebuilds means there are prebuilds to delete.
100 if len(p.Running) > 0 {
101 return false
102 }
103
104 // Inactive presets with expired prebuilds means there are expired prebuilds to delete.
105 if len(p.Expired) > 0 {
106 return false
107 }
108
109 // Inactive presets with pending jobs means there are pending jobs to cancel.
110 if p.PendingCount > 0 {
111 return false
112 }
113
114 // Backoff is only populated for active presets, but check defensively.
115 if p.Backoff != nil {
116 return false
117 }
118
119 // Fields not checked (only relevant for active presets):
120 // - PrebuildSchedules: Only affects desired instance calculation.
121 // - InProgress: Only populated for active template versions.
122 // - IsHardLimited: Only populated for active template versions.
123
124 // Inactive preset with nothing to clean up: safe to skip.
125 return true
126}
127
128// ReconciliationState represents the processed state of a preset's prebuilds,
129// calculated from a PresetSnapshot. While PresetSnapshot contains raw data,

Callers 2

ReconcileAllMethod · 0.80

Calls 1

isActiveMethod · 0.95

Tested by 1