Open-event-server: Implement docker healthcheck and fix endpoint

Created on 27 Sep 2019  路  26Comments  路  Source: fossasia/open-event-server

Currently, the health check endpoint shows that celery is not up. Which is untrue
https://api.eventyay.com/health-check

Besides, the presence or absence of celery does not signify the health of the web container. Hence, only DB and migrations should be checked by default and celery should have another endpoint for itself for checking the celery container

The second part of the issue is to add healthcheck command to Dockerfile so that

  1. DockerHub can automatically test to see if it runs or not (will most likely fail as it depends on PSQL)
  2. Docker Compose can restart brain dead containers - live containers no longer fit for serving requests
bug codeheat devOps enhancement good-first-issue hacktoberfest help-wanted

All 26 comments

Hello I want to work on this issue.. If anyone is not doing.

Go ahead

Hello, my suggestion is create a endpoint for /healthcheck and other for /working.

/healthcheck : Return 200 if ok.

[{}]

/working : Return a list of all dependency
ex:

[  
{
  service: "mongo-db",
  status: "working",
  error_description: "",
  error_code: ""
},
{
  service: "api_celery",
  status: "Error",
  error_description: "health_check_celery",
  error_code: "TO001"
}
]

This structure is good, so the healthcheck response time is short.
I use this structure in my projects

Makes sense :+1:

Create a issue for this fix endpoints??
I think it would be better to create issue to fix the docker and other for docker.

There is already a healthcheck endpoint, it just needs to get fixed

Hi @iamareebjamal I would like to work on this. Should I start on it if nobody's working on it?

Yes, please, go ahead

@iamareebjamal Can I work on this issue if it is still available?

@YashJipkate is working on it

I am new to this open source community. I would like to know can i work on this issue if anyone is not working?and can anyone guide me through what to do in this and to setup the environment for that?

@iamareebjamal while running http://localhost:5000/health-check it gives INFO:werkzeug:127.0.0.1 - - [09/Dec/2019 21:27:42] "GET /health-check HTTP/1.1" 404 - Can you tell me why it's not working?

Also, for the celery endpoint as stated

celery should have another endpoint for itself for checking the celery container

But when I referred to the PRs you said here that no, new end point is not needed. https://github.com/fossasia/open-event-server/pull/6544#issuecomment-544438124

What should be done?

/health-check?celery

Can you tell me why it's not working?

Debug

@iamareebjamal Does the server needs up be run via docker inorder for the health-check to be working?

How would server even know it is running inside docker?

Okay, I will debug but the https://api.eventyay.com/health-check endpoint is working fine. Okay will debug and get back to you. Thanks.

It's not

I meant that the endpoint is giving a proper response

{"hostname": "835219ead0c8", "status": "success", "timestamp": 1575918192.6720035, "results": [{"checker": "health_check_celery", "output": "celery ok", "passed": true, "timestamp": 1575918192.6703465, "expires": 1575918219.6703465}, {"checker": "health_check_db", "output": "database ok", "passed": true, "timestamp": 1575918192.6719618, "expires": 1575918219.6719618}, {"checker": "health_check_migrations", "output": "database up to date with migrations", "passed": true, "timestamp": 1575918192.6719916, "expires": 1575918219.6719916}]}

As per the issue,

Currently, the health check endpoint shows that celery is not up. Which is untrue

The response is saying celery ok
@iamareebjamal

It wasn't working at the time of me raising the issue. Anyway it is mainly about separating the endpoint of celery and adding healthcheck in Dockerfile

@iamareebjamal Health-check was previously giving me 404 error for my machine, but then I followed the documentation and changed to

# Health-check
health = HealthCheck(current_app)
health.add_check(health_check_db())
current_app.add_url_rule("/healthcheck", "healthcheck", view_func=lambda: health.run())

But when hitting localhost:5000/healthcheck getting 500 status

AttributeError: 'tuple' object has no attribute '__name__'

image

@iamareebjamal The second part of the issue shall be done in same PR or another PR?

Same

Is this issue available to work on? @mariobehling @iamareebjamal

Green means open

Is this issue is available to work on it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mariobehling picture mariobehling  路  4Comments

schedutron picture schedutron  路  4Comments

iamareebjamal picture iamareebjamal  路  4Comments

dr0pdb picture dr0pdb  路  4Comments

mariobehling picture mariobehling  路  4Comments