cli: do not suggest liveness probes for controller owned pods
@@ -95,6 +95,12 @@ func FindMissingLivenessProbes(g osgraph.Graph, f osgraph.Namer, setProbeCommand
continue
}
+ // skip any podSpec nodes that belong to Pods with controller
+ // owner references.
+ if hasControllerOwnerReference(topLevelNode) {
+ continue
+ }
+
topLevelString := f.ResourceName(topLevelNode)
markers = append(markers, osgraph.Marker{
Node: podSpecNode,
@@ -122,6 +128,20 @@ func hasLivenessProbe(podSpecNode *kubegraph.PodSpecNode) bool {
return false
}
+// hasControllerOwnerReference returns true if a given Pod node is controller controlled.
+func hasControllerOwnerReference(node graph.Node) bool {
+ pod, ok := node.(*kubegraph.PodNode)
+ if !ok {
+ return false
+ }
+ for _, ref := range pod.OwnerReferences {
+ if ref.Controller != nil && *ref.Controller == true {
+ return true
+ }
+ }
+ return false
+}
+
// hasControllerRefEdge returns true if a given node contains one or more "ManagedByController" outbound edges
func hasControllerRefEdge(g osgraph.Graph, node graph.Node) bool {
managedEdges := g.OutboundEdges(node, kubeedges.ManagedByControllerEdgeKind)
