News for hackers. Stuff that matters.
Re:Show HN: Is_ready – Wait for many services to become avai... by q3k on Sunday April 28, 2024 @05:03AM (#40187132)
Alternative: write your applications to not depend on the liveness of other services to start up. Your ops will thank you.
Re:Show HN: Is_ready – Wait for many services to become avai... by no_circuit on Sunday April 28, 2024 @07:40AM (#40187847)
That makes a lot of sense for application servers when one controls the stack and can implement something like exponential backoff, and services are expected to already be running.

However it is not realistic to make sure all library dependencies used behave properly for more lambda-like jobs where a library/app like "wait for" is very useful since it reduces the backoff parameters that ops needs to know about, and reduces unnecessary errors in logs.

Take GCP Cloud SQL Auth Proxy [1] for example which simplifies the details of securely connecting to a database without exposing long-term credentials to app code. Typically for the audience that uses the proxy, it is run as a sidecar container in Kubernetes Pod and has a non-deterministic startup time in the range of a few seconds. There is no "depends_on" facility like in Docker (at least when I had to use it). Your batch job could potentially always fail if the proxy cannot establish a connection to the database before your minimal database migration container starts up. Building the backoff inside the migration app makes it more opaque for ops teams. Having this "wait for" run in a startup script before the main app allow ops to tune its parameters, such as through environment variables, so that the job behaves appropriately under health probes [2] for higher level backoffs. All of which can be configured without recompiling the main app code, or embedding the functionality in the first place.

[1] https://cloud.google.com/sql/docs/postgres/connect-auth-prox...

[2] https://kubernetes.io/docs/tasks/configure-pod-container/con...

Re:Show HN: Is_ready – Wait for many services to become avai... by stavepan on Sunday April 28, 2024 @05:08AM (#40187157)
Can you suggest to me one way for an API service to wait for a database to accept connections to run the database migrations without the API depending on the liveness of the database to start up?
Re:Show HN: Is_ready – Wait for many services to become avai... by ivan_gammel on Sunday April 28, 2024 @05:17AM (#40187192)
Start the server and respond 503 every time when your database and other dependencies are not ready. Couldn’t be easier.
Re:Show HN: Is_ready – Wait for many services to become avai... by stavepan on Sunday April 28, 2024 @08:20AM (#40188068)
Many people have the following setup in docker-compose.yml file.

version: '3' services: mysql: image: mysql:8.0

  app:
    build: .
    command: is_ready --timeout 10 --addr mysql:3306 -- <run migrations command>
For cases like this, returning 503 every time the database is not ready, is not very convenient.
Re:Show HN: Is_ready – Wait for many services to become avai... by liampulles on Sunday April 28, 2024 @08:51AM (#40188233)
I think the pragmatic answer is you should wait for your database to be live before starting up. One just wants to lean on the side of depending on a few critical services rather than all potentially-utlizied application services.