-
Notifications
You must be signed in to change notification settings - Fork 232
Description
What would you like to be added:
I propose refactoring the logic that constructs the datalayer.EndpointPool for Standalone mode (currently residing in cmd/epp/runner/runner.go) into a reusable library function.
Current State:
- Production:
runner.goparses CLI flags (--endpoint-selector,--endpoint-target-ports) and manually constructs theEndpointPoolstruct, performing logic like slice initialization and map conversion. - Testing:
test/integration/epp/harness.go(inWithStandaloneMode) manually reconstructs a similarEndpointPoolobject to inject into the Datastore, bypassing the CLI parsing logic entirely.
Proposed Change:
Extract the construction logic into a shared function (e.g., in pkg/epp/server or pkg/epp/datalayer):
func NewEndpointPoolFromOptions(namespace, name, selector string, targetPorts []int) (*datalayer.EndpointPool, error) {
// Logic to validate, initialize slices, and return the Pool
}Both cmd/epp/runner and test/integration/epp should use this shared function.
Why is this needed:
This addresses a wiring gap between our production binary and our hermetic integration tests.
Recently, a regression (#2092) occurred in Standalone mode where the target ports slice was copied incorrectly in runner.go, leading to a panic on startup. Even with the new integration tests for Standalone mode (#2175), this bug would not have been caught because the test harness re-implements the object construction logic instead of exercising the actual production code path.
By sharing this initialization code, we ensure that logic errors in configuration parsing are caught immediately by the integration suite.
Additional Context:
While a smoke E2E test for standalone mode (to be tracked in a separate ticket) would also catch this class of bug by running the actual binary, maintaining unit/integration parity is valuable for faster feedback loops and cheaper debugging. Both approaches are independently valuable.