Whether a runner is alive (Effect's RunnerHealth). Sharding keeps
the shards of a live runner where they are, and moves those of a dead
one: layer_noop says every runner is alive, layer_ping pings it
through Runners, and layer_k8s reads its pod's readiness.
Values#
| Attribute | Type | Description |
|---|---|---|
layer_noop | Layer[RunnerHealth] | Every runner is alive (for tests and local development). |
make_ping | Effect[RunnerHealthService, Never, Runners] | Alive when a ping answers within ten seconds, retried five times half a second apart. |
layer_ping | Layer[RunnerHealth, Never, Runners] |
|
Classes#
Functions#
make_k8s#
make_k8s(*, namespace=None, label_selector=None) -> Effect[RunnerHealthService, Never, K8sHttpClient]Alive when the pod at the runner's host is ready or initializing; alive too when the Kubernetes API cannot be read.
| Parameter | Type | Description |
|---|---|---|
namespace | str | None = None | |
label_selector | str | None = None |
Returns Effect[RunnerHealthService, Never, K8sHttpClient]
def make_k8s(
*, namespace: str | None = None, label_selector: str | None = None
) -> Effect[RunnerHealthService, Never, K8sHttpClient]:
"""Alive when the pod at the runner's host is ready or initializing;
alive too when the Kubernetes API cannot be read."""
def service(pods: Effect[dict[str, Pod], object]) -> RunnerHealthService:
def is_alive(address: RunnerAddress) -> Effect[bool]:
def ready(by_ip: dict[str, Pod]) -> bool:
pod = by_ip.get(address.host)
return pod is not None and pod.is_ready_or_initializing
return pods.map(ready).catch_cause(lambda _: succeed(True))
return RunnerHealthService(is_alive)
return make_get_pods(namespace=namespace, label_selector=label_selector).map(service)layer_k8s#
layer_k8s(*, namespace=None, label_selector=None) -> Layer[RunnerHealth, Never, K8sHttpClient]make_k8s as a layer. The HttpClient must trust the pod CA
and the service account must be allowed to list pods.
| Parameter | Type | Description |
|---|---|---|
namespace | str | None = None | |
label_selector | str | None = None |
Returns Layer[RunnerHealth, Never, K8sHttpClient]
def layer_k8s(
*, namespace: str | None = None, label_selector: str | None = None
) -> Layer[RunnerHealth, Never, K8sHttpClient]:
"""``make_k8s`` as a layer. The ``HttpClient`` must trust the pod CA
and the service account must be allowed to list pods."""
return layer_.effect(RunnerHealth, make_k8s(namespace=namespace, label_selector=label_selector))