1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-15 16:56:24 +00:00

Merge pull request #3502 from paulfantom/livenessProbe

pkg/prometheus: remove liveness probe
This commit is contained in:
Paweł Krupa 2020-09-15 13:03:38 +02:00 committed by GitHub
commit ac44b6180e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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` 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 readinessProbeHandler v1.Handler
var livenessFailureThreshold int32
if (version.Major == 1 && version.Minor >= 8) || version.Major == 2 { if (version.Major == 1 && version.Minor >= 8) || version.Major == 2 {
{ {
healthyPath := path.Clean(webRoutePrefix + "/-/healthy") healthyPath := path.Clean(webRoutePrefix + "/-/healthy")
if p.Spec.ListenLocal { if p.Spec.ListenLocal {
localHealthyPath := fmt.Sprintf("http://localhost:9090%s", healthyPath) localHealthyPath := fmt.Sprintf("http://localhost:9090%s", healthyPath)
livenessProbeHandler.Exec = &v1.ExecAction{ readinessProbeHandler.Exec = &v1.ExecAction{
Command: []string{ Command: []string{
"sh", "sh",
"-c", "-c",
@ -591,7 +589,7 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
}, },
} }
} else { } else {
livenessProbeHandler.HTTPGet = &v1.HTTPGetAction{ readinessProbeHandler.HTTPGet = &v1.HTTPGetAction{
Path: healthyPath, Path: healthyPath,
Port: intstr.FromString(p.Spec.PortName), Port: intstr.FromString(p.Spec.PortName),
} }
@ -617,27 +615,17 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
} }
} }
livenessFailureThreshold = 6
} else { } else {
livenessProbeHandler = v1.Handler{ readinessProbeHandler = v1.Handler{
HTTPGet: &v1.HTTPGetAction{ HTTPGet: &v1.HTTPGetAction{
Path: path.Clean(webRoutePrefix + "/status"), Path: path.Clean(webRoutePrefix + "/status"),
Port: intstr.FromString(p.Spec.PortName), 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{ // TODO(paulfantom): Re-add livenessProbe and add startupProbe when kubernetes 1.21 is available.
Handler: livenessProbeHandler, // This would be a follow-up to https://github.com/prometheus-operator/prometheus-operator/pull/3502
PeriodSeconds: 5,
TimeoutSeconds: probeTimeoutSeconds,
FailureThreshold: livenessFailureThreshold,
}
readinessProbe := &v1.Probe{ readinessProbe := &v1.Probe{
Handler: readinessProbeHandler, Handler: readinessProbeHandler,
TimeoutSeconds: probeTimeoutSeconds, TimeoutSeconds: probeTimeoutSeconds,
@ -846,7 +834,6 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
Ports: ports, Ports: ports,
Args: promArgs, Args: promArgs,
VolumeMounts: promVolumeMounts, VolumeMounts: promVolumeMounts,
LivenessProbe: livenessProbe,
ReadinessProbe: readinessProbe, ReadinessProbe: readinessProbe,
Resources: p.Spec.Resources, Resources: p.Spec.Resources,
TerminationMessagePolicy: v1.TerminationMessageFallbackToLogsOnError, 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) 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 { if len(sset.Spec.Template.Spec.Containers[0].Ports) != 0 {
t.Fatal("Prometheus container should have 0 ports defined") t.Fatal("Prometheus container should have 0 ports defined")
} }