n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
45.55k stars 6.28k forks source link

🐛 Main and Webhook node healthz endpoints return 200 OK when they can't connect to Redis #6089

Open pemontto opened 1 year ago

pemontto commented 1 year ago

Describe the bug When running in queue mode, the n8n main and webhook instances don't include health checks for Redis.

To Reproduce Steps to reproduce the behaviour:

  1. Run in queue mode
  2. Shutdown Redis
  3. Run a healthcheck on a webhook or main node
  4. Confirm logs are reporting Redis unavailable - trying to reconnect... "
    
    /data # /usr/bin/wget --server-response --proxy off --no-verbose --tries=1 --timeout=3 127.0.0.1:5678/healthz
    Connecting to 127.0.0.1:5678 (127.0.0.1:5678)
    HTTP/1.1 200 OK
    Content-Type: application/json; charset=utf-8
    Content-Length: 15
    ETag: W/"f-VaSQ4oDUiZblZNAEkkN+sX+q3Sg"
    Vary: Accept-Encoding
    Date: Wed, 26 Apr 2023 15:59:24 GMT
    Connection: close

saving to 'healthz' healthz 100% |**| 15 0:00:00 ETA 'healthz' saved /data # cat healthz {"status":"ok"}



**Expected behaviour**
Just like the worker health check, if `config.getEnv('executions.mode') === 'queue'` for a main or webhook node, then Redis should also be checked:
https://github.com/n8n-io/n8n/blob/0c9ce3a2ec9487b4eb9130651927e91dcd0f85af/packages/cli/src/commands/worker.ts#L326-L333

**Environment (please complete the following information):**

- OS: n8n docker
- n8n Version: 0.225.1
- Node.js Version: 16
- Database system: Postgres
- Operation mode: queue
Joffcom commented 1 year ago

Hey @pemontto,

Thanks for this one, We have been chatting about this internally and don't have a solid solution yet it could be that we overhaul the status page a bit rather than going with a simple ok / not ok.

pemontto commented 1 year ago

Returning a JSON blob that represents each component a la:

{
    "status": "ok",
    "services": {
        "n8n": "ok",
        "db": "ok",
        "redis": "ok"
    }
}

or additional endpoints? /healthz/all /healthz/n8n /healthz/db /healthz/redis

Joffcom commented 1 year ago

That is what needs to be worked out :)