Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

use docker healthcheck #27

Closed
wants to merge 4 commits into from

Conversation

shadiakiki1986
Copy link
Contributor

This PR adds support for healthcheck in the docker-compose file.
ATM, your repo's tester has a built-in wait for health check in tests/es_acceptance.py in function wait_for_cluster_health. Using docker's healthcheck, other services can benefit from this without having to re-code a wait for health check function in each. On the down-side, this requires upgrading the yml version from 2.0 to 2.1, and hence upgrading docker-compose and docker to versions supporting it

Maybe creating a separate branch for this would be convenient?

Note that I ran make for testing and it failed with a connection failed error, but then again I ran make on master, and it also failed.

@elasticmachine
Copy link
Collaborator

Can one of the admins verify this patch?

4 similar comments
@elasticmachine
Copy link
Collaborator

Can one of the admins verify this patch?

@elasticmachine
Copy link
Collaborator

Can one of the admins verify this patch?

@elasticmachine
Copy link
Collaborator

Can one of the admins verify this patch?

@elasticmachine
Copy link
Collaborator

Can one of the admins verify this patch?

@dliappis
Copy link
Contributor

Thanks for your interest and the PR!

The trouble with this approach is that curl requests will fail as x-pack (inc. security) is included in the Elasticsearch image and thus those API calls require authentication.

So for that to work we'd need to tweak the default x-pack configuration and allow anonymous access specifically to a chosen health check endpoint (e.g. _cat/health).

Additionally, for every new feature added, we need acceptance tests, so we'll need to add python tests to ensure this is working as expected.

Incidentally, I just tried make on both the master and 5.2 branches and all tests pass.

@shadiakiki1986
Copy link
Contributor Author

You're right about the authorization issue with xpack. I did not face it because I was just overriding the configuration with one that doesn't use xpack. What do you suggest as next steps for this PR?

host="$(hostname -i || echo '127.0.0.1')"

# TODO with xpack, the below curl will fail with "unauthorized" error if xpack is enabled
if health="$(curl -fsSL "http://$host:9200/_cat/health?h=status")"; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even if you get a 401/403 response code, this means container is healthy
you could call curl -I -X "http://$host:9200" and parse response code

@dliappis
Copy link
Contributor

dliappis commented Nov 7, 2017

Closing this based on the argumentation in #60

@dliappis dliappis closed this Nov 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants