Skip to content

Commit 2ecad3d

Browse files
committed
emit warning on no liveness probe defined for pods
1 parent 70adfdf commit 2ecad3d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

pkg/cmd/cli/describe/projectstatus.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ func getMarkerScanners(logsCommandName, securityPolicyCommandFormat, setProbeCom
376376
func(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
377377
return deployanalysis.FindDeploymentConfigReadinessWarnings(g, f, setProbeCommandName)
378378
},
379+
func(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
380+
return deployanalysis.FindDeploymentConfigLivenessWarnings(g, f, setProbeCommandName)
381+
},
379382
routeanalysis.FindPortMappingIssues,
380383
routeanalysis.FindMissingTLSTerminationType,
381384
routeanalysis.FindPathBasedPassthroughRoutes,

pkg/deploy/graph/analysis/dc.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818
MissingImageStreamErr = "MissingImageStream"
1919
MissingImageStreamTagWarning = "MissingImageStreamTag"
2020
MissingReadinessProbeWarning = "MissingReadinessProbe"
21+
MissingLivenessProbeWarning = "MissingLivenessProbe"
2122
)
2223

2324
// FindDeploymentConfigTriggerErrors checks for possible failures in deployment config
@@ -124,3 +125,33 @@ Node:
124125

125126
return markers
126127
}
128+
129+
// FindDeploymentConfigLivenessWarnings inspects deploymentconfigs and reports those that
130+
// don't have liveness probes set up.
131+
func FindDeploymentConfigLivenessWarnings(g osgraph.Graph, f osgraph.Namer, setProbeCommand string) []osgraph.Marker {
132+
markers := []osgraph.Marker{}
133+
134+
Node:
135+
for _, uncastDcNode := range g.NodesByKind(deploygraph.DeploymentConfigNodeKind) {
136+
dcNode := uncastDcNode.(*deploygraph.DeploymentConfigNode)
137+
if t := dcNode.DeploymentConfig.Spec.Template; t != nil && len(t.Spec.Containers) > 0 {
138+
for _, container := range t.Spec.Containers {
139+
if container.LivenessProbe != nil {
140+
continue Node
141+
}
142+
}
143+
// All of the containers in the deployment config lack a readiness probe
144+
markers = append(markers, osgraph.Marker{
145+
Node: uncastDcNode,
146+
Severity: osgraph.WarningSeverity,
147+
Key: MissingLivenessProbeWarning,
148+
Message: fmt.Sprintf("%s has no liveness probe to verify pods are still running.",
149+
f.ResourceName(dcNode)),
150+
Suggestion: osgraph.Suggestion(fmt.Sprintf("%s %s --liveness ...", setProbeCommand, f.ResourceName(dcNode))),
151+
})
152+
continue Node
153+
}
154+
}
155+
156+
return markers
157+
}

0 commit comments

Comments
 (0)