Skip to content

Commit

Permalink
Remove redundant kubernetes ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Acosta committed Aug 10, 2016
1 parent d06547e commit 166bdf1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 26 deletions.
7 changes: 0 additions & 7 deletions probe/kubernetes/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

// These constants are keys used in node metadata
const (
ID = "kubernetes_id"
Name = "kubernetes_name"
Namespace = "kubernetes_namespace"
Created = "kubernetes_created"
Expand All @@ -20,7 +19,6 @@ const (
// Meta represents a metadata information about a Kubernetes object
type Meta interface {
UID() string
ID() string
Name() string
Namespace() string
Created() string
Expand All @@ -36,10 +34,6 @@ func (m meta) UID() string {
return string(m.ObjectMeta.UID)
}

func (m meta) ID() string {
return m.ObjectMeta.Namespace + "/" + m.ObjectMeta.Name
}

func (m meta) Name() string {
return m.ObjectMeta.Name
}
Expand All @@ -59,7 +53,6 @@ func (m meta) Labels() map[string]string {
// MetaNode gets the node metadata
func (m meta) MetaNode(id string) report.Node {
return report.MakeNodeWith(id, map[string]string{
ID: m.ID(),
Name: m.Name(),
Namespace: m.Namespace(),
Created: m.Created(),
Expand Down
4 changes: 0 additions & 4 deletions probe/kubernetes/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const (
// Exposed for testing
var (
PodMetadataTemplates = report.MetadataTemplates{
ID: {ID: ID, Label: "ID", From: report.FromLatest, Priority: 1},
State: {ID: State, Label: "State", From: report.FromLatest, Priority: 2},
IP: {ID: IP, Label: "IP", From: report.FromLatest, Priority: 3},
report.Container: {ID: report.Container, Label: "# Containers", From: report.FromCounters, Datatype: "number", Priority: 4},
Expand All @@ -38,7 +37,6 @@ var (
PodMetricTemplates = docker.ContainerMetricTemplates

ServiceMetadataTemplates = report.MetadataTemplates{
ID: {ID: ID, Label: "ID", From: report.FromLatest, Priority: 1},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2},
Created: {ID: Created, Label: "Created", From: report.FromLatest, Priority: 3},
PublicIP: {ID: PublicIP, Label: "Public IP", From: report.FromLatest, Priority: 4},
Expand All @@ -49,7 +47,6 @@ var (
ServiceMetricTemplates = PodMetricTemplates

DeploymentMetadataTemplates = report.MetadataTemplates{
ID: {ID: ID, Label: "ID", From: report.FromLatest, Priority: 1},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2},
Created: {ID: Created, Label: "Created", From: report.FromLatest, Priority: 3},
ObservedGeneration: {ID: ObservedGeneration, Label: "Observed Gen.", From: report.FromLatest, Priority: 4},
Expand All @@ -61,7 +58,6 @@ var (
DeploymentMetricTemplates = ReplicaSetMetricTemplates

ReplicaSetMetadataTemplates = report.MetadataTemplates{
ID: {ID: ID, Label: "ID", From: report.FromLatest, Priority: 1},
Namespace: {ID: Namespace, Label: "Namespace", From: report.FromLatest, Priority: 2},
Created: {ID: Created, Label: "Created", From: report.FromLatest, Priority: 3},
ObservedGeneration: {ID: ObservedGeneration, Label: "Observed Gen.", From: report.FromLatest, Priority: 4},
Expand Down
3 changes: 0 additions & 3 deletions probe/kubernetes/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,11 @@ func TestReporter(t *testing.T) {
latest map[string]string
}{
{pod1ID, serviceID, map[string]string{
kubernetes.ID: "ping/pong-a",
kubernetes.Name: "pong-a",
kubernetes.Namespace: "ping",
kubernetes.Created: pod1.Created(),
}},
{pod2ID, serviceID, map[string]string{
kubernetes.ID: "ping/pong-b",
kubernetes.Name: "pong-b",
kubernetes.Namespace: "ping",
kubernetes.Created: pod1.Created(),
Expand Down Expand Up @@ -229,7 +227,6 @@ func TestReporter(t *testing.T) {
}

for k, want := range map[string]string{
kubernetes.ID: "ping/pongservice",
kubernetes.Name: "pongservice",
kubernetes.Namespace: "ping",
kubernetes.Created: pod1.Created(),
Expand Down
1 change: 0 additions & 1 deletion render/detailed/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ func TestMakeDetailedPodNode(t *testing.T) {
Linkable: true,
Pseudo: false,
Metadata: []report.MetadataRow{
{ID: "kubernetes_id", Label: "ID", Value: "ping/pong-b", Priority: 1},
{ID: "kubernetes_state", Label: "State", Value: "running", Priority: 2},
{ID: "container", Label: "# Containers", Value: "1", Priority: 4, Datatype: "number"},
{ID: "kubernetes_namespace", Label: "Namespace", Value: "ping", Priority: 5},
Expand Down
13 changes: 8 additions & 5 deletions render/detailed/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ func containerImageNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bo

func podNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
base.Label, _ = n.Latest.Lookup(kubernetes.Name)
base.Rank, _ = n.Latest.Lookup(kubernetes.ID)

namespace, _ := n.Latest.Lookup(kubernetes.Namespace)
base.Rank = namespace + "/" + base.Label
if c, ok := n.Counters.Lookup(report.Container); ok {
if c == 1 {
base.LabelMinor = fmt.Sprintf("%d container", c)
Expand All @@ -258,7 +258,8 @@ func podNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {

func serviceNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
base.Label, _ = n.Latest.Lookup(kubernetes.Name)
base.Rank, _ = n.Latest.Lookup(kubernetes.ID)
namespace, _ := n.Latest.Lookup(kubernetes.Namespace)
base.Rank = namespace + "/" + base.Label
base.Stack = true

// Services are always just a group of pods, so there's no counting multiple
Expand All @@ -276,7 +277,8 @@ func serviceNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {

func deploymentNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
base.Label, _ = n.Latest.Lookup(kubernetes.Name)
base.Rank, _ = n.Latest.Lookup(kubernetes.ID)
namespace, _ := n.Latest.Lookup(kubernetes.Namespace)
base.Rank = namespace + "/" + base.Label
base.Stack = true

if p, ok := n.Counters.Lookup(report.Pod); ok {
Expand All @@ -292,7 +294,8 @@ func deploymentNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool)

func replicaSetNodeSummary(base NodeSummary, n report.Node) (NodeSummary, bool) {
base.Label, _ = n.Latest.Lookup(kubernetes.Name)
base.Rank, _ = n.Latest.Lookup(kubernetes.ID)
namespace, _ := n.Latest.Lookup(kubernetes.Namespace)
base.Rank = namespace + "/" + base.Label
base.Stack = true

if p, ok := n.Counters.Lookup(report.Pod); ok {
Expand Down
6 changes: 0 additions & 6 deletions test/fixture/report_fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,11 @@ var (
ServerContainerImageName = "image/server"

KubernetesNamespace = "ping"
ClientPodID = "ping/pong-a"
ServerPodID = "ping/pong-b"
ClientPodUID = "5d4c3b2a1"
ServerPodUID = "i9h8g7f6e"
ClientPodNodeID = report.MakePodNodeID(ClientPodUID)
ServerPodNodeID = report.MakePodNodeID(ServerPodUID)
ServiceName = "pongservice"
ServiceID = "ping/pongservice"
ServiceUID = "service1234"
ServiceNodeID = report.MakeServiceNodeID(ServiceUID)

Expand Down Expand Up @@ -366,7 +363,6 @@ var (
Nodes: report.Nodes{
ClientPodNodeID: report.MakeNodeWith(
ClientPodNodeID, map[string]string{
kubernetes.ID: ClientPodID,
kubernetes.Name: "pong-a",
kubernetes.Namespace: KubernetesNamespace,
report.HostNodeID: ClientHostNodeID,
Expand All @@ -377,7 +373,6 @@ var (
),
ServerPodNodeID: report.MakeNodeWith(
ServerPodNodeID, map[string]string{
kubernetes.ID: ServerPodID,
kubernetes.Name: "pong-b",
kubernetes.Namespace: KubernetesNamespace,
kubernetes.State: "running",
Expand All @@ -395,7 +390,6 @@ var (
ServiceNodeID: report.MakeNodeWith(

ServiceNodeID, map[string]string{
kubernetes.ID: ServiceID,
kubernetes.Name: "pongservice",
kubernetes.Namespace: "ping",
}).
Expand Down

0 comments on commit 166bdf1

Please sign in to comment.