Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Table model to PropertyList #2100

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions client/app/scripts/components/node-details.js
Original file line number Diff line number Diff line change
@@ -203,20 +203,22 @@ class NodeDetails extends React.Component {
</div>
))}

{details.tables && details.tables.length > 0 && details.tables.map((table) => {
if (table.rows.length > 0) {
{details.propertyLists && details.propertyLists.map((propertyList) => {
if (propertyList.rows.length > 0) {
return (
<div className="node-details-content-section" key={table.id}>
<div className="node-details-content-section" key={propertyList.id}>
<div className="node-details-content-section-header">
{table.label}
{table.truncationCount > 0 && <span
{propertyList.label}
{propertyList.truncationCount > 0 && <span
className="node-details-content-section-header-warning">
<Warning text={getTruncationText(table.truncationCount)} />
<Warning text={getTruncationText(propertyList.truncationCount)} />
</span>}
</div>
<NodeDetailsLabels
rows={table.rows} controls={table.controls}
matches={nodeMatches.get('tables')} />
rows={propertyList.rows}
controls={propertyList.controls}
matches={nodeMatches.get('propertyLists')}
/>
</div>
);
}
20 changes: 18 additions & 2 deletions client/app/scripts/utils/__tests__/search-utils-test.js
Original file line number Diff line number Diff line change
@@ -17,7 +17,15 @@ describe('SearchUtils', () => {
id: 'metric1',
label: 'Metric 1',
value: 1
}]
}],
propertyLists: [{
id: 'labels1',
rows: [{
id: 'label1',
label: 'Label 1',
value: 'Value 1'
}]
}],
},
n2: {
id: 'n2',
@@ -28,7 +36,7 @@ describe('SearchUtils', () => {
value: 'value 2'
}],
tables: [{
id: 'metric1',
id: 'table1',
rows: [{
id: 'row1',
label: 'Row 1',
@@ -242,6 +250,14 @@ describe('SearchUtils', () => {
expect(matches.size).toEqual(1);
expect(matches.getIn(['n2', 'tables', 'row1']).text).toBe('Row Value 1');
});

it('should match on a property lists field', () => {
const nodes = nodeSets.someNodes;
const matches = fun(nodes, {query: 'Value 1'});
expect(matches.size).toEqual(2);
expect(matches.getIn(['n2', 'tables', 'row1']).text).toBe('Row Value 1');
expect(matches.getIn(['n1', 'propertyLists', 'label1']).text).toBe('Value 1');
});
});

describe('updateNodeMatches', () => {
24 changes: 22 additions & 2 deletions client/app/scripts/utils/search-utils.js
Original file line number Diff line number Diff line change
@@ -148,7 +148,7 @@ export function searchTopology(nodes, { prefix, query, metric, comp, value }) {
});
}

// tables (envvars and labels)
// node tables
const tables = node.get('tables');
if (tables) {
tables.forEach((table) => {
@@ -161,6 +161,20 @@ export function searchTopology(nodes, { prefix, query, metric, comp, value }) {
}
});
}

// property lists (envvars and labels)
const propertyLists = node.get('propertyLists');
if (propertyLists) {
propertyLists.forEach((propertyList) => {
if (propertyList.get('rows')) {
propertyList.get('rows').forEach((field) => {
const keyPath = [nodeId, 'propertyLists', field.get('id')];
nodeMatches = findNodeMatch(nodeMatches, keyPath, field.get('value'),
query, prefix, field.get('label'));
});
}
});
}
} else if (metric) {
const metrics = node.get('metrics');
if (metrics) {
@@ -267,12 +281,18 @@ export function getSearchableFields(nodes) {
))
), makeSet());

const propertyLabels = nodes.reduce((labels, node) => (
labels.union(get(node, 'propertyLists').flatMap(t => (t.get('rows') || makeList)
.map(f => f.get('label'))
))
), makeSet());

const metricLabels = nodes.reduce((labels, node) => (
labels.union(get(node, 'metrics').map(f => f.get('label')))
), makeSet());

return makeMap({
fields: baseLabels.union(metadataLabels, parentLabels, tableRowLabels)
fields: baseLabels.union(metadataLabels, parentLabels, tableRowLabels, propertyLabels)
.map(slugify)
.toList()
.sort(),
4 changes: 2 additions & 2 deletions probe/docker/container.go
Original file line number Diff line number Diff line change
@@ -379,8 +379,8 @@ func (c *container) getBaseNode() report.Node {
}).WithParents(report.EmptySets.
Add(report.ContainerImage, report.MakeStringSet(report.MakeContainerImageNodeID(c.Image()))),
)
result = result.AddPrefixTable(LabelPrefix, c.container.Config.Labels)
result = result.AddPrefixTable(EnvPrefix, c.env())
result = result.AddPrefixPropertyList(LabelPrefix, c.container.Config.Labels)
result = result.AddPrefixPropertyList(EnvPrefix, c.env())
return result
}

12 changes: 6 additions & 6 deletions probe/docker/reporter.go
Original file line number Diff line number Diff line change
@@ -47,9 +47,9 @@ var (
report.Container: {ID: report.Container, Label: "# Containers", From: report.FromCounters, Datatype: "number", Priority: 2},
}

ContainerTableTemplates = report.TableTemplates{
ContainerPropertyListTemplates = report.PropertyListTemplates{
ImageTableID: {ID: ImageTableID, Label: "Image",
FixedRows: map[string]string{
FixedProperties: map[string]string{
ImageID: "ID",
ImageName: "Name",
ImageSize: "Size",
@@ -60,7 +60,7 @@ var (
EnvPrefix: {ID: EnvPrefix, Label: "Environment Variables", Prefix: EnvPrefix},
}

ContainerImageTableTemplates = report.TableTemplates{
ContainerImagePropertyListTemplates = report.PropertyListTemplates{
ImageLabelPrefix: {ID: ImageLabelPrefix, Label: "Docker Labels", Prefix: ImageLabelPrefix},
}

@@ -181,7 +181,7 @@ func (r *Reporter) containerTopology(localAddrs []net.IP) report.Topology {
result := report.MakeTopology().
WithMetadataTemplates(ContainerMetadataTemplates).
WithMetricTemplates(ContainerMetricTemplates).
WithTableTemplates(ContainerTableTemplates)
WithPropertyListTemplates(ContainerPropertyListTemplates)
result.Controls.AddControls(ContainerControls)

metadata := map[string]string{report.ControlProbeID: r.probeID}
@@ -244,7 +244,7 @@ func (r *Reporter) containerTopology(localAddrs []net.IP) report.Topology {
func (r *Reporter) containerImageTopology() report.Topology {
result := report.MakeTopology().
WithMetadataTemplates(ContainerImageMetadataTemplates).
WithTableTemplates(ContainerImageTableTemplates)
WithPropertyListTemplates(ContainerImagePropertyListTemplates)

r.registry.WalkImages(func(image docker_client.APIImages) {
imageID := trimImageID(image.ID)
@@ -258,7 +258,7 @@ func (r *Reporter) containerImageTopology() report.Topology {
}
nodeID := report.MakeContainerImageNodeID(imageID)
node := report.MakeNodeWith(nodeID, latests)
node = node.AddPrefixTable(ImageLabelPrefix, image.Labels)
node = node.AddPrefixPropertyList(ImageLabelPrefix, image.Labels)
result.AddNode(node)
})

2 changes: 1 addition & 1 deletion probe/kubernetes/meta.go
Original file line number Diff line number Diff line change
@@ -56,5 +56,5 @@ func (m meta) MetaNode(id string) report.Node {
Name: m.Name(),
Namespace: m.Namespace(),
Created: m.Created(),
}).AddPrefixTable(LabelPrefix, m.Labels())
}).AddPrefixPropertyList(LabelPrefix, m.Labels())
}
10 changes: 5 additions & 5 deletions probe/kubernetes/reporter.go
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ var (

ReplicaSetMetricTemplates = PodMetricTemplates

TableTemplates = report.TableTemplates{
PropertyListTemplates = report.PropertyListTemplates{
LabelPrefix: {ID: LabelPrefix, Label: "Kubernetes Labels", Prefix: LabelPrefix},
}

@@ -223,7 +223,7 @@ func (r *Reporter) serviceTopology() (report.Topology, []Service, error) {
result = report.MakeTopology().
WithMetadataTemplates(ServiceMetadataTemplates).
WithMetricTemplates(ServiceMetricTemplates).
WithTableTemplates(TableTemplates)
WithPropertyListTemplates(PropertyListTemplates)
services = []Service{}
)
err := r.client.WalkServices(func(s Service) error {
@@ -258,7 +258,7 @@ func (r *Reporter) deploymentTopology(probeID string) (report.Topology, []Deploy
result = report.MakeTopology().
WithMetadataTemplates(DeploymentMetadataTemplates).
WithMetricTemplates(DeploymentMetricTemplates).
WithTableTemplates(TableTemplates)
WithPropertyListTemplates(PropertyListTemplates)
deployments = []Deployment{}
)
result.Controls.AddControls(ScalingControls)
@@ -276,7 +276,7 @@ func (r *Reporter) replicaSetTopology(probeID string, deployments []Deployment)
result = report.MakeTopology().
WithMetadataTemplates(ReplicaSetMetadataTemplates).
WithMetricTemplates(ReplicaSetMetricTemplates).
WithTableTemplates(TableTemplates)
WithPropertyListTemplates(PropertyListTemplates)
replicaSets = []ReplicaSet{}
selectors = []func(labelledChild){}
)
@@ -355,7 +355,7 @@ func (r *Reporter) podTopology(services []Service, replicaSets []ReplicaSet) (re
pods = report.MakeTopology().
WithMetadataTemplates(PodMetadataTemplates).
WithMetricTemplates(PodMetricTemplates).
WithTableTemplates(TableTemplates)
WithPropertyListTemplates(PropertyListTemplates)
selectors = []func(labelledChild){}
)
pods.Controls.AddControl(report.Control{
78 changes: 39 additions & 39 deletions probe/overlay/weave.go
Original file line number Diff line number Diff line change
@@ -19,34 +19,34 @@ import (

// Keys for use in Node
const (
WeavePeerName = "weave_peer_name"
WeavePeerNickName = "weave_peer_nick_name"
WeaveDNSHostname = "weave_dns_hostname"
WeaveMACAddress = "weave_mac_address"
WeaveVersion = "weave_version"
WeaveEncryption = "weave_encryption"
WeaveProtocol = "weave_protocol"
WeavePeerDiscovery = "weave_peer_discovery"
WeaveTargetCount = "weave_target_count"
WeaveConnectionCount = "weave_connection_count"
WeavePeerCount = "weave_peer_count"
WeaveTrustedSubnets = "weave_trusted_subnet_count"
WeaveIPAMTableID = "weave_ipam_table"
WeaveIPAMStatus = "weave_ipam_status"
WeaveIPAMRange = "weave_ipam_range"
WeaveIPAMDefaultSubnet = "weave_ipam_default_subnet"
WeaveDNSTableID = "weave_dns_table"
WeaveDNSDomain = "weave_dns_domain"
WeaveDNSUpstream = "weave_dns_upstream"
WeaveDNSTTL = "weave_dns_ttl"
WeaveDNSEntryCount = "weave_dns_entry_count"
WeaveProxyTableID = "weave_proxy_table"
WeaveProxyStatus = "weave_proxy_status"
WeaveProxyAddress = "weave_proxy_address"
WeavePluginTableID = "weave_plugin_table"
WeavePluginStatus = "weave_plugin_status"
WeavePluginDriver = "weave_plugin_driver"
WeaveConnectionsTablePrefix = "weave_connections_table_"
WeavePeerName = "weave_peer_name"
WeavePeerNickName = "weave_peer_nick_name"
WeaveDNSHostname = "weave_dns_hostname"
WeaveMACAddress = "weave_mac_address"
WeaveVersion = "weave_version"
WeaveEncryption = "weave_encryption"
WeaveProtocol = "weave_protocol"
WeavePeerDiscovery = "weave_peer_discovery"
WeaveTargetCount = "weave_target_count"
WeaveConnectionCount = "weave_connection_count"
WeavePeerCount = "weave_peer_count"
WeaveTrustedSubnets = "weave_trusted_subnet_count"
WeaveIPAMTableID = "weave_ipam_table"
WeaveIPAMStatus = "weave_ipam_status"
WeaveIPAMRange = "weave_ipam_range"
WeaveIPAMDefaultSubnet = "weave_ipam_default_subnet"
WeaveDNSTableID = "weave_dns_table"
WeaveDNSDomain = "weave_dns_domain"
WeaveDNSUpstream = "weave_dns_upstream"
WeaveDNSTTL = "weave_dns_ttl"
WeaveDNSEntryCount = "weave_dns_entry_count"
WeaveProxyTableID = "weave_proxy_table"
WeaveProxyStatus = "weave_proxy_status"
WeaveProxyAddress = "weave_proxy_address"
WeavePluginTableID = "weave_plugin_table"
WeavePluginStatus = "weave_plugin_status"
WeavePluginDriver = "weave_plugin_driver"
WeaveConnectionsListPrefix = "weave_connections_list_"

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

)

var (
@@ -72,38 +72,38 @@ var (
WeaveTrustedSubnets: {ID: WeaveTrustedSubnets, Label: "Trusted Subnets", From: report.FromSets, Priority: 9},
}

weaveTableTemplates = report.TableTemplates{
weavePropertyListTemplates = report.PropertyListTemplates{
WeaveIPAMTableID: {ID: WeaveIPAMTableID, Label: "IPAM",
FixedRows: map[string]string{
FixedProperties: map[string]string{
WeaveIPAMStatus: "Status",
WeaveIPAMRange: "Range",
WeaveIPAMDefaultSubnet: "Default Subnet",
},
},
WeaveDNSTableID: {ID: WeaveDNSTableID, Label: "DNS",
FixedRows: map[string]string{
FixedProperties: map[string]string{
WeaveDNSDomain: "Domain",
WeaveDNSUpstream: "Upstream",
WeaveDNSTTL: "TTL",
WeaveDNSEntryCount: "Entries",
},
},
WeaveProxyTableID: {ID: WeaveProxyTableID, Label: "Proxy",
FixedRows: map[string]string{
FixedProperties: map[string]string{
WeaveProxyStatus: "Status",
WeaveProxyAddress: "Address",
},
},
WeavePluginTableID: {ID: WeavePluginTableID, Label: "Plugin",
FixedRows: map[string]string{
FixedProperties: map[string]string{
WeavePluginStatus: "Status",
WeavePluginDriver: "Driver Name",
},
},
WeaveConnectionsTablePrefix: {
ID: WeaveConnectionsTablePrefix,
WeaveConnectionsListPrefix: {
ID: WeaveConnectionsListPrefix,
Label: "Connections",
Prefix: WeaveConnectionsTablePrefix,
Prefix: WeaveConnectionsListPrefix,
},
}
)
@@ -345,7 +345,7 @@ func (w *Weave) Report() (report.Report, error) {

r := report.MakeReport()
r.Container = r.Container.WithMetadataTemplates(containerMetadata)
r.Overlay = r.Overlay.WithMetadataTemplates(weaveMetadata).WithTableTemplates(weaveTableTemplates)
r.Overlay = r.Overlay.WithMetadataTemplates(weaveMetadata).WithPropertyListTemplates(weavePropertyListTemplates)

// We report nodes for all peers (not just the current node) to highlight peers not monitored by Scope
// (i.e. without a running probe)
@@ -434,13 +434,13 @@ func (w *Weave) addCurrentPeerInfo(latests map[string]string, node report.Node)
latests[WeavePluginStatus] = "running"
latests[WeavePluginDriver] = "weave"
}
node = node.AddPrefixTable(WeaveConnectionsTablePrefix, getConnectionsTable(w.statusCache.Router))
node = node.AddPrefixPropertyList(WeaveConnectionsListPrefix, getConnectionsList(w.statusCache.Router))
node = node.WithParents(report.EmptySets.Add(report.Host, report.MakeStringSet(w.hostID)))

return latests, node
}

func getConnectionsTable(router weave.Router) map[string]string {
func getConnectionsList(router weave.Router) map[string]string {
const (
outboundArrow = "->"
inboundArrow = "<-"
Original file line number Diff line number Diff line change
@@ -4,17 +4,16 @@ import (
"github.com/weaveworks/scope/report"
)

// NodeTables produces a list of tables (to be consumed directly by the UI) based
// on the report and the node. It uses the report to get the templates for the node's
// topology.
func NodeTables(r report.Report, n report.Node) []report.Table {
// NodePropertyLists produces a list of property lists (to be consumed directly by the UI) based
// on the report and the node. It uses the report to get the templates for the node's topology.
func NodePropertyLists(r report.Report, n report.Node) []report.PropertyList {
if _, ok := n.Counters.Lookup(n.Topology); ok {
// This is a group of nodes, so no tables!
return nil
}

if topology, ok := r.Topology(n.Topology); ok {
return topology.TableTemplates.Tables(n)
return topology.PropertyListTemplates.PropertyLists(n)
}
return nil
}
Loading