/healthz route of an app deployed on Google App Engine returns 404
S

3

9

HTTP requests for a /healthz route on an app deployed on Google App Engine don't seem to reach the /healthz endpoint within the app.
Instead, a 404 page is served, apparently from the GCP infrastructure.
Can I know how to override this behaviour and make these requests reach my app?

Thank you.

enter image description here.

A bit more background:

I'm deploying a Streamlit app on Google App Engine.
Streamlit web UI appear to be sending requests to the /healthz endpoint periodically, and when these requests fail, Streamlit app stops working and displays an error message as below.

enter image description here

Sloganeer answered 7/10, 2020 at 5:40 Comment(1)
The latest release of Streamlit fixes this /healthz endpoint clash with GCP. Please see v1.18 in the change logs.Halyard
A
7

Some URL paths ending in z, including /healthz, are reserved for use by App Engine and cannot be used.

Arber answered 7/10, 2020 at 14:1 Comment(2)
There's more information about this here.Dawnedawson
Fix for /healthz conflict with GCP in streamlit v1.18Halyard
V
6

I have managed to get around the healthz conflict in a rather nasty way. I also enabled session_affinity to help with websocket connections.

here is my app.yaml, ill explain the healthz fix below:

runtime: python
env: flex
# This is a horrible workaround to get streamlit working on app engine
# https://discuss.streamlit.io/t/has-anyone-deployed-to-google-cloud-platform/931/20
entrypoint: find ${VIRTUAL_ENV}/lib/python3.6/site-packages/streamlit -type f \( -iname \*.py -o -iname \*.js \) -print0 | xargs -0 sed -i 's/healthz/health-check/g' && streamlit run sim_v3.py --server.port $PORT --server.enableCORS=false

runtime_config:
  python_version: 3

manual_scaling:
  instances: 1

network:
  session_affinity: true

The hack is happening in the entrypoint command. I am finding all files in the python virtualenv dependencies folder, site-packages, that are either .py or .js and replacing healthz with health-check

If you are intending on supporting a deployed streamlit app, I suggest you avoid this solution. It will break if

  • the version of python changes in the google python runtime
  • streamlit make a change that would break this inline replacement
  • google decide to change their folder naming conventions
Vice answered 8/12, 2020 at 10:29 Comment(1)
Great hack here - streamlit package has released a stable fix for this /healthz issue in v1.18Halyard
H
1

The latest release of Streamlit fixes this /healthz endpoint clash with GCP. Please see v1.18 in the change logs.

Please upgrade to the latest Streamlit version.

Halyard answered 13/2, 2023 at 15:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.