Skip to content

Commit 2f793fd

Browse files
authored
waypoint interop: specify Equals when waypointed services change (#58525)
* waypoint interop: specify Equals when waypointed services change * relnote * switch back to Equals
1 parent 2efb699 commit 2f793fd

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

pilot/pkg/serviceregistry/kube/controller/ambient/sidecar_interop.go

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,31 @@ import (
3333
// This is to map to the eventual EDS structure.
3434
type serviceEDS struct {
3535
ServiceKey string
36-
WaypointInstance []*workloadapi.Workload
36+
WaypointInstance []model.WorkloadInfo
3737
UseWaypoint bool
3838
}
3939

40-
func (w serviceEDS) ResourceName() string {
41-
return w.ServiceKey
40+
func (s serviceEDS) ResourceName() string {
41+
return s.ServiceKey
42+
}
43+
44+
func (s serviceEDS) Equals(other serviceEDS) bool {
45+
if s.ServiceKey != other.ServiceKey {
46+
return false
47+
}
48+
if s.UseWaypoint != other.UseWaypoint {
49+
return false
50+
}
51+
if len(s.WaypointInstance) != len(other.WaypointInstance) {
52+
return false
53+
}
54+
// assumes builder sorted the slices
55+
for i := range s.WaypointInstance {
56+
if !s.WaypointInstance[i].Equals(other.WaypointInstance[i]) {
57+
return false
58+
}
59+
}
60+
return true
4261
}
4362

4463
// RegisterEdsShim handles triggering xDS events when Envoy EDS needs to change.
@@ -93,12 +112,14 @@ func RegisterEdsShim(
93112
waypointServiceKey = waypointSvc.ResourceName()
94113
}
95114
workloads := krt.Fetch(ctx, Workloads, krt.FilterIndex(WorkloadsByServiceKey, waypointServiceKey))
115+
// for comparison in Equals
116+
workloads = slices.SortBy(workloads, func(i model.WorkloadInfo) string {
117+
return i.Workload.Uid
118+
})
96119
return &serviceEDS{
97-
ServiceKey: svc.ResourceName(),
98-
UseWaypoint: useWaypoint,
99-
WaypointInstance: slices.Map(workloads, func(e model.WorkloadInfo) *workloadapi.Workload {
100-
return e.Workload
101-
}),
120+
ServiceKey: svc.ResourceName(),
121+
UseWaypoint: useWaypoint,
122+
WaypointInstance: workloads,
102123
}
103124
},
104125
opts.WithName("ServiceEds")...)

releasenotes/notes/58525.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: release-notes/v2
2+
kind: bug-fix
3+
area: traffic-management
4+
releaseNotes:
5+
- |
6+
**Fixed** an issue where Envoy proxies that to Waypoint proxies would in rare cases
7+
either get extraraneous XDS updates or miss some updates entirely.

0 commit comments

Comments
 (0)