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

app-proxy health check fails with 404 response #436

Closed
lhriley opened this issue Dec 21, 2023 · 0 comments · Fixed by #437
Closed

app-proxy health check fails with 404 response #436

lhriley opened this issue Dec 21, 2023 · 0 comments · Fixed by #437
Assignees

Comments

@lhriley
Copy link

lhriley commented Dec 21, 2023

Health check fails with defaults:

❯ kubectl -n codefresh-workers logs -f deployment.apps/cf-runtime-app-proxy
Found 3 pods, using pod/cf-runtime-app-proxy-995b74d8d-7bktr
Using newrelic: {"config":{"app_name":"app-proxy [production]","logging":{"enabled":false,"level":"info"},"error_collector":{"ignore_status_codes":["400-600"]}}}
New Relic for Node.js halted startup due to an error:
Error: Not starting without license key!
    at onNextTick (/app/cf-app-proxy/node_modules/newrelic/lib/agent.js:245:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
[2023-12-21T20:25:02.733Z INFO] >> validating connection to "https://g.codefresh.io/" {"namespace":"codefresh:index"}
[2023-12-21T20:25:02.894Z INFO] >> connection to platform validated {"namespace":"codefresh:index"}
[2023-12-21T20:25:02.895Z INFO] >> initializing server {"namespace":"codefresh:index"}
[2023-12-21T20:25:02.899Z INFO] >> app proxy running on ::3000 {"namespace":"codefresh:index"}
[2023-12-21T20:25:06.237Z] GET /health 404 145 - 4.530 ms
[2023-12-21T20:25:11.225Z] GET /health 404 145 - 0.652 ms
[2023-12-21T20:25:16.226Z] GET /health 404 145 - 0.765 ms
[2023-12-21T20:25:21.225Z] GET /health 404 145 - 0.617 ms
[2023-12-21T20:25:26.225Z] GET /health 404 145 - 0.583 ms
[2023-12-21T20:25:31.225Z] GET /health 404 145 - 0.492 ms
[2023-12-21T20:25:36.225Z] GET /health 404 145 - 0.357 ms

I can show that this works locally by running the container and curling the health endpoint:

❯ docker run --rm -it -p 3000:3000 -P quay.io/codefresh/cf-app-proxy:0.0.45
Using newrelic: {"config":{"app_name":"app-proxy [production]","logging":{"enabled":false,"level":"info"},"error_collector":{"ignore_status_codes":["400-600"]}}}
New Relic for Node.js halted startup due to an error:
Error: Not starting without license key!
    at onNextTick (/app/cf-app-proxy/node_modules/newrelic/lib/agent.js:245:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
[2023-12-21T20:41:49.490Z INFO] >> validating connection to "https://g.codefresh.io" {"namespace":"codefresh:index"}
[2023-12-21T20:41:49.693Z INFO] >> connection to platform validated {"namespace":"codefresh:index"}
[2023-12-21T20:41:49.693Z INFO] >> initializing server {"namespace":"codefresh:index"}
[2023-12-21T20:41:49.697Z INFO] >> app proxy running on ::3000 {"namespace":"codefresh:index"}
^C[2023-12-21T20:51:43.438Z INFO] >> got SIGTERM, exiting gracefully {"namespace":"codefresh:server:index"}
[2023-12-21T20:51:43.440Z INFO] >> server exited gracefully {"namespace":"codefresh:server:index"}
❯ curl 127.0.0.1:3000/health
ok%        

With this information I tested this by port-forwarding to the running pod and adding an additional / to the health check when I did a curl:

❯ kubectl -n codefresh-workers port-forward deployments/cf-runtime-app-proxy 3000:3000
Forwarding from 127.0.0.1:3000 -> 3000
Forwarding from [::1]:3000 -> 3000
Handling connection for 3000
Handling connection for 3000
❯ curl 127.0.0.1:3000/health
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot GET /health</pre>
</body>
</html>
❯ curl 127.0.0.1:3000//health
ok%   

I think the issue is here, and should be an empty string, maybe?

            - name: API_PATH_PREFIX
              value: /

Either that or you expect a double // as the API path prefix? In which case the solution would be to use //health as the probe endpoint:

          readinessProbe:
            failureThreshold: 5
            httpGet:
              path: /health
              port: http
              scheme: HTTP

Update: I can confirm that setting API_PATH_PREFIX as an empty string "" fixes the healthcheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants