8

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

user1502505
  • 724
  • 1
  • 8
  • 11

3 Answers3

6

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

Dustin Ingram
  • 20,502
  • 7
  • 59
  • 82
  • There's more information about this [here](https://stackoverflow.com/questions/43380939/where-does-the-convention-of-using-healthz-for-application-health-checks-come-f). – Rafael Feb 23 '21 at 13:09
  • Fix for /healthz conflict with GCP in streamlit v1.18 – Doracahl Feb 15 '23 at 22:49
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
CommodoreBeard
  • 340
  • 2
  • 12
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.

Doracahl
  • 336
  • 2
  • 14