Skip to content

Commit

Permalink
Change readiness timeout var (#2269)
Browse files Browse the repository at this point in the history
  • Loading branch information
anyasabo authored Dec 16, 2019
1 parent 958df1d commit 65e2c96
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
38 changes: 38 additions & 0 deletions docs/elasticsearch-specification.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Before you deploy and run ECK, take some time to look at the basic and advanced
- <<{p}-advanced-node-scheduling,Advanced Elasticsearch node scheduling>>
- <<{p}-orchestration>>
- <<{p}-snapshots,Create automated snapshots>>
- <<{p}-readiness>>
[id="{p}-pod-template"]
=== Pod Template
Expand Down Expand Up @@ -506,3 +507,40 @@ spec:
include::orchestration.asciidoc[]
include::advanced-node-scheduling.asciidoc[]
include::snapshots.asciidoc[]


[id="{p}-readiness"]
=== Readiness probe

By default, the readiness probe checks that the pod can successfully respond to HTTP requests within a three second timeout. This is acceptable in most cases. In some cases (such as when the cluster is under heavy load), it may be helpful to increase the timeout. This allows the pod to stay in a `Ready` state and thus be part of the Elasticsearch service even if it is responding slowly. To adjust the timeout, set the `READINESS_PROBE_TIMEOUT` environment variable in the pod template. The readiness probe configuration also must be updated with the new timeout. For example, to increase the API call timeout to ten seconds and the overall check time to twelve seconds:

[source,yaml]
----
spec:
version: 7.4.2
nodeSets:
- name: default
count: 1
podTemplate:
spec:
containers:
- name: elasticsearch
readinessProbe:
exec:
command:
- bash
- -c
- /mnt/elastic-internal/scripts/readiness-probe-script.sh
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 12
successThreshold: 1
timeoutSeconds: 12
env:
- name: READINESS_PROBE_TIMEOUT
value: "10"
----

Note that this will require restarting the pods.
4 changes: 2 additions & 2 deletions pkg/controller/elasticsearch/nodespec/readiness_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewReadinessProbe() *corev1.Probe {
const ReadinessProbeScriptConfigKey = "readiness-probe-script.sh"
const ReadinessProbeScript = `#!/usr/bin/env bash
# Consider a node to be healthy if it responds to a simple GET on "/_cat/nodes?local"
CURL_TIMEOUT=${CURL_TIMEOUT:=3}
READINESS_PROBE_TIMEOUT=${READINESS_PROBE_TIMEOUT:=3}
# Check if PROBE_PASSWORD_PATH is set, otherwise fall back to its former name in 1.0.0.beta-1: PROBE_PASSWORD_FILE
if [[ -z "${PROBE_PASSWORD_PATH}" ]]; then
Expand All @@ -48,7 +48,7 @@ fi
# request Elasticsearch
ENDPOINT="${READINESS_PROBE_PROTOCOL:-https}://127.0.0.1:9200/_cat/nodes?local"
status=$(curl -o /dev/null -w "%{http_code}" --max-time $CURL_TIMEOUT -XGET -s -k ${BASIC_AUTH} $ENDPOINT)
status=$(curl -o /dev/null -w "%{http_code}" --max-time $READINESS_PROBE_TIMEOUT -XGET -s -k ${BASIC_AUTH} $ENDPOINT)
# ready if status code 200
if [[ $status == "200" ]]; then
Expand Down

0 comments on commit 65e2c96

Please sign in to comment.