From 92c9c7cd6fee1c21889dc710ecf0ec9584724236 Mon Sep 17 00:00:00 2001 From: krhitesh7 Date: Tue, 24 Sep 2024 13:28:25 +0530 Subject: [PATCH] Cleanup log2 --- go.mod | 1 - go.sum | 6 --- pkg/cache/v3/simple.go | 91 +++++++++++++++++++++--------------------- 3 files changed, 45 insertions(+), 53 deletions(-) diff --git a/go.mod b/go.mod index 1e570100d7..c7768ddd0f 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,6 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 google.golang.org/grpc v1.62.1 google.golang.org/protobuf v1.33.0 - github.com/rs/zerolog v1.31.0 ) require ( diff --git a/go.sum b/go.sum index 4795c0d9c0..c06f3f50da 100644 --- a/go.sum +++ b/go.sum @@ -1233,7 +1233,6 @@ github.com/cncf/xds/go v0.0.0-20230428030218-4003588d1b74/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ= github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM= -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -1285,7 +1284,6 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= @@ -1440,11 +1438,9 @@ github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuz github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= github.com/lyft/protoc-gen-star/v2 v2.0.1/go.mod h1:RcCdONR2ScXaYnQC5tUzxzlpA3WVYF7/opLeUgcQs/o= github.com/lyft/protoc-gen-star/v2 v2.0.3/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= @@ -1478,8 +1474,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= diff --git a/pkg/cache/v3/simple.go b/pkg/cache/v3/simple.go index 8d92841e32..29fa2d8ab9 100644 --- a/pkg/cache/v3/simple.go +++ b/pkg/cache/v3/simple.go @@ -29,7 +29,6 @@ import ( "github.com/envoyproxy/go-control-plane/pkg/cache/types" "github.com/envoyproxy/go-control-plane/pkg/log" "github.com/envoyproxy/go-control-plane/pkg/server/stream/v3" - log2 "github.com/rs/zerolog/log" ) // ResourceSnapshot is an abstract snapshot of a collection of resources that @@ -261,12 +260,12 @@ func (cache *snapshotCache) BatchUpsertResources(ctx context.Context, typ string } for name, r := range resourcesUpserted { - if typ == resource.EndpointType { - cla := r.Resource.(*endpoint.ClusterLoadAssignment) - if len(cla.Endpoints) == 0 { - log2.Info().Msgf("BatchUpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints)) - } - } + //if typ == resource.EndpointType { + // cla := r.Resource.(*endpoint.ClusterLoadAssignment) + // if len(cla.Endpoints) == 0 { + // log2.Info().Msgf("BatchUpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints)) + // } + //} currentResources.Items[name] = *r } @@ -276,6 +275,7 @@ func (cache *snapshotCache) BatchUpsertResources(ctx context.Context, typ string // Update snapshot.(*Snapshot).Resources[index] = currentResources + cache.snapshots[node] = snapshot // Respond deltas @@ -294,12 +294,12 @@ func (cache *snapshotCache) BatchUpsertResources(ctx context.Context, typ string resources := make(map[resource.Type][]types.ResourceWithTTL) resources[typ] = make([]types.ResourceWithTTL, 0) for _, r := range resourcesUpserted { - if typ == resource.EndpointType { - cla := r.Resource.(*endpoint.ClusterLoadAssignment) - if len(cla.Endpoints) == 0 { - log2.Info().Msgf("BatchUpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints)) - } - } + //if typ == resource.EndpointType { + // cla := r.Resource.(*endpoint.ClusterLoadAssignment) + // if len(cla.Endpoints) == 0 { + // log2.Info().Msgf("BatchUpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints)) + // } + //} resources[typ] = append(resources[typ], *r) } s, err := NewSnapshotWithTTLs("0", resources) @@ -341,12 +341,12 @@ func (cache *snapshotCache) UpsertResources(ctx context.Context, node string, ty } for name, r := range resourcesUpserted { - if typ == resource.EndpointType { - cla := r.Resource.(*endpoint.ClusterLoadAssignment) - if len(cla.Endpoints) == 0 { - log2.Info().Msgf("UpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints)) - } - } + //if typ == resource.EndpointType { + // cla := r.Resource.(*endpoint.ClusterLoadAssignment) + // if len(cla.Endpoints) == 0 { + // log2.Info().Msgf("UpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints)) + // } + //} currentResources.Items[name] = *r } @@ -371,12 +371,12 @@ func (cache *snapshotCache) UpsertResources(ctx context.Context, node string, ty resources := make(map[resource.Type][]types.ResourceWithTTL) resources[typ] = make([]types.ResourceWithTTL, 0) for _, r := range resourcesUpserted { - if typ == resource.EndpointType { - cla := r.Resource.(*endpoint.ClusterLoadAssignment) - if len(cla.Endpoints) == 0 { - log2.Info().Msgf("UpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints)) - } - } + //if typ == resource.EndpointType { + // cla := r.Resource.(*endpoint.ClusterLoadAssignment) + // if len(cla.Endpoints) == 0 { + // log2.Info().Msgf("UpsertResources: Writing claname=%s endpoints=%d", cla.ClusterName, len(cla.Endpoints)) + // } + //} resources[typ] = append(resources[typ], *r) } s, err := NewSnapshotWithTTLs("0", resources) @@ -986,27 +986,26 @@ func (cache *snapshotCache) respondDelta(ctx context.Context, snapshot ResourceS // We want to respond immediately for the first wildcard request in a stream, even if the response is empty // otherwise, envoy won't complete initialization if len(resp.Resources) > 0 || len(resp.RemovedResources) > 0 || (state.IsWildcard() && state.IsFirst()) { - changedResourceNames := make([]string, 0, len(resp.Resources)) - for _, rsc := range resp.Resources { - if resp.GetDeltaRequest().GetTypeUrl() != resource.EndpointType { - changedResourceNames = append(changedResourceNames, GetResourceName(rsc.Resource)) - } else { - cla := rsc.Resource.(*endpoint.ClusterLoadAssignment) - claName := GetResourceName(rsc.Resource) - changedResourceNames = append(changedResourceNames, fmt.Sprintf("%s:%d", GetResourceName(rsc.Resource), len(cla.Endpoints))) - // HACK - if (strings.Contains(claName, "tardis-") && len(cla.Endpoints) == 0) || - (strings.Contains(claName, "sc-sent-post-") && len(cla.Endpoints) == 0) || - (strings.Contains(claName, "mmoe-v2-1-image") && len(cla.Endpoints) == 0) || - (strings.Contains(claName, "mmoe-v2-1-video") && len(cla.Endpoints) == 0) { - log2.Info().Msgf("Skipping because %s has 0 endpoints", claName) - return nil, nil - } - } - } - nodeString := GetEnvoyNodeStr(resp.GetDeltaRequest().GetNode()) - log2.Info().Msgf("createDeltaResponse [changed][%s]: %v", nodeString, changedResourceNames) - log2.Info().Msgf("createDeltaResponse [removed][%s]: %v", nodeString, resp.RemovedResources) + //changedResourceNames := make([]string, 0, len(resp.Resources)) + //for _, rsc := range resp.Resources { + // if resp.GetDeltaRequest().GetTypeUrl() == resource.EndpointType { + // changedResourceNames = append(changedResourceNames, GetResourceName(rsc.Resource)) + // cla := rsc.Resource.(*endpoint.ClusterLoadAssignment) + // claName := GetResourceName(rsc.Resource) + // changedResourceNames = append(changedResourceNames, fmt.Sprintf("%s:%d", GetResourceName(rsc.Resource), len(cla.Endpoints))) + // // HACK + // if (strings.Contains(claName, "tardis-") && len(cla.Endpoints) == 0) || + // (strings.Contains(claName, "sc-sent-post-") && len(cla.Endpoints) == 0) || + // (strings.Contains(claName, "mmoe-v2-1-image") && len(cla.Endpoints) == 0) || + // (strings.Contains(claName, "mmoe-v2-1-video") && len(cla.Endpoints) == 0) { + // log2.Info().Msgf("Skipping because %s has 0 endpoints", claName) + // return nil, nil + // } + // nodeString := GetEnvoyNodeStr(resp.GetDeltaRequest().GetNode()) + // log2.Info().Msgf("createDeltaResponse [changed][%s]: %v", nodeString, changedResourceNames) + // log2.Info().Msgf("createDeltaResponse [removed][%s]: %v", nodeString, resp.RemovedResources) + // } + //} if cache.log != nil { cache.log.Debugf("node: %s, sending delta response for typeURL %s with resources: %v removed resources: %v with wildcard: %t", request.GetNode().GetId(), request.GetTypeUrl(), GetResourceWithTTLNames(resp.Resources), resp.RemovedResources, state.IsWildcard())