mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-15 19:41:02 +00:00
Remove old 'Controls' field which was replaced two years ago
This saves memory and CPU time encoding and decoding. We assume that no probes that old are still running, and we don't need to reconstruct the data for saved historical reports because controls are not relevant to historical nodes.
This commit is contained in:
@@ -44,7 +44,6 @@ func makeTestReport() report.Report {
|
|||||||
r.Endpoint.AddNode(report.MakeNode(";172.20.1.168;41582").
|
r.Endpoint.AddNode(report.MakeNode(";172.20.1.168;41582").
|
||||||
WithTopology("endpoint").
|
WithTopology("endpoint").
|
||||||
WithSet("snooped_dns_names", report.MakeStringSet("ip-172-20-1-168.ec2.internal")).
|
WithSet("snooped_dns_names", report.MakeStringSet("ip-172-20-1-168.ec2.internal")).
|
||||||
WithControls("docker_remove_container").
|
|
||||||
WithLatestActiveControls("docker_pause_container").
|
WithLatestActiveControls("docker_pause_container").
|
||||||
WithLatest("addr", t1, "127.0.0.1"),
|
WithLatest("addr", t1, "127.0.0.1"),
|
||||||
)
|
)
|
||||||
@@ -57,7 +56,6 @@ func makeTestReport() report.Report {
|
|||||||
r.Pod.WithShape("heptagon").WithLabel("pod", "pods").
|
r.Pod.WithShape("heptagon").WithLabel("pod", "pods").
|
||||||
AddNode(report.MakeNode("fceef9592ec3cf1a8e1d178fdd0de41a;<pod>").
|
AddNode(report.MakeNode("fceef9592ec3cf1a8e1d178fdd0de41a;<pod>").
|
||||||
WithTopology("pod").
|
WithTopology("pod").
|
||||||
WithControls("kubernetes_delete_pod").
|
|
||||||
WithLatestControls(map[string]report.NodeControlData{"kubernetes_get_logs": {Dead: true}}).
|
WithLatestControls(map[string]report.NodeControlData{"kubernetes_get_logs": {Dead: true}}).
|
||||||
WithLatest("host_node_id", t1, "ip-172-20-1-168;<host>"))
|
WithLatest("host_node_id", t1, "ip-172-20-1-168;<host>"))
|
||||||
r.Overlay.WithMetadataTemplates(report.MetadataTemplates{
|
r.Overlay.WithMetadataTemplates(report.MetadataTemplates{
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ type Node struct {
|
|||||||
Counters Counters `json:"counters,omitempty"`
|
Counters Counters `json:"counters,omitempty"`
|
||||||
Sets Sets `json:"sets,omitempty"`
|
Sets Sets `json:"sets,omitempty"`
|
||||||
Adjacency IDList `json:"adjacency,omitempty"`
|
Adjacency IDList `json:"adjacency,omitempty"`
|
||||||
Controls NodeControls `json:"controls,omitempty"`
|
|
||||||
LatestControls NodeControlDataLatestMap `json:"latestControls,omitempty"`
|
LatestControls NodeControlDataLatestMap `json:"latestControls,omitempty"`
|
||||||
Latest StringLatestMap `json:"latest,omitempty"`
|
Latest StringLatestMap `json:"latest,omitempty"`
|
||||||
Metrics Metrics `json:"metrics,omitempty" deepequal:"nil==empty"`
|
Metrics Metrics `json:"metrics,omitempty" deepequal:"nil==empty"`
|
||||||
@@ -30,7 +29,6 @@ func MakeNode(id string) Node {
|
|||||||
Counters: MakeCounters(),
|
Counters: MakeCounters(),
|
||||||
Sets: MakeSets(),
|
Sets: MakeSets(),
|
||||||
Adjacency: MakeIDList(),
|
Adjacency: MakeIDList(),
|
||||||
Controls: MakeNodeControls(),
|
|
||||||
LatestControls: MakeNodeControlDataLatestMap(),
|
LatestControls: MakeNodeControlDataLatestMap(),
|
||||||
Latest: MakeStringLatestMap(),
|
Latest: MakeStringLatestMap(),
|
||||||
Metrics: Metrics{},
|
Metrics: Metrics{},
|
||||||
@@ -120,12 +118,6 @@ func (n Node) WithAdjacent(a ...string) Node {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithControls returns a fresh copy of n, with cs added to Controls.
|
|
||||||
func (n Node) WithControls(cs ...string) Node {
|
|
||||||
n.Controls = n.Controls.Add(cs...)
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithLatestActiveControls returns a fresh copy of n, with active controls cs added to LatestControls.
|
// WithLatestActiveControls returns a fresh copy of n, with active controls cs added to LatestControls.
|
||||||
func (n Node) WithLatestActiveControls(cs ...string) Node {
|
func (n Node) WithLatestActiveControls(cs ...string) Node {
|
||||||
lcs := map[string]NodeControlData{}
|
lcs := map[string]NodeControlData{}
|
||||||
@@ -199,7 +191,6 @@ func (n Node) Merge(other Node) Node {
|
|||||||
Counters: n.Counters.Merge(other.Counters),
|
Counters: n.Counters.Merge(other.Counters),
|
||||||
Sets: n.Sets.Merge(other.Sets),
|
Sets: n.Sets.Merge(other.Sets),
|
||||||
Adjacency: n.Adjacency.Merge(other.Adjacency),
|
Adjacency: n.Adjacency.Merge(other.Adjacency),
|
||||||
Controls: n.Controls.Merge(other.Controls),
|
|
||||||
LatestControls: n.LatestControls.Merge(other.LatestControls),
|
LatestControls: n.LatestControls.Merge(other.LatestControls),
|
||||||
Latest: n.Latest.Merge(other.Latest),
|
Latest: n.Latest.Merge(other.Latest),
|
||||||
Metrics: n.Metrics.Merge(other.Metrics),
|
Metrics: n.Metrics.Merge(other.Metrics),
|
||||||
|
|||||||
@@ -419,43 +419,8 @@ func (r Report) Validate() error {
|
|||||||
|
|
||||||
// Upgrade returns a new report based on a report received from the old probe.
|
// Upgrade returns a new report based on a report received from the old probe.
|
||||||
//
|
//
|
||||||
// This for now creates node's LatestControls from Controls.
|
|
||||||
func (r Report) Upgrade() Report {
|
func (r Report) Upgrade() Report {
|
||||||
return r.upgradeLatestControls().upgradePodNodes().upgradeNamespaces().upgradeDNSRecords()
|
return r.upgradePodNodes().upgradeNamespaces().upgradeDNSRecords()
|
||||||
}
|
|
||||||
|
|
||||||
func (r Report) upgradeLatestControls() Report {
|
|
||||||
needUpgrade := false
|
|
||||||
r.WalkTopologies(func(topology *Topology) {
|
|
||||||
for _, node := range topology.Nodes {
|
|
||||||
if node.LatestControls.Size() == 0 && len(node.Controls.Controls) > 0 {
|
|
||||||
needUpgrade = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if !needUpgrade {
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
cp := r.Copy()
|
|
||||||
ncd := NodeControlData{
|
|
||||||
Dead: false,
|
|
||||||
}
|
|
||||||
cp.WalkTopologies(func(topology *Topology) {
|
|
||||||
n := Nodes{}
|
|
||||||
for name, node := range topology.Nodes {
|
|
||||||
if node.LatestControls.Size() == 0 && len(node.Controls.Controls) > 0 {
|
|
||||||
for _, control := range node.Controls.Controls {
|
|
||||||
node.LatestControls = node.LatestControls.Set(control, node.Controls.Timestamp, ncd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
n[name] = node
|
|
||||||
}
|
|
||||||
topology.Nodes = n
|
|
||||||
})
|
|
||||||
|
|
||||||
return cp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Report) upgradePodNodes() Report {
|
func (r Report) upgradePodNodes() Report {
|
||||||
|
|||||||
@@ -82,14 +82,8 @@ func TestReportUpgrade(t *testing.T) {
|
|||||||
namespaceID := report.MakeNamespaceNodeID(namespaceName)
|
namespaceID := report.MakeNamespaceNodeID(namespaceName)
|
||||||
podNode := report.MakeNode("foo").
|
podNode := report.MakeNode("foo").
|
||||||
WithLatests(map[string]string{report.KubernetesNamespace: namespaceName}).
|
WithLatests(map[string]string{report.KubernetesNamespace: namespaceName}).
|
||||||
WithControls("alive").
|
|
||||||
WithParents(report.MakeSets().Add(report.ReplicaSet, report.MakeStringSet("bar")))
|
WithParents(report.MakeSets().Add(report.ReplicaSet, report.MakeStringSet("bar")))
|
||||||
controls := map[string]report.NodeControlData{
|
expectedPodNode := podNode.PruneParents().WithParents(parentsWithDeployment)
|
||||||
"alive": {
|
|
||||||
Dead: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
expectedPodNode := podNode.PruneParents().WithParents(parentsWithDeployment).WithLatestControls(controls)
|
|
||||||
rpt := report.MakeReport()
|
rpt := report.MakeReport()
|
||||||
rpt.ReplicaSet.AddNode(rsNode)
|
rpt.ReplicaSet.AddNode(rsNode)
|
||||||
rpt.Pod.AddNode(podNode)
|
rpt.Pod.AddNode(podNode)
|
||||||
|
|||||||
Reference in New Issue
Block a user