Skip to content

Conversation

taimoorzaeem
Copy link
Collaborator

@taimoorzaeem taimoorzaeem commented Aug 17, 2025

The --ready flag is a wrapper around the admin server /ready request. This is done through using an http client library in postgrest.

  • Implementation
  • Docs

Closes #4239.

@taimoorzaeem taimoorzaeem marked this pull request as draft August 20, 2025 18:32
@taimoorzaeem
Copy link
Collaborator Author

@steve-chavez Where do we document this new flag, I guess in https://docs.postgrest.org/en/v13/references/cli.html?

@steve-chavez
Copy link
Member

@taimoorzaeem Yes, should be in CLI.

@taimoorzaeem taimoorzaeem marked this pull request as ready for review August 26, 2025 06:50
@steve-chavez
Copy link
Member

@taimoorzaeem Just tried:

$ postgrest-run -- --ready
postgrest: HttpExceptionRequest Request {
  host                 = "0.0.0.0"
  port                 = 3001
  secure               = False
  requestHeaders       = []
  path                 = "/ready"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
  proxySecureMode      = ProxySecureWithConnect
}
 (ConnectionFailure Network.Socket.connect: <socket: 13>: does not exist (Connection refused))

The error is expected, but can we make it clearer? (no Haskell type wrapping)

@steve-chavez
Copy link
Member

Also noted that on success we don't print anything:

$ postgrest-run -- --ready

# result is good
$ echo $?
0

Maybe we should print something like traefik:

$ postgrest-run -- --ready
OK: http://:<port>/ready

@taimoorzaeem taimoorzaeem marked this pull request as draft August 26, 2025 19:00
The `--ready` flag is a wrapper around the admin server
`/ready` request. This is done through using an http client
library in postgrest.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
Comment on lines +332 to +337
healthcheck_process = subprocess.run(command, env=env, capture_output=True)
assert healthcheck_process.returncode == 1
assert (
"postgrest: health check request failed - connection refused to"
in healthcheck_process.stderr.decode()
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is flaky and fails sometimes because the subprocess.run exits without capturing the stderr output. I guess this happens due to output not being flushed properly. Any ideas on how to handle this cleanly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead try to force a schema cache failure so /ready always fails. An idea could be to put a bad database connection uri. Check the io tests too, likely this was done before.

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

Successfully merging this pull request may close these issues.

New CLI option --ready
3 participants