mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 10:11:03 +00:00
Merge pull request #3215 from weaveworks/remove-probe-backwards-compat
Probe: remove backwards-compatibility code when publishing reports
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user