Repository navigation
refactor(bridge): share endpoint health probe and wrapperRef alias lookup - #1077
Merged
Merged
Conversation
…okup Extract probeEndpointHealth (endpoint_health_probe.go) as the single implementation of the active endpoint probe (skip on empty endpoint or nil prober, call Probe, report a nil result as errNilProbeResult). BridgeProber.probe3PEndpoint and Reconciler.verifyEndpointHealth now delegate to it and keep only their caller-specific message/reason mapping, so observable status, messages and timeouts are unchanged. ParseWrapperRef now resolves target coordinates through parseWrapperRef and ToBridgeWrapperRef, so the crdGroup/group, crdVersion/version, crdKind/kind, targetName/name and targetNamespace/namespace aliases are declared once. Add table-driven tests for probeEndpointHealth, verifyEndpointHealth's reason/message mapping, the BridgeProber probe-error message, and wrapperRef alias precedence/fallback. TAG=agy CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
There was a problem hiding this comment.
Code Review
This pull request consolidates active health probing logic by introducing a shared probeEndpointHealth helper function in endpoint_health_probe.go, refactoring bridge_prober.go and wrapper_reconciler.go to use it. It also refactors ParseWrapperRef in spec_parser.go to reuse existing parsing helpers and avoid duplicate key alias definitions, and adds corresponding unit tests. There are no review comments, and I have no feedback to provide.
VLukiantsev
marked this pull request as ready for review
October 6, 2026 07:23
pachopepe
approved these changes
Oct 6, 2026
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.
Summary
Removes two duplicated pieces of logic in
pkg/components/bridge:BridgeProber.probe3PEndpointandReconciler.verifyEndpointHealtheach implemented separately.wrapperRefkey aliases thatparseWrapperRefandParseWrapperRefeach declared.Motivation & Context
These copies were found during the bridge SRP work. They aren't part of any file split, so they go in their own PR. Each copy could drift on its own; for example, a fix to the nil-result handling or a new key alias would have to be made twice.
Key Changes
endpoint_health_probe.go:probeEndpointHealth(ctx, prober, endpoint, timeout).errNilProbeResult.endpointProberinterface defined where it's used, whichHealthProberandStatusDetectorHealthProberboth satisfy.BridgeProber.Probereplaces with the same configured default as before.ParseWrapperRefnow gets group, version, kind, name and namespace throughparseWrapperRefandToBridgeWrapperRef, so each alias pair is declared once. The JSONPath fields stay inParseWrapperRef, the only function that uses them.TestProbeEndpointHealth;TestVerifyEndpointHealth, covering every Reconciler reason and message (no direct coverage before);TestBridgeProber_ProbeHealthMessageFallbacks;TestParseWrapperRef_KeyAliases, covering which key wins over its alias and the fallback.Assumptions
health probe error: ...vsHealth probe failed for <ep>: ...). I treated that as deliberate per-caller behaviour and kept it, rather than picking one. If they should match, that's a one-line follow-up.BridgeProberbuilt without ahealthProberreports healthy fromProbeHealth, butProbeFailedthrough the Reconciler'sProbepath. That inconsistency was already there and this PR doesn't change it.Verification & Testing
bazel test //pkg/components/bridge:bridge_test --test_output=errors --runs_per_test=3: passes.bazel build //pkg/components/... //cmd/xmc_bridge/...: passes.dupl, test determinism checker, addlicense): passes.Related Issues / Bugs
N/A
TAG=agy
CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399