Probe: remove backwards-compatibility code when publishing reports

Removed to reduce CPU and memory usage in probes.

This code was added in August 2016 so that newer probes could be used
with older apps. Since then we have adopted the stance that new apps
will accept reports from old probes but not vice-versa, on a version
change.
This commit is contained in:
Bryan Boreham
2018-06-05 14:20:23 +00:00
parent eeb126116a
commit 009af5be0c
3 changed files with 1 additions and 53 deletions

View File

@@ -200,7 +200,7 @@ ForLoop:
}
}
if err := p.publisher.Publish(rpt.BackwardCompatible()); err != nil {
if err := p.publisher.Publish(rpt); err != nil {
log.Infof("publish: %v", err)
}
}

View File

@@ -6,7 +6,6 @@ import (
"strings"
"time"
"github.com/weaveworks/common/mtime"
"github.com/weaveworks/scope/common/xfer"
)
@@ -503,34 +502,6 @@ func (r Report) upgradeDNSRecords() Report {
return r
}
// BackwardCompatible returns a new backward-compatible report.
//
// This for now creates node's Controls from LatestControls.
func (r Report) BackwardCompatible() Report {
now := mtime.Now()
cp := r.Copy()
cp.WalkTopologies(func(topology *Topology) {
n := Nodes{}
for name, node := range topology.Nodes {
var controls []string
node.LatestControls.ForEach(func(k string, _ time.Time, v NodeControlData) {
if !v.Dead {
controls = append(controls, k)
}
})
if len(controls) > 0 {
node.Controls = NodeControls{
Timestamp: now,
Controls: MakeStringSet(controls...),
}
}
n[name] = node
}
topology.Nodes = n
})
return cp
}
// Sampling describes how the packet data sources for this report were
// sampled. It can be used to calculate effective sample rates. We can't
// just put the rate here, because that can't be accurately merged. Counts

View File

@@ -72,29 +72,6 @@ func TestNode(t *testing.T) {
}
}
func TestReportBackwardCompatibility(t *testing.T) {
mtime.NowForce(time.Now())
defer mtime.NowReset()
rpt := report.MakeReport()
controls := map[string]report.NodeControlData{
"dead": {
Dead: true,
},
"alive": {
Dead: false,
},
}
node := report.MakeNode("foo").WithLatestControls(controls)
expectedNode := node.WithControls("alive")
rpt.Pod.AddNode(node)
expected := report.MakeReport()
expected.Pod.AddNode(expectedNode)
got := rpt.BackwardCompatible()
if !s_reflect.DeepEqual(expected, got) {
t.Error(test.Diff(expected, got))
}
}
func TestReportUpgrade(t *testing.T) {
mtime.NowForce(time.Now())
defer mtime.NowReset()