Skip to content

Commit

Permalink
emit warning on no liveness probe defined for pods
Browse files Browse the repository at this point in the history
  • Loading branch information
juanvallejo committed Aug 11, 2016
1 parent 70adfdf commit 2ecad3d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cmd/cli/describe/projectstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ func getMarkerScanners(logsCommandName, securityPolicyCommandFormat, setProbeCom
func(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
return deployanalysis.FindDeploymentConfigReadinessWarnings(g, f, setProbeCommandName)
},
func(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
return deployanalysis.FindDeploymentConfigLivenessWarnings(g, f, setProbeCommandName)
},
routeanalysis.FindPortMappingIssues,
routeanalysis.FindMissingTLSTerminationType,
routeanalysis.FindPathBasedPassthroughRoutes,
Expand Down
31 changes: 31 additions & 0 deletions pkg/deploy/graph/analysis/dc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
MissingImageStreamErr = "MissingImageStream"
MissingImageStreamTagWarning = "MissingImageStreamTag"
MissingReadinessProbeWarning = "MissingReadinessProbe"
MissingLivenessProbeWarning = "MissingLivenessProbe"
)

// FindDeploymentConfigTriggerErrors checks for possible failures in deployment config
Expand Down Expand Up @@ -124,3 +125,33 @@ Node:

return markers
}

// FindDeploymentConfigLivenessWarnings inspects deploymentconfigs and reports those that
// don't have liveness probes set up.
func FindDeploymentConfigLivenessWarnings(g osgraph.Graph, f osgraph.Namer, setProbeCommand string) []osgraph.Marker {
markers := []osgraph.Marker{}

Node:
for _, uncastDcNode := range g.NodesByKind(deploygraph.DeploymentConfigNodeKind) {
dcNode := uncastDcNode.(*deploygraph.DeploymentConfigNode)
if t := dcNode.DeploymentConfig.Spec.Template; t != nil && len(t.Spec.Containers) > 0 {
for _, container := range t.Spec.Containers {
if container.LivenessProbe != nil {
continue Node
}
}
// All of the containers in the deployment config lack a readiness probe
markers = append(markers, osgraph.Marker{
Node: uncastDcNode,
Severity: osgraph.WarningSeverity,
Key: MissingLivenessProbeWarning,
Message: fmt.Sprintf("%s has no liveness probe to verify pods are still running.",
f.ResourceName(dcNode)),
Suggestion: osgraph.Suggestion(fmt.Sprintf("%s %s --liveness ...", setProbeCommand, f.ResourceName(dcNode))),
})
continue Node
}
}

return markers
}

0 comments on commit 2ecad3d

Please sign in to comment.