Skip to main content

probe

Asking a child's local server whether it is healthy.

Module​

Functions​

get​

def get(    url: str, *, ssl_context: ssl.SSLContext | None = None, timeout: float = 3.0,) ‑> bytes:

GET url from a child's local server, which must answer successfully.

Arguments

  • url: The http or https loopback URL to ask.
  • ssl_context: How to verify the server's certificate, for https.
  • timeout: How long to wait for an answer, in seconds.

Returns The body it answered with.

Raises

  • ProbeFailed: If the server did not answer, or answered with an error status.

get_json​

def get_json(    url: str, *, ssl_context: ssl.SSLContext | None = None, timeout: float = 3.0,) ‑> Any:

GET url as get does, and parse the JSON it answers with.

Arguments

  • url: The http or https loopback URL to ask.
  • ssl_context: How to verify the server's certificate, for https.
  • timeout: How long to wait for an answer, in seconds.

Returns The parsed body.

Raises

  • ProbeFailed: As get, or if the body is not JSON.

loopback_tls_context​

def loopback_tls_context() ‑> ssl.SSLContext:

A TLS context that verifies a certificate's chain and dates, not its name.

A probe dials 127.0.0.1, which a certificate issued for the compute's domain never names, so the name check could only fail. An expired or untrusted certificate still fails, as it would for a real client.

unverified_tls_context​

def unverified_tls_context() ‑> ssl.SSLContext:

A TLS context that checks nothing about the server's certificate.

For asking what answers on a port, not for trusting it: nothing is sent over it that the server should not see.

Global variables​

  • PROBE_TIMEOUT_SECONDS : Final[float] - How long one probe waits for a child to answer. Probes run on the registration tick, so a hung child must not hold it up for long.

Classes​

ProbeFailed​

class ProbeFailed(*args, **kwargs):

A child's server did not give a usable answer, and why.