1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-08 18:14:14 +00:00

pkg/prometheus: remove liveness probe

Removing liveness probe to prevent killing prometheus pod during WAL
replay.

This should be reverted around kubernetes 1.21 release. At that point
startupProbe should be added.
This commit is contained in:
paulfantom 2020-09-14 16:59:54 +02:00
parent dc7578c762
commit 35b2954459
No known key found for this signature in database
GPG key ID: 12AE0185401674E7
2 changed files with 5 additions and 37 deletions

View file

@ -575,15 +575,13 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
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",
@ -591,7 +589,7 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
},
}
} else {
livenessProbeHandler.HTTPGet = &v1.HTTPGetAction{
readinessProbeHandler.HTTPGet = &v1.HTTPGetAction{
Path: healthyPath,
Port: intstr.FromString(p.Spec.PortName),
}
@ -617,27 +615,17 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
}
}
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,
@ -846,7 +834,6 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
Ports: ports,
Args: promArgs,
VolumeMounts: promVolumeMounts,
LivenessProbe: livenessProbe,
ReadinessProbe: readinessProbe,
Resources: p.Spec.Resources,
TerminationMessagePolicy: v1.TerminationMessageFallbackToLogsOnError,

View file

@ -438,25 +438,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")
}