Skip to content

Commit

Permalink
controllers: small probe builder refactoring
Browse files Browse the repository at this point in the history
it simplies code and allows to extend it later with additional probes configuration. Such as custom script checks.

Signed-off-by: f41gh7 <[email protected]>
  • Loading branch information
f41gh7 committed Aug 14, 2024
1 parent fecc56c commit 3bc9696
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions internal/controller/operator/factory/build/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,27 @@ func Probe(container corev1.Container, cr probeCRD) corev1.Container {
sp = ep.StartupProbe
}

if rp == nil {
readinessProbeHandler := corev1.ProbeHandler{
defaultProbeHandler := func() corev1.ProbeHandler {
return corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Port: intstr.Parse(port),
Scheme: corev1.URIScheme(scheme),
Path: probePath(),
},
}
}
if rp == nil {
rp = &corev1.Probe{
ProbeHandler: readinessProbeHandler,
ProbeHandler: defaultProbeHandler(),
TimeoutSeconds: probeTimeoutSeconds,
PeriodSeconds: 5,
FailureThreshold: 10,
}
}
if needAddLiveness {
if lp == nil {
probeHandler := corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Port: intstr.Parse(port),
Scheme: corev1.URIScheme(scheme),
Path: probePath(),
},
}
lp = &corev1.Probe{
ProbeHandler: probeHandler,
ProbeHandler: defaultProbeHandler(),
TimeoutSeconds: probeTimeoutSeconds,
FailureThreshold: 10,
PeriodSeconds: 5,
Expand Down

0 comments on commit 3bc9696

Please sign in to comment.