Fix waypoint address missing in ebpf/endpoints when LocalityInfo is nil#1534
Fix waypoint address missing in ebpf/endpoints when LocalityInfo is nil#1534
Conversation
When locality LB mode is enabled (e.g., FAILOVER mode used by waypoints), the handleWorkloadNewBoundServices function was not adding workloads to service endpoints if p.locality.LocalityInfo was nil. This caused waypoint endpoints to be missing from the eBPF maps when: 1. No local workload had been processed yet 2. Waypoint workloads arrived before any local workload The fix ensures workloads are added with the lowest priority (len of routing preferences) when LocalityInfo is nil, ensuring the endpoint is added and will be recalculated when locality is eventually set. Co-authored-by: hzxuzhonghu <13374016+hzxuzhonghu@users.noreply.github.com>
Co-authored-by: hzxuzhonghu <13374016+hzxuzhonghu@users.noreply.github.com>
Co-authored-by: hzxuzhonghu <13374016+hzxuzhonghu@users.noreply.github.com>
|
Awesome work |
|
cc @imuxin |
| // If locality is not yet initialized, use lowest priority (len of routing preferences) | ||
| // This ensures the workload is added to the endpoint map and will be recalculated | ||
| // when locality is eventually set | ||
| prio = uint32(len(service.LoadBalancing.GetRoutingPreference())) |
Changed default priority from len(routingPreferences) to 0 as requested by reviewer. This ensures workloads are assigned the highest priority when locality information is not yet available. Co-authored-by: hzxuzhonghu <13374016+hzxuzhonghu@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug where waypoint addresses were missing from eBPF endpoint maps when using locality-based load balancing (like FAILOVER mode, which is the default for waypoints). The issue occurred when waypoint workloads arrived before any local workload was processed, leaving LocalityInfo uninitialized (nil).
Key changes:
- Modified
handleWorkloadNewBoundServicesto check ifLocalityInfois nil before callingCalcLocalityLBPrio - When
LocalityInfois nil, workloads are now assigned the highest priority (0) to ensure immediate addition to eBPF maps - Added comprehensive test
TestLocalityLBWithNilLocalityInfoto validate the fix
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/controller/workload/workload_processor.go | Added nil check for LocalityInfo before calculating locality-based priority; assigns highest priority (0) when nil to ensure workloads are added to endpoint maps immediately |
| pkg/controller/workload/workload_processor_test.go | Added test case validating that workloads are correctly added to service endpoints with priority 0 when LocalityInfo is nil in locality LB mode |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // This ensures the workload is added to the endpoint map and will be recalculated | ||
| // when locality is eventually set |
There was a problem hiding this comment.
[nitpick] The comment states that the endpoint "will be recalculated when locality is eventually set," but there's a TODO comment at line 572 in the same file indicating that endpoint priority recalculation upon locality initialization is not yet implemented. Consider updating this comment to be more accurate, such as:
// If locality is not yet initialized, use highest priority (0)
// This ensures the workload is added to the endpoint map immediately
// TODO: Priority should be recalculated when locality is eventually set (see line 572)| // This ensures the workload is added to the endpoint map and will be recalculated | |
| // when locality is eventually set | |
| // This ensures the workload is added to the endpoint map immediately | |
| // TODO: Priority should be recalculated when locality is eventually set (see line 572) |
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hzxuzhonghu The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
|
/retest |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Waypoint endpoints were missing from eBPF maps when
LocalityInfowas nil, causing "Connection reset by peer" errors.Root cause: In
handleWorkloadNewBoundServices, locality mode (FAILOVER, the waypoint default) requiredLocalityInfo != nilto add workloads to endpoints. SinceLocalityInfois only set when a local node workload is processed, waypoint workloads arriving first were silently dropped.Fix:
LocalityInfo != nilgate from the endpoint addition logicLocalityInfois nil, assign highest priority (0)Which issue(s) this PR fixes:
Fixes #1533
Special notes for your reviewer:
Test added:
TestLocalityLBWithNilLocalityInfovalidates workloads from other nodes are added to endpoints even when locality is uninitialized.Does this PR introduce a user-facing change?:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.