Commit 23bf638
feat: plan-centric reconcile wiring (Steps 5-6) (#88)
* feat: plan-centric reconcile wiring (Steps 5-6)
Wire the plan foundations into the actual reconcile loop. This is the
behavioral change that makes Plan the central abstraction.
Step 5: Phase-aware BuildPlan + infrastructure tasks in plans
- buildBasePlan prepends ensure-data-pvc, apply-statefulset, apply-service
before sidecar tasks
- buildBootstrapPlan inserts ensure-data-pvc at start, apply-statefulset +
apply-service after teardown-bootstrap
- buildGenesisPlan includes infrastructure tasks before ceremony tasks
- All plans set TargetPhase: Running, FailedPhase: Failed
- Each mode planner's BuildPlan checks node phase: Pending builds init
plan, Running builds convergence plan (apply-statefulset + apply-service)
Step 6: Mutating ForNode + simplified reconcile loop
- ForNode(node) error — resumes active plan or builds new one, stamps
directly onto node.Status.Plan
- Reconcile loop: ensure finalizer → check Failed → reconcilePeers →
ForNode → persist new plan → ExecutePlan → emit metrics → runtime tasks
- Deleted: reconcilePending, reconcileInitializing, reconcileRunning,
transitionPhase, ensureNodeDataPVC, reconcileNodeStatefulSet,
reconcileNodeService, fieldOwner constant
- New plan is persisted via status patch before ExecutePlan runs (captures
patch base before ForNode mutates the in-memory object)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: code quality cleanup from adversarial review
Address all findings from the Kubernetes and Platform specialist reviews.
Must fix:
- Document deliberate empty FailedPhase on convergence plans (retry, not fail)
- Delete dead TestBootstrapMode test (passed but tested nothing)
- Replace non-asserting phase transition tests with proper executor test
Renames for clarity:
- ForNode → ResolvePlan (conveys mutation, not accessor)
- hadPlan → planAlreadyActive (self-documenting branch condition)
- nilPlanIfConvergence → clearCompletedConvergencePlan (says what it does)
Deduplication:
- Remove duplicate NeedsLongStartup from planner (noderesource has it)
- Consolidate fieldOwner into task.go (was duplicated across task files)
- Remove unused *SeiNode param from configureGenesisParams
- Add DefaultStatus() to taskBase, use in all fire-and-forget tasks
Test quality:
- Replace hardcoded Tasks[3] indices with findPlannedTask name-based lookup
- Add TestExecutePlan_ConvergencePlan_NilsOnCompletion
- Add TestExecutePlan_TaskFailure_SetsPlanFailedCondition
- Add comments to magic for-range-N loops explaining plan progression
Documentation:
- Add planner/doc.go explaining full plan lifecycle
- Document ResolvePlan contract (caller must capture patch base before calling)
- Fix truncated ResultRequeueImmediate comment
- Update CLAUDE.md Key Patterns with plan-driven reconciliation section
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: address PR comments — observedPhase, genesis params factory
- Rename prevPhase to observedPhase in controller.go
- Genesis plan uses genesisParamsForTaskType for genesis-specific tasks,
falls through to paramsForTaskType for shared tasks (infrastructure +
common sidecar). Eliminates the inline switch that duplicated the
params factory.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: genesis plan uses shared paramsForTaskType factory
buildGenesisPlan now follows the same pattern as buildBasePlan:
configApplyParams (with validator mode + overrides) is passed through
to the shared paramsForTaskType factory. genesisCeremonyParams only
handles the 4 ceremony-specific tasks (generate-identity, generate-gentx,
upload-genesis-artifacts, set-genesis-peers) and returns nil for
everything else, falling through to the shared factory.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: consolidate all task params into single paramsForTaskType factory
Move genesis ceremony task params (generate-identity, generate-gentx,
upload-genesis-artifacts, set-genesis-peers) into the shared
paramsForTaskType factory. Remove the separate genesisCeremonyParams
function — one factory handles all task types.
Genesis ceremony params are guarded by a nil check on
Validator.GenesisCeremony, extracted into genesisCeremonyTaskParams
helper for readability. buildGenesisPlan now calls paramsForTaskType
directly, same as every other plan builder.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: extract shared buildSidecarProgression, insertBefore returns error
Two structural improvements to plan composition:
1. Extract buildSidecarProgression — the insertBefore calls that build
the sidecar task sequence were duplicated between buildBasePlan and
buildBootstrapProgression. Now both delegate to a single shared
function, eliminating the drift risk.
2. insertBefore returns an error when the target task is not found,
instead of silently dropping the insertion. This catches plan
construction bugs at build time rather than producing silently
incomplete plans that run without the missing task.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: inline buildBootstrapProgression, document postBootstrap intent
Remove the one-line buildBootstrapProgression wrapper — buildBootstrapPlan
calls buildSidecarProgression directly. Add comment to
buildPostBootstrapProgression explaining it is intentionally separate
from the shared sidecar progression.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent b93d623 commit 23bf638
21 files changed
Lines changed: 620 additions & 515 deletions
File tree
- internal
- controller/node
- planner
- task
- platform/clusters/prod/protocol
- atlantic-2
- pacific-1
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
58 | 62 | | |
59 | 63 | | |
60 | | - | |
61 | 64 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
87 | 85 | | |
88 | 86 | | |
89 | | - | |
| 87 | + | |
90 | 88 | | |
91 | 89 | | |
92 | 90 | | |
93 | 91 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
97 | 100 | | |
98 | 101 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
| 102 | + | |
113 | 103 | | |
114 | 104 | | |
115 | | - | |
116 | 105 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
127 | 112 | | |
128 | | - | |
129 | | - | |
130 | 113 | | |
131 | | - | |
132 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
133 | 119 | | |
134 | 120 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
140 | 128 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
159 | 133 | | |
160 | 134 | | |
161 | 135 | | |
162 | | - | |
163 | | - | |
164 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
165 | 140 | | |
166 | 141 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | 142 | | |
177 | 143 | | |
178 | 144 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
191 | 148 | | |
192 | 149 | | |
193 | 150 | | |
| |||
226 | 183 | | |
227 | 184 | | |
228 | 185 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | 186 | | |
260 | 187 | | |
261 | 188 | | |
| |||
308 | 235 | | |
309 | 236 | | |
310 | 237 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
507 | 507 | | |
508 | | - | |
| 508 | + | |
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| |||
0 commit comments