From 11701af0a6de26ea399c48c0524d5816a3c7a230 Mon Sep 17 00:00:00 2001 From: John Murret Date: Tue, 7 Nov 2023 05:04:02 -0700 Subject: [PATCH] do not create endpoints resource when the endpoints array is empty. --- agent/xds/endpoints.go | 5 +++++ .../endpoints/lambda-connect-proxy-tproxy.latest.golden | 7 ------- .../xds/testdata/endpoints/transparent-proxy.latest.golden | 7 ------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/agent/xds/endpoints.go b/agent/xds/endpoints.go index 2fb0a4a1df598..bde4ad8cb3cd1 100644 --- a/agent/xds/endpoints.go +++ b/agent/xds/endpoints.go @@ -784,6 +784,11 @@ func (s *ResourceGenerator) endpointsFromDiscoveryChain( continue // skip the cluster if we're still populating the snapshot } + if len(endpointGroup.Endpoints) == 0 { + s.Logger.Trace("skipping endpoint generation because no endpoints found for target group", "cluster", clusterName) + continue // skip the cluster if we're still populating the snapshot + } + la := makeLoadAssignment( s.Logger, cfgSnap, diff --git a/agent/xds/testdata/builtin_extension/endpoints/lambda-connect-proxy-tproxy.latest.golden b/agent/xds/testdata/builtin_extension/endpoints/lambda-connect-proxy-tproxy.latest.golden index ebf0eb91d97e9..a0b07adefb2dd 100644 --- a/agent/xds/testdata/builtin_extension/endpoints/lambda-connect-proxy-tproxy.latest.golden +++ b/agent/xds/testdata/builtin_extension/endpoints/lambda-connect-proxy-tproxy.latest.golden @@ -90,13 +90,6 @@ ] } ] - }, - { - "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - "clusterName": "no-endpoints.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", - "endpoints": [ - {} - ] } ], "typeUrl": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", diff --git a/agent/xds/testdata/endpoints/transparent-proxy.latest.golden b/agent/xds/testdata/endpoints/transparent-proxy.latest.golden index ebf0eb91d97e9..a0b07adefb2dd 100644 --- a/agent/xds/testdata/endpoints/transparent-proxy.latest.golden +++ b/agent/xds/testdata/endpoints/transparent-proxy.latest.golden @@ -90,13 +90,6 @@ ] } ] - }, - { - "@type": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment", - "clusterName": "no-endpoints.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul", - "endpoints": [ - {} - ] } ], "typeUrl": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment",