Skip to content

Commit

Permalink
fix(kuma-cp) meshInsight has info about Dataplane twice (bp #1458) (#…
Browse files Browse the repository at this point in the history
…1459)

* fix(kuma-cp) meshInsight has info about Dataplane twice (#1458)

* feat(kuma-cp) calc dp only once, get read of noisy logs

Signed-off-by: Ilya Lobkov <ilya.lobkov@konghq.com>
(cherry picked from commit b198aac)

* fix(*) failing test

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>

Co-authored-by: Ilya Lobkov <ilya.lobkov@konghq.com>
Co-authored-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
  • Loading branch information
3 people authored Jan 22, 2021
1 parent 5e6b9e2 commit 270de3a
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 5 deletions.
5 changes: 5 additions & 0 deletions api/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
Expand All @@ -15,7 +16,9 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7
github.com/envoyproxy/protoc-gen-validate v0.4.1 h1:7dLaJvASGRD7X49jSCSXXHwKPm0ZN9r9kJD+p+vS7dM=
github.com/envoyproxy/protoc-gen-validate v0.4.1/go.mod h1:E+IEazqdaWv3FrnGtZIu3b9fPFMK8AzeTTrk9SfVwWs=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
Expand Down Expand Up @@ -116,6 +119,7 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand All @@ -141,6 +145,7 @@ google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
45 changes: 45 additions & 0 deletions go.sum

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pkg/insights/resyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ func (r *resyncer) createOrUpdateMeshInsight(mesh string) error {
return err
}
switch resType {
case core_mesh.DataplaneType:
insight.Dataplanes.Total = uint32(len(list.GetItems()))
case core_mesh.DataplaneInsightType:
for _, dpInsight := range list.(*core_mesh.DataplaneInsightResourceList).Items {
dpSubscription, _ := dpInsight.Spec.GetLatestSubscription()
Expand All @@ -299,7 +301,6 @@ func (r *resyncer) createOrUpdateMeshInsight(mesh string) error {
insight.DpVersions.KumaDp[kumaDpVersion].Offline++
insight.DpVersions.Envoy[envoyVersion].Offline++
}
insight.Dataplanes.Total = insight.Dataplanes.Online + insight.Dataplanes.Offline
updateTotal(kumaDpVersion, insight.DpVersions.KumaDp)
updateTotal(envoyVersion, insight.DpVersions.Envoy)
}
Expand Down
24 changes: 21 additions & 3 deletions pkg/insights/resyncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ var _ = Describe("Insight Persistence", func() {
}, "10s", "100ms").Should(BeNil())

// then
Expect(meshInsight.Spec.Dataplanes.Total).To(Equal(uint32(3)))
Expect(meshInsight.Spec.Dataplanes.Offline).To(Equal(uint32(3)))

kumaDp := meshInsight.Spec.DpVersions.KumaDp
Expect(kumaDp["unknown"].Total).To(Equal(uint32(1)))
Expect(kumaDp["unknown"].Offline).To(Equal(uint32(1)))
Expand All @@ -180,4 +177,25 @@ var _ = Describe("Insight Persistence", func() {
Expect(envoy["1.15.0"].Total).To(Equal(uint32(2)))
Expect(envoy["1.15.0"].Offline).To(Equal(uint32(2)))
})

It("should not count dataplane as a policy", func() {
err := rm.Create(context.Background(), core_mesh.NewMeshResource(), store.CreateByKey("mesh-1", model.NoMesh))
Expect(err).ToNot(HaveOccurred())

err = rm.Create(context.Background(), &core_mesh.DataplaneResource{Spec: samples.Dataplane}, store.CreateByKey("dp-1", "mesh-1"))
Expect(err).ToNot(HaveOccurred())

nowMtx.Lock()
now = now.Add(61 * time.Second)
nowMtx.Unlock()
tickCh <- now

insight := core_mesh.NewMeshInsightResource()
Eventually(func() error {
return rm.Get(context.Background(), insight, store.GetByKey("mesh-1", model.NoMesh))
}, "10s", "100ms").Should(BeNil())
Expect(insight.Spec.Policies[string(core_mesh.DataplaneType)]).To(BeNil())
Expect(insight.Spec.Dataplanes.Total).To(Equal(uint32(1)))
Expect(insight.Spec.LastSync).To(MatchProto(proto.MustTimestampProto(now)))
})
})
Loading

0 comments on commit 270de3a

Please sign in to comment.