@@ -29,7 +29,6 @@ import (
2929 "github.com/envoyproxy/go-control-plane/pkg/cache/types"
3030 "github.com/envoyproxy/go-control-plane/pkg/log"
3131 "github.com/envoyproxy/go-control-plane/pkg/server/stream/v3"
32- log2 "github.com/rs/zerolog/log"
3332)
3433
3534// ResourceSnapshot is an abstract snapshot of a collection of resources that
@@ -261,12 +260,12 @@ func (cache *snapshotCache) BatchUpsertResources(ctx context.Context, typ string
261260 }
262261
263262 for name , r := range resourcesUpserted {
264- if typ == resource .EndpointType {
265- cla := r .Resource .(* endpoint.ClusterLoadAssignment )
266- if len (cla .Endpoints ) == 0 {
267- log2 .Info ().Msgf ("BatchUpsertResources: Writing claname=%s endpoints=%d" , cla .ClusterName , len (cla .Endpoints ))
268- }
269- }
263+ // if typ == resource.EndpointType {
264+ // cla := r.Resource.(*endpoint.ClusterLoadAssignment)
265+ // if len(cla.Endpoints) == 0 {
266+ // log2.Info().Msgf("BatchUpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints))
267+ // }
268+ // }
270269 currentResources .Items [name ] = * r
271270 }
272271
@@ -276,6 +275,7 @@ func (cache *snapshotCache) BatchUpsertResources(ctx context.Context, typ string
276275
277276 // Update
278277 snapshot .(* Snapshot ).Resources [index ] = currentResources
278+
279279 cache .snapshots [node ] = snapshot
280280
281281 // Respond deltas
@@ -294,12 +294,12 @@ func (cache *snapshotCache) BatchUpsertResources(ctx context.Context, typ string
294294 resources := make (map [resource.Type ][]types.ResourceWithTTL )
295295 resources [typ ] = make ([]types.ResourceWithTTL , 0 )
296296 for _ , r := range resourcesUpserted {
297- if typ == resource .EndpointType {
298- cla := r .Resource .(* endpoint.ClusterLoadAssignment )
299- if len (cla .Endpoints ) == 0 {
300- log2 .Info ().Msgf ("BatchUpsertResources: Writing claname=%s endpoints=%d" , cla .ClusterName , len (cla .Endpoints ))
301- }
302- }
297+ // if typ == resource.EndpointType {
298+ // cla := r.Resource.(*endpoint.ClusterLoadAssignment)
299+ // if len(cla.Endpoints) == 0 {
300+ // log2.Info().Msgf("BatchUpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints))
301+ // }
302+ // }
303303 resources [typ ] = append (resources [typ ], * r )
304304 }
305305 s , err := NewSnapshotWithTTLs ("0" , resources )
@@ -341,12 +341,12 @@ func (cache *snapshotCache) UpsertResources(ctx context.Context, node string, ty
341341 }
342342
343343 for name , r := range resourcesUpserted {
344- if typ == resource .EndpointType {
345- cla := r .Resource .(* endpoint.ClusterLoadAssignment )
346- if len (cla .Endpoints ) == 0 {
347- log2 .Info ().Msgf ("UpsertResources: Writing claname=%s endpoints=%d" , cla .ClusterName , len (cla .Endpoints ))
348- }
349- }
344+ // if typ == resource.EndpointType {
345+ // cla := r.Resource.(*endpoint.ClusterLoadAssignment)
346+ // if len(cla.Endpoints) == 0 {
347+ // log2.Info().Msgf("UpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints))
348+ // }
349+ // }
350350 currentResources .Items [name ] = * r
351351 }
352352
@@ -371,12 +371,12 @@ func (cache *snapshotCache) UpsertResources(ctx context.Context, node string, ty
371371 resources := make (map [resource.Type ][]types.ResourceWithTTL )
372372 resources [typ ] = make ([]types.ResourceWithTTL , 0 )
373373 for _ , r := range resourcesUpserted {
374- if typ == resource .EndpointType {
375- cla := r .Resource .(* endpoint.ClusterLoadAssignment )
376- if len (cla .Endpoints ) == 0 {
377- log2 .Info ().Msgf ("UpsertResources: Writing claname=%s endpoints=%d" , cla .ClusterName , len (cla .Endpoints ))
378- }
379- }
374+ // if typ == resource.EndpointType {
375+ // cla := r.Resource.(*endpoint.ClusterLoadAssignment)
376+ // if len(cla.Endpoints) == 0 {
377+ // log2.Info().Msgf("UpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints))
378+ // }
379+ // }
380380 resources [typ ] = append (resources [typ ], * r )
381381 }
382382 s , err := NewSnapshotWithTTLs ("0" , resources )
@@ -986,27 +986,26 @@ func (cache *snapshotCache) respondDelta(ctx context.Context, snapshot ResourceS
986986 // We want to respond immediately for the first wildcard request in a stream, even if the response is empty
987987 // otherwise, envoy won't complete initialization
988988 if len (resp .Resources ) > 0 || len (resp .RemovedResources ) > 0 || (state .IsWildcard () && state .IsFirst ()) {
989- changedResourceNames := make ([]string , 0 , len (resp .Resources ))
990- for _ , rsc := range resp .Resources {
991- if resp .GetDeltaRequest ().GetTypeUrl () != resource .EndpointType {
992- changedResourceNames = append (changedResourceNames , GetResourceName (rsc .Resource ))
993- } else {
994- cla := rsc .Resource .(* endpoint.ClusterLoadAssignment )
995- claName := GetResourceName (rsc .Resource )
996- changedResourceNames = append (changedResourceNames , fmt .Sprintf ("%s:%d" , GetResourceName (rsc .Resource ), len (cla .Endpoints )))
997- // HACK
998- if (strings .Contains (claName , "tardis-" ) && len (cla .Endpoints ) == 0 ) ||
999- (strings .Contains (claName , "sc-sent-post-" ) && len (cla .Endpoints ) == 0 ) ||
1000- (strings .Contains (claName , "mmoe-v2-1-image" ) && len (cla .Endpoints ) == 0 ) ||
1001- (strings .Contains (claName , "mmoe-v2-1-video" ) && len (cla .Endpoints ) == 0 ) {
1002- log2 .Info ().Msgf ("Skipping because %s has 0 endpoints" , claName )
1003- return nil , nil
1004- }
1005- }
1006- }
1007- nodeString := GetEnvoyNodeStr (resp .GetDeltaRequest ().GetNode ())
1008- log2 .Info ().Msgf ("createDeltaResponse [changed][%s]: %v" , nodeString , changedResourceNames )
1009- log2 .Info ().Msgf ("createDeltaResponse [removed][%s]: %v" , nodeString , resp .RemovedResources )
989+ //changedResourceNames := make([]string, 0, len(resp.Resources))
990+ //for _, rsc := range resp.Resources {
991+ // if resp.GetDeltaRequest().GetTypeUrl() == resource.EndpointType {
992+ // changedResourceNames = append(changedResourceNames, GetResourceName(rsc.Resource))
993+ // cla := rsc.Resource.(*endpoint.ClusterLoadAssignment)
994+ // claName := GetResourceName(rsc.Resource)
995+ // changedResourceNames = append(changedResourceNames, fmt.Sprintf("%s:%d", GetResourceName(rsc.Resource), len(cla.Endpoints)))
996+ // // HACK
997+ // if (strings.Contains(claName, "tardis-") && len(cla.Endpoints) == 0) ||
998+ // (strings.Contains(claName, "sc-sent-post-") && len(cla.Endpoints) == 0) ||
999+ // (strings.Contains(claName, "mmoe-v2-1-image") && len(cla.Endpoints) == 0) ||
1000+ // (strings.Contains(claName, "mmoe-v2-1-video") && len(cla.Endpoints) == 0) {
1001+ // log2.Info().Msgf("Skipping because %s has 0 endpoints", claName)
1002+ // return nil, nil
1003+ // }
1004+ // nodeString := GetEnvoyNodeStr(resp.GetDeltaRequest().GetNode())
1005+ // log2.Info().Msgf("createDeltaResponse [changed][%s]: %v", nodeString, changedResourceNames)
1006+ // log2.Info().Msgf("createDeltaResponse [removed][%s]: %v", nodeString, resp.RemovedResources)
1007+ // }
1008+ //}
10101009 if cache .log != nil {
10111010 cache .log .Debugf ("node: %s, sending delta response for typeURL %s with resources: %v removed resources: %v with wildcard: %t" ,
10121011 request .GetNode ().GetId (), request .GetTypeUrl (), GetResourceWithTTLNames (resp .Resources ), resp .RemovedResources , state .IsWildcard ())
0 commit comments