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
1919 scheme="http://"
2020 address="127.0.0.1:9000"
2121 resource="/minio/index.html"
22+ start=$(stat -c "%Y" /proc/1)
2223 }
2324
24−HealthCheckMain () {
25− # Get the http response code
26− http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" ${scheme}${address}${resource})
25+healthcheck_main () {
26+ # In distributed environment like Swarm, traffic is routed
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})
2737
28− # Get the http response body
29− http_response_body=$(curl -k -s ${scheme}${address}${resource})
38+ # Get the http response body
39+ http_response_body=$(curl -k -s ${scheme}${address}${resource})
3040
31− # server returns response 403 and body "SSL required" if non-TLS connection is attempted on a TLS-configured server.
32− # change the scheme and try again
33− if [ "$http_response" = "403" ] && [ "$http_response_body" = "SSL required" ]; then
34− scheme="https://"
35− http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" ${scheme}${address}${resource})
36− fi
41+ # server returns response 403 and body "SSL required" if non-TLS
42+ # connection is attempted on a TLS-configured server. Change
43+ # the scheme and try again
44+ if [ "$http_response" = "403" ] && \
45+ [ "$http_response_body" = "SSL required" ]; then
46+ scheme="https://"
47+ http_response=$(curl -s -k -o /dev/null -I -w "%{http_code}" \
48+ ${scheme}${address}${resource})
49+ fi
3750
38− # If http_repsonse is 200 - server is up.
39− # When MINIO_BROWSER is set to off, curl responds with 404. We assume that the the server is up
40− [ "$http_response" = "200" ] || [ "$http_response" = "404" ]
51+ # If http_repsonse is 200 - server is up. When MINIO_BROWSER is
52+ # set to off, curl responds with 404. We assume that the server
53+ # is up
54+ [ "$http_response" = "200" ] || [ "$http_response" = "404" ]
55+ fi
4156 }
4257
43−_init && HealthCheckMain
58+_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