Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Healthcheck #3010

Open
markusa380 opened this issue Dec 7, 2022 · 17 comments
Open

Docker Healthcheck #3010

markusa380 opened this issue Dec 7, 2022 · 17 comments
Assignees
Labels
docker enhancement New Enhancement good first issue Good for newcomers

Comments

@markusa380
Copy link

Is your feature request related to a problem? Please describe.
It's harder than necessary to detect when OpenSearch Docker containers are ready to accept requests, for example when using testcontainers.

Describe the solution you'd like
I'd like to see the official Docker images use the HEALTHCHECK instruction (which should probably request /_cat/health?v=status) so other systems can depend on it.

Describe alternatives you've considered
Alternative solutions revolve around the systems using the image, e.g. by implementing custom health check loops or, like testcontainers with ElasticSearch, by using a regex on STDOUT.

Additional context
n/a

@markusa380 markusa380 added enhancement New Enhancement untriaged Issues that have not yet been triaged labels Dec 7, 2022
@reta
Copy link
Contributor

reta commented Dec 7, 2022

@dblock dblock transferred this issue from opensearch-project/OpenSearch Dec 9, 2022
@gaiksaya gaiksaya removed the untriaged Issues that have not yet been triaged label Dec 15, 2022
@gaiksaya
Copy link
Member

[Triage] We will look into this. Looks like a good thing to have. Thanks for creating the issue @markusa380

@gaiksaya gaiksaya transferred this issue from opensearch-project/opensearch-devops Dec 15, 2022
@bbarani bbarani added the good first issue Good for newcomers label Jan 11, 2023
@bbarani
Copy link
Member

bbarani commented Jan 25, 2023

@markusa380 Thanks for opening the issue. We are looking in to this issue. In the meantime, feel free to contribute this enhancement.

@Tokesh
Copy link
Contributor

Tokesh commented May 3, 2023

Hello! I'm newbie at Open Source Community. If it still relevant issue, can you provide information about the dockerfiles in which the heartbeat status needs to be added?
I can try to solve this issue. I'll do my best!

@dblock
Copy link
Member

dblock commented May 3, 2023

Is opensearch-project/opensearch-go#315 relevant?

@bbarani
Copy link
Member

bbarani commented May 19, 2023

@prudhvigodithi @peterzhuamazon @rishabh6788 @gaiksaya Do you have some inputs for @Tokesh ?

@gaiksaya
Copy link
Member

@prudhvigodithi
Copy link
Collaborator

prudhvigodithi commented May 19, 2023

Hey @Tokesh welcome to the OpenSearch community. Here is some useful link, we can add a health check with OpenSearch API that shows the health of the container. For helm charts this is how its done you can use this as reference.

@Tokesh
Copy link
Contributor

Tokesh commented May 19, 2023

Thank you all for the details! I am currently taking my college exams. I will try to send the PR for consideration within a week. I don't seem to be blocking anyone.

@prudhvigodithi
Copy link
Collaborator

All the best for your exam @Tokesh.

@peterzhuamazon
Copy link
Member

Thank you all for the details! I am currently taking my college exams. I will try to send the PR for consideration within a week. I don't seem to be blocking anyone.

Sure @Tokesh , all the best to your exam and feel free to ask any questions regarding this issue whenever you need.
Thanks.

@Tokesh
Copy link
Contributor

Tokesh commented May 29, 2023

Now I'm thinking that maybe I made the wrong approach for implementation in my PR. I just added a health check to each service in the docker compose.
Perhaps I need to write an additional service in the docker compose that will check the health of other containers through ping/curl at runtime?

@prudhvigodithi
Copy link
Collaborator

The best practice to add health check in docker is to use HEALTHCHECK in dockerfile.

Example (using https://opensearch.org/docs/2.7/api-reference/cat/cat-health/)

HEALTHCHECK --interval=30s --timeout=3s \
  CMD curl -f http://localhost:9201/_cat/health?v || exit 1

The above once the image is built docker ps should return the status of the container based on the output of http://localhost:9201/_cat/health?

Also FYI this will not impact when running docker in Kubernetes as Kubernetes doesn't use Docker Healthchecks. They are explicitly disabled within Kubernetes.

@Tokesh can you please explore HEALTHCHECK in dockerfile?

Thank you

@Tokesh
Copy link
Contributor

Tokesh commented May 31, 2023

The best practice to add health check in docker is to use HEALTHCHECK in dockerfile.

Also FYI this will not impact when running docker in Kubernetes as Kubernetes doesn't use Docker Healthchecks. They are explicitly disabled within Kubernetes.

Okkie, i got it! I am very glad that I can learn the best practices. Thank you very much! Made a PR to check. Im ready to change or add if that necessary.

@bbarani
Copy link
Member

bbarani commented Jul 10, 2023

@Tokesh Any update on this issue?

@Tokesh
Copy link
Contributor

Tokesh commented Jul 10, 2023

@Tokesh Any update on this issue?

Hello! As I remember, we got a little stuck on the implementation itself. The question was that we need authentication.
If you help me, I would be very happy. Just recently came back home after small vacations. If you give a little more context, what should I do, I can do.

@bbarani
Copy link
Member

bbarani commented Sep 18, 2023

@prudhvigodithi @peterzhuamazon Can you help @Tokesh here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker enhancement New Enhancement good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

8 participants