@@ -82,18 +82,23 @@ func FindMissingLivenessProbes(g osgraph.Graph, f osgraph.Namer, setProbeCommand
82
82
83
83
for _ , uncastPodSpecNode := range g .NodesByKind (kubegraph .PodSpecNodeKind ) {
84
84
podSpecNode := uncastPodSpecNode .(* kubegraph.PodSpecNode )
85
- topLevelNode := osgraph .GetTopLevelContainerNode (g , podSpecNode )
86
-
87
85
if hasLivenessProbe (podSpecNode ) {
88
86
continue
89
87
}
88
+
89
+ topLevelNode := osgraph .GetTopLevelContainerNode (g , podSpecNode )
90
+
91
+ // skip any podSpec nodes that are managed by other nodes.
92
+ // Liveness probes should only be applied to a controlling
93
+ // podSpec node, and not to any of its children.
90
94
if hasControllerRefEdge (g , topLevelNode ) {
91
95
continue
92
96
}
93
97
94
98
topLevelString := f .ResourceName (topLevelNode )
95
99
markers = append (markers , osgraph.Marker {
96
- Node : podSpecNode ,
100
+ Node : podSpecNode ,
101
+ RelatedNodes : []graph.Node {topLevelNode },
97
102
98
103
Severity : osgraph .WarningSeverity ,
99
104
Key : MissingLivenessProbeWarning ,
@@ -117,17 +122,10 @@ func hasLivenessProbe(podSpecNode *kubegraph.PodSpecNode) bool {
117
122
return false
118
123
}
119
124
120
- // hasControllerRefEdge returns true if a given node contains a "ManagedByController" edge between itself and any of its "To" nodes.
125
+ // hasControllerRefEdge returns true if a given node contains one or more "ManagedByController" outbound edges
121
126
func hasControllerRefEdge (g osgraph.Graph , node graph.Node ) bool {
122
- children := g .From (node )
123
- for _ , child := range children {
124
- edge := g .Edge (node , child )
125
- edgeKinds := g .EdgeKinds (edge )
126
- if edgeKinds .Has (kubeedges .ManagedByControllerEdgeKind ) {
127
- return true
128
- }
129
- }
130
- return false
127
+ managedEdges := g .OutboundEdges (node , kubeedges .ManagedByControllerEdgeKind )
128
+ return len (managedEdges ) > 0
131
129
}
132
130
133
131
// CheckForUnmountableSecrets checks to be sure that all the referenced secrets are mountable (by service account)
0 commit comments