Skip to content

Commit ebfafc9

Browse files
authored
Merge pull request #10 from ShareChat/cleanup-logs
Cleanup logs
2 parents ef534dd + 92c9c7c commit ebfafc9

3 files changed

Lines changed: 45 additions & 53 deletions

File tree

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80
1717
google.golang.org/grpc v1.62.1
1818
google.golang.org/protobuf v1.33.0
19-
github.com/rs/zerolog v1.31.0
2019
)
2120

2221
require (

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,6 @@ github.com/cncf/xds/go v0.0.0-20230428030218-4003588d1b74/go.mod h1:eXthEFrGJvWH
12331233
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
12341234
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ=
12351235
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM=
1236-
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
12371236
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
12381237
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
12391238
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
12851284
github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
12861285
github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
12871286
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
1288-
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
12891287
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
12901288
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
12911289
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
14401438
github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
14411439
github.com/lyft/protoc-gen-star/v2 v2.0.1/go.mod h1:RcCdONR2ScXaYnQC5tUzxzlpA3WVYF7/opLeUgcQs/o=
14421440
github.com/lyft/protoc-gen-star/v2 v2.0.3/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk=
1443-
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
14441441
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
14451442
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
14461443
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
1447-
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
14481444
github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
14491445
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
14501446
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
14781474
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
14791475
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
14801476
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
1481-
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
1482-
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
14831477
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
14841478
github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk=
14851479
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=

pkg/cache/v3/simple.go

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)