From f5a2c73edd18804476ba575a82d87f2daa3eaeb2 Mon Sep 17 00:00:00 2001 From: huabing zhao Date: Tue, 17 Oct 2023 10:29:05 +0800 Subject: [PATCH] fix resource order Signed-off-by: huabing zhao --- pkg/cache/types/types.go | 8 ++++---- pkg/cache/v3/order.go | 2 +- pkg/cache/v3/order_test.go | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/cache/types/types.go b/pkg/cache/types/types.go index de1dac8363..ffaf0a9774 100644 --- a/pkg/cache/types/types.go +++ b/pkg/cache/types/types.go @@ -43,12 +43,12 @@ type ResponseType int // ADS expects things to be returned in a specific order. // See the following issue for details: https://github.com/envoyproxy/go-control-plane/issues/526 const ( - Endpoint ResponseType = iota - Cluster - ScopedRoute + Cluster ResponseType = iota + Endpoint + Listener Route + ScopedRoute VirtualHost - Listener Secret Runtime ExtensionConfig diff --git a/pkg/cache/v3/order.go b/pkg/cache/v3/order.go index b27795022e..c416946e82 100644 --- a/pkg/cache/v3/order.go +++ b/pkg/cache/v3/order.go @@ -16,7 +16,7 @@ func (k keys) Len() int { // Less compares the typeURL and determines what order things should be sent. func (k keys) Less(i, j int) bool { - return GetResponseType(k[i].TypeURL) > GetResponseType(k[j].TypeURL) + return GetResponseType(k[i].TypeURL) < GetResponseType(k[j].TypeURL) } func (k keys) Swap(i, j int) { diff --git a/pkg/cache/v3/order_test.go b/pkg/cache/v3/order_test.go index bed86fd260..1ebb3f6f13 100644 --- a/pkg/cache/v3/order_test.go +++ b/pkg/cache/v3/order_test.go @@ -33,6 +33,14 @@ func TestOrderKeys(t *testing.T) { }, } expected := keys{ + { + ID: 2, + TypeURL: resource.ClusterType, + }, + { + ID: 1, + TypeURL: resource.EndpointType, + }, { ID: 4, TypeURL: resource.ListenerType, @@ -45,14 +53,6 @@ func TestOrderKeys(t *testing.T) { ID: 5, TypeURL: resource.ScopedRouteType, }, - { - ID: 2, - TypeURL: resource.ClusterType, - }, - { - ID: 1, - TypeURL: resource.EndpointType, - }, } orderedKeys := unorderedKeys