Don't sort endpointSliceData objects

EndpointSliceCache cached EndpointSlices into endpointSliceData
objects, in part so it could sort the ports and addresses, so that if
those fields got reordered without otherwise changing, it would not
trigger an OnEndpointSliceUpdate().

However, the EndpointSlice controller and mirroring controller always
output the ports in the same order, and they never reorder the
addresses of an existing slice unless the set of addresses actually
changed. So in the normal case, sorting the data adds more work than
it saves.
This commit is contained in:
Dan Winship
2024-04-29 16:17:30 -04:00
parent 4946c1fde2
commit f956fdf240
2 changed files with 3 additions and 36 deletions

View File

@@ -370,7 +370,7 @@ func TestEsDataChanged(t *testing.T) {
ObjectMeta: objMeta,
Ports: []discovery.EndpointPort{port80, port443},
},
expectChanged: false,
expectChanged: true,
},
"port removed": {
cache: NewEndpointSliceCache("", v1.IPv4Protocol, nil, nil),
@@ -422,7 +422,7 @@ func TestEsDataChanged(t *testing.T) {
Ports: []discovery.EndpointPort{port443},
Endpoints: []discovery.Endpoint{endpoint2, endpoint1},
},
expectChanged: false,
expectChanged: true,
},
"identical with endpoint added": {
cache: NewEndpointSliceCache("", v1.IPv4Protocol, nil, nil),