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

2.2k views Asked by At

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

3

There are 3 answers

2
Dustin Ingram On BEST ANSWER

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

1
CommodoreBeard On

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
0
Doracahl On

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.