Summary
cleanupInternalSearchResources and cleanupInternalTimeseriesResources differ only in component name. Similarly, ensureSearchStatefulSet and ensureTimeseriesStatefulSet are 180+ lines each with near-identical structure. This duplication increases maintenance burden and risk of divergence — a fix applied to one but not the other creates subtle bugs.
Detailed Requirements
Extract common helper functions:
cleanupInternalComponentResources(ctx, server, componentName) — replaces both cleanup functions
buildStatefulSetSpec(componentName, config) or similar — replaces both ensure functions
Component-specific configuration (ports, paths, environment variables) should be passed as parameters or a config struct.
Location
internal/controller/axonopsserver_controller.go:1043-1157 (cleanup functions)
internal/controller/axonopsserver_controller.go:1548-1747 (ensureSearchStatefulSet)
internal/controller/axonopsserver_controller.go:1862-2117 (ensureTimeseriesStatefulSet)
Acceptance Criteria
- Single
cleanupInternalComponentResources function replaces both cleanup functions
- Common StatefulSet builder replaces both ensure functions
- Component-specific config (ports, paths, env vars, image) passed as parameters or config struct
- All existing tests pass without behavioral changes
- Diff shows net reduction in lines of code
Testing Requirements
- All existing unit tests pass unchanged
- New unit tests for the extracted helper functions with different component configs
- Verify both Search and TimeSeries StatefulSets are functionally identical to before
Documentation Requirements
- Add godoc to the new helper functions explaining the parameterization
Dependencies
Summary
cleanupInternalSearchResourcesandcleanupInternalTimeseriesResourcesdiffer only in component name. Similarly,ensureSearchStatefulSetandensureTimeseriesStatefulSetare 180+ lines each with near-identical structure. This duplication increases maintenance burden and risk of divergence — a fix applied to one but not the other creates subtle bugs.Detailed Requirements
Extract common helper functions:
cleanupInternalComponentResources(ctx, server, componentName)— replaces both cleanup functionsbuildStatefulSetSpec(componentName, config)or similar — replaces both ensure functionsComponent-specific configuration (ports, paths, environment variables) should be passed as parameters or a config struct.
Location
internal/controller/axonopsserver_controller.go:1043-1157(cleanup functions)internal/controller/axonopsserver_controller.go:1548-1747(ensureSearchStatefulSet)internal/controller/axonopsserver_controller.go:1862-2117(ensureTimeseriesStatefulSet)Acceptance Criteria
cleanupInternalComponentResourcesfunction replaces both cleanup functionsTesting Requirements
Documentation Requirements
Dependencies