pod
The pod child.
Module
Global variables
POD_CONFIG_ERROR_EXIT_CODE : Final[int]- The exit code with which a pod child says the configuration it was started with is invalid: it would fail the same way however often it was started again with it.EX_CONFIGfromsysexits.h.
POD_INSTANCE_ID_ENV_VAR : Final[str]- The environment variable carrying a pod child's identity to it, which the pod reads asconfig.settings.private.pod_instance_idand reports on its control server's/health._BITFOUNT_-prefixed so the settings read it as private. Minted fresh for every pod child the compute starts, so a host can tell its own live pod from one a previous generation left behind.
POD_RESTART_POLICY : Final[RestartPolicy]- How a host that wants its pod kept running has the compute restart it. A pod that exits is restarted. So is one that stops answering: a pod that has answered a health check and then goes quiet for ten checks in a row is wedged, not still coming up, so it is killed and restarted -- killing it skips its own shutdown and leaves the processes it started behind, which is the price of bringing the pod back. Ten minutes rather than fewer, so a pod busy with a large sweep cannot be taken for a wedged one; one that has never answered a check is left alone however long it takes, as loading its datasets is slow rather than broken and killing it would only start the load again. A pod that never came up waits up to ten minutes between attempts, as that is usually because something it needs from outside (the hub, the network, a drive) is not there yet. A pod whose configuration is invalid is left down until it is started again.
Classes
PodChild
class PodChild( spec: ChildSpecSource, *, identity: ComputeIdentity, host_key: HostCacheKey | None = None,):The pod child.
Not a daemon, because the pod starts processes of its own (schema
generation), which a daemon process may not; it is stopped explicitly
instead. Every start is handed a freshly minted identity (see
POD_INSTANCE_ID_ENV_VAR), reported as status().instance_id, so a host
that needs to know whether a call actually restarted the pod compares it
before and after.
Healthy when its control server says it is ready and answers with the identity this start was given, so a pod left behind on the same port by an earlier run is never taken for this one. Whether its datasets are usable is not part of this: the pod reports that to the hub itself.
Every start is also handed the same host cache key, so each pod process of one Compute serves its DAG runs the same key.
Arguments
spec: What to run as the pod: a spec, or a function building a fresh one for each pod process.identity: The compute's identity, whose installation id prefixes each minted pod identity.host_key: The Compute host's cache key, handed to every pod process this child starts, orNoneto hand none.
Ancestors
Variables
- static
label : ClassVar[str]- What the child is called in logs, as in "the pod child".
- static
name : ClassVar[str]- What the child is called in the hub's compute heartbeat.
Static methods
orphan_answer
def orphan_answer(port: int) ‑> collections.abc.Mapping[str, typing.Any] | None:What a pod's control server, from any build, answers on port.
Arguments
port: The port to ask on.
Returns
Its /health body, or None if nothing answers there as a pod.
port
def port() ‑> int:The control port the pod serves on.
Methods
check_health
def check_health(self) ‑> ChildHealth:Inherited from:
Check the child now, and keep the result for status().
A child that is not running is unhealthy without being asked. A result for a process that was stopped or replaced while it was being checked is returned but not kept.
Returns Whether the child is healthy, and why not if it is not.
clear_orphan
def clear_orphan(self) ‑> int | None:Inherited from:
Clear the child's port of a child an earlier run left on it.
Done before every start, and safe to do at any other time: this child's own running process is never cleared, so a host may clear ahead of taking a lock it would otherwise hold throughout.
Returns
The pid of the process cleared, or None if there was none.
Raises
ChildPortHeldError: If the port is held and could not be cleared.
is_alive
def is_alive(self) ‑> bool:Inherited from:
Whether the child has been started and is still running.
kill
def kill(self) ‑> None:Inherited from:
Kill the child at once, with none of the grace stop gives it.
For a child that has stopped answering: it will not shut down cleanly, and waiting for it would hold up everything else waiting on the compute's lock. Its process is kept, so it reads as exited until it is started again.
Reported as KILLED without a log line of its own: whoever decides a
child is not worth waiting for says why in its own.
latest_health
def latest_health(self) ‑> ChildHealth:Inherited from:
The child's health now, without probing it.
Its last check's result while it is running. A child that is not running is unhealthy whatever its last check said.
replace_spec
def replace_spec(self, spec: ChildSpecSource) ‑> None:Run spec as the pod from its next start on.
A running pod is left alone: only a later start uses it.
Arguments
spec: What to run as the pod: a spec, or a function building a fresh one for each pod process.
start
def start(self) ‑> None:Inherited from:
Start the child if it is not running.
A child an earlier run left on the port is cleared first (see
orphans). A process that cannot be started leaves the last one, if
it had one, in place: a child restarted after a crash still reads as
exited, with its exit code, until a start succeeds.
Raises
ChildPortHeldError: If the child's port is held and could not be cleared, once reported.Exception: Whatever starting the process raised, once reported.
status
def status(self) ‑> ChildStatus:The pod's state, including the identity it was started with.
stop
def stop(self) ‑> None:Stop the pod if it is running, and forget the identity it had.