Repository navigation
refactor: decompose KapeHandlerReconciler into focused files (#51) - #144
Merged
Merged
Conversation
Split the 541-line handler.go into purpose-named files and replace the duplicated condition helpers with apimachinery stdlib equivalents. Pure internal refactor — no behaviour change. - Reconcile now delegates each responsibility (dependency gate, scaling gate, workload, label sync, status) to extracted step methods; body is 55 lines (was ~160). - handler_deps.go: resolvedDependencies + validateDependencies, with fetch/validation split into resolveSchema / resolveHandlerTool / resolveSkills. Reason constants live here. - handler_hash.go: computeRolloutHash as a free function. - handler_conditions.go: buildHandlerConditions + computeReadyRollup. - Removed findCond / isConditionTrue from production code; all call sites use meta.FindStatusCondition / meta.IsStatusConditionTrue. - testhelpers_test.go: single home for the shared findCondition and fakeConfigLoader test helpers (was declared in tool_test.go). Closes #51 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dzungtr
force-pushed
the
refactor/51-reconciler-decompose
branch
from
July 19, 2026 12:37
c127c33 to
47fa06d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Pure internal refactor of
operator/controller/reconcile/handler.go(was 541 lines, 14 functions) into purpose-named files. No behaviour change, no CRD changes.Changes
Reconcileslimmed to 55 lines (was ~160). It now delegates each responsibility to an extracted step method:gateDependencies,gateScaling,reconcileWorkload(+reconcileScaledObject),syncLabels,updateStatus.handler_deps.go—resolvedDependenciesstruct + itsEagerSkills/LazySkillsmethods,validateDependencies, and theunionToolMap/sortedToolsByNamehelpers. Fetch is split from validation viaresolveSchema/resolveHandlerTool/resolveSkills. Dependency reason constants live here.handler_hash.go—computeRolloutHashas a free function.handler_conditions.go—buildHandlerConditions+computeReadyRollup.findCond/isConditionTruefrom production code; every call site now usesmeta.FindStatusCondition/meta.IsStatusConditionTruefromk8s.io/apimachinery/pkg/api/meta(identical signatures, drop-in).testhelpers_test.go— single home for the sharedfindConditionandfakeConfigLoadertest helpers (previously declared intool_test.go).Verification
go build ./...— cleango vet ./controller/reconcile/...— cleango test ./operator/...— all green, no test assertions modifiedgolangci-lint run ./operator/controller/reconcile/...— no new errors (one pre-existingtool.go:174errcheck onresp.Body.Close()is untouched, out of scope)gofmtclean on all new/modified production filesAcceptance criteria
Reconcilebody ≤ 80 lines (55)handler_deps.go,handler_hash.go,handler_conditions.goexistfindCond/isConditionTrueremoved; call sites usemeta.*findConditiondeclaration (noDuplicateDecl)go test ./operator/...greenCloses #51
🤖 Generated with Claude Code