Skip to content

Commit

Permalink
add and handle controllerRefEdgeKinds
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Oct 17, 2016
1 parent 977778b commit d75004e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/api/kubegraph/analysis/podspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions pkg/deploy/graph/edges.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit d75004e

Please sign in to comment.