Skip to content

Commit

Permalink
Merge pull request #110 from jan--f/rm-liveness-probe-4.6
Browse files Browse the repository at this point in the history
Bug 1935586: pkg/prometheus: remove liveness probe
  • Loading branch information
openshift-merge-robot committed Mar 10, 2021
2 parents c5c522d + 543db0f commit 555d602
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 37 deletions.
23 changes: 5 additions & 18 deletions pkg/prometheus/statefulset.go
Expand Up @@ -551,23 +551,21 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *operator.Config, ruleConf

const localProbe = `if [ -x "$(command -v curl)" ]; then curl %s; elif [ -x "$(command -v wget)" ]; then wget -q -O /dev/null %s; else exit 1; fi`

var livenessProbeHandler v1.Handler
var readinessProbeHandler v1.Handler
var livenessFailureThreshold int32
if (version.Major == 1 && version.Minor >= 8) || version.Major == 2 {
{
healthyPath := path.Clean(webRoutePrefix + "/-/healthy")
if p.Spec.ListenLocal {
localHealthyPath := fmt.Sprintf("http://localhost:9090%s", healthyPath)
livenessProbeHandler.Exec = &v1.ExecAction{
readinessProbeHandler.Exec = &v1.ExecAction{
Command: []string{
"sh",
"-c",
fmt.Sprintf(localProbe, localHealthyPath, localHealthyPath),
},
}
} else {
livenessProbeHandler.HTTPGet = &v1.HTTPGetAction{
readinessProbeHandler.HTTPGet = &v1.HTTPGetAction{
Path: healthyPath,
Port: intstr.FromString(p.Spec.PortName),
}
Expand All @@ -593,27 +591,17 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *operator.Config, ruleConf
}
}

livenessFailureThreshold = 6

} else {
livenessProbeHandler = v1.Handler{
readinessProbeHandler = v1.Handler{
HTTPGet: &v1.HTTPGetAction{
Path: path.Clean(webRoutePrefix + "/status"),
Port: intstr.FromString(p.Spec.PortName),
},
}
readinessProbeHandler = livenessProbeHandler
// For larger servers, restoring a checkpoint on startup may take quite a bit of time.
// Wait up to 5 minutes (60 fails * 5s per fail)
livenessFailureThreshold = 60
}

livenessProbe := &v1.Probe{
Handler: livenessProbeHandler,
PeriodSeconds: 5,
TimeoutSeconds: probeTimeoutSeconds,
FailureThreshold: livenessFailureThreshold,
}
// TODO(paulfantom): Re-add livenessProbe and add startupProbe when kubernetes 1.21 is available.
// This would be a follow-up to https://github.com/prometheus-operator/prometheus-operator/pull/3502
readinessProbe := &v1.Probe{
Handler: readinessProbeHandler,
TimeoutSeconds: probeTimeoutSeconds,
Expand Down Expand Up @@ -799,7 +787,6 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *operator.Config, ruleConf
Ports: ports,
Args: promArgs,
VolumeMounts: promVolumeMounts,
LivenessProbe: livenessProbe,
ReadinessProbe: readinessProbe,
Resources: p.Spec.Resources,
TerminationMessagePolicy: v1.TerminationMessageFallbackToLogsOnError,
Expand Down
19 changes: 0 additions & 19 deletions pkg/prometheus/statefulset_test.go
Expand Up @@ -440,25 +440,6 @@ func TestListenLocal(t *testing.T) {
t.Fatalf("Readiness probe doesn't match expected. \n\nExpected: %+v\n\nGot: %+v", expectedReadinessProbe, actualReadinessProbe)
}

actualLivenessProbe := sset.Spec.Template.Spec.Containers[0].LivenessProbe
expectedLivenessProbe := &v1.Probe{
Handler: v1.Handler{
Exec: &v1.ExecAction{
Command: []string{
`sh`,
`-c`,
`if [ -x "$(command -v curl)" ]; then curl http://localhost:9090/-/healthy; elif [ -x "$(command -v wget)" ]; then wget -q -O /dev/null http://localhost:9090/-/healthy; else exit 1; fi`,
},
},
},
TimeoutSeconds: 3,
PeriodSeconds: 5,
FailureThreshold: 6,
}
if !reflect.DeepEqual(actualLivenessProbe, expectedLivenessProbe) {
t.Fatalf("Liveness probe doesn't match expected. \n\nExpected: %v\n\nGot: %v", expectedLivenessProbe, actualLivenessProbe)
}

if len(sset.Spec.Template.Spec.Containers[0].Ports) != 0 {
t.Fatal("Prometheus container should have 0 ports defined")
}
Expand Down

0 comments on commit 555d602

Please sign in to comment.