From d75004e5c2c29e308d1025cab5193746a4ce2fc9 Mon Sep 17 00:00:00 2001 From: juanvallejo Date: Mon, 17 Oct 2016 16:36:54 -0400 Subject: [PATCH] add and handle controllerRefEdgeKinds --- pkg/api/kubegraph/analysis/podspec.go | 20 +++++++++++--------- pkg/deploy/graph/edges.go | 3 +++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pkg/api/kubegraph/analysis/podspec.go b/pkg/api/kubegraph/analysis/podspec.go index b6f2eda46f86..75749638859b 100644 --- a/pkg/api/kubegraph/analysis/podspec.go +++ b/pkg/api/kubegraph/analysis/podspec.go @@ -8,9 +8,7 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubeedges "github.com/openshift/origin/pkg/api/kubegraph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - kubenodes "github.com/openshift/origin/pkg/api/kubegraph/nodes" deploygraph "github.com/openshift/origin/pkg/deploy/graph" - deploynodes "github.com/openshift/origin/pkg/deploy/graph/nodes" "k8s.io/kubernetes/pkg/util/sets" ) @@ -84,7 +82,7 @@ func FindMissingSecrets(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker { func FindMissingLivenessProbes(g osgraph.Graph, f osgraph.Namer, setProbeCommand string) []osgraph.Marker { markers := []osgraph.Marker{} appendedNodes := sets.NewString() - ignoredNodes := findDeploymentEdgeKinds(g) + ignoredNodes := findControllerRefEdgeKinds(g) for _, uncastPodSpecNode := range g.NodesByKind(kubegraph.PodSpecNodeKind) { podSpecNode := uncastPodSpecNode.(*kubegraph.PodSpecNode) @@ -187,14 +185,18 @@ func CheckMissingMountedSecrets(g osgraph.Graph, podSpecNode *kubegraph.PodSpecN return missingSecrets } -// findDeploymentEdgeKinds returns all replication controller nodes -// whose deployment is being fulfilled by a DeploymentConfig -func findDeploymentEdgeKinds(g osgraph.Graph) []graph.Node { - nodeFilter := osgraph.NodesOfKind(deploynodes.DeploymentConfigNodeKind) - edgeFilter := osgraph.EdgesOfKind(deploygraph.DeploymentEdgeKind) +func findControllerRefEdgeKinds(g osgraph.Graph) []graph.Node { + nodeFilter := osgraph.NodesOfKind() + edgeFilter := osgraph.EdgesOfKind(deploygraph.ControllerRefEdgeKind) subGraph := g.Subgraph(nodeFilter, edgeFilter) - return subGraph.NodesByKind(kubenodes.ReplicationControllerNodeKind) + ignoredNodes := []graph.Node{} + + // ignore all nodes "controlled" by another node + for _, edge := range subGraph.Edges() { + ignoredNodes = append(ignoredNodes, edge.To()) + } + return ignoredNodes } func isNodeInList(node graph.Node, nodeList []graph.Node) bool { diff --git a/pkg/deploy/graph/edges.go b/pkg/deploy/graph/edges.go index c8866522c571..9e99cfb7b784 100644 --- a/pkg/deploy/graph/edges.go +++ b/pkg/deploy/graph/edges.go @@ -22,6 +22,8 @@ const ( DeploymentEdgeKind = "Deployment" // VolumeClaimEdgeKind goes from DeploymentConfigs to PersistentVolumeClaims indicating a request for persistent storage. VolumeClaimEdgeKind = "VolumeClaim" + // ControllerRefEdgeKind goes from a controller node to its controlled child-node + ControllerRefEdgeKind = "ControllerRef" ) // AddTriggerEdges creates edges that point to named Docker image repositories for each image used in the deployment. @@ -73,6 +75,7 @@ func AddDeploymentEdges(g osgraph.MutableUniqueGraph, node *deploygraph.Deployme } if BelongsToDeploymentConfig(node.DeploymentConfig, rcNode.ReplicationController) { g.AddEdge(node, rcNode, DeploymentEdgeKind) + g.AddEdge(node, rcNode, ControllerRefEdgeKind) } } }