History

Report healthy status for initial 120s, then switch to healthcheck (#4799)

Swarm routes traffic only to containers that report healthy status, while Minio in distributed mode needs to talk to other peers before it can respond to healthcheck probe. As the Minio containers are not able to talk to each other, distributed Minio is not getting started on Docker Swarm. With this PR, Minio Healthcheck report healthy status for initial 120s enough for distributed Minio to start. After that normal Healthcheck resumes. Also changed the healthcheck method name in accordance with Google shell styleguide.

Nitish Tiwari committed 9 years ago

Commit 53f84d61 parent d864e001 file · +30 −15Browse files

Showing the changes to buildscripts (1 of 1 file). Show all

Unified · Split

buildscripts/healthcheck.sh+30−15
@@ -19,25 +19,40 @@ _init () { · 18 unmodified lines
19 scheme="http://"19 scheme="http://"
20 address="127.0.0.1:9000"20 address="127.0.0.1:9000"
21 resource="/minio/index.html"21 resource="/minio/index.html"
22 start=$(stat -c "%Y" /proc/1)
22}23}
23 24
24HealthCheckMain () {25healthcheck_main () {
25 # Get the http response code26 # In distributed environment like Swarm, traffic is routed
26 http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" ${scheme}${address}${resource})27 # to a container only when it reports a `healthy` status. So, we exit
28 # with 0 to ensure healthy status till distributed Minio starts (120s).
29 #
30 # Refer: https://github.com/moby/moby/pull/28938#issuecomment-301753272
31 if [ $(( $(date +%s) - start )) -lt 120 ]; then
32 exit 0
33 else
34 # Get the http response code
35 http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" \
36 ${scheme}${address}${resource})
27 37
28 # Get the http response body38 # Get the http response body
29 http_response_body=$(curl -k -s ${scheme}${address}${resource})39 http_response_body=$(curl -k -s ${scheme}${address}${resource})
30 40
31 # server returns response 403 and body "SSL required" if non-TLS connection is attempted on a TLS-configured server. 41 # server returns response 403 and body "SSL required" if non-TLS
32 # change the scheme and try again42 # connection is attempted on a TLS-configured server. Change
33 if [ "$http_response" = "403" ] && [ "$http_response_body" = "SSL required" ]; then43 # the scheme and try again
34 scheme="https://"44 if [ "$http_response" = "403" ] && \
35 http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" ${scheme}${address}${resource})45 [ "$http_response_body" = "SSL required" ]; then
36 fi46 scheme="https://"
47 http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" \
48 ${scheme}${address}${resource})
49 fi
37 50
38 # If http_repsonse is 200 - server is up. 51 # If http_repsonse is 200 - server is up. When MINIO_BROWSER is
39 # When MINIO_BROWSER is set to off, curl responds with 404. We assume that the the server is up52 # set to off, curl responds with 404. We assume that the server
40 [ "$http_response" = "200" ] || [ "$http_response" = "404" ]53 # is up
54 [ "$http_response" = "200" ] || [ "$http_response" = "404" ]
55 fi
41}56}
42 57
43_init && HealthCheckMain58_init && healthcheck_main

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t