PodStorage¶
- class controller.storage.kubernetes.pod.PodStorage(api_client, logger)¶
Bases:
KubernetesObjectDeleter
Storage layer for
Pod
objects.- Parameters:
api_client (
ApiClient
) – Kubernetes API client.logger (
BoundLogger
) – Logger to use.
Methods Summary
delete_after_completion
(name, namespace, timeout)Wait for a pod to complete and then delete it.
events_for_pod
(name, namespace, timeout)Iterate over Kubernetes events involving a pod.
wait_for_phase
(name, namespace, timeout, *, ...)Wait for a pod to exit a set of phases.
watch_pod_changes
(namespace)Watches a namespace for pod changes (not creation or deletion).
Methods Documentation
- async delete_after_completion(name, namespace, timeout)¶
Wait for a pod to complete and then delete it.
This first waits for a pod to finish running, after which it deletes the pod. This method does not wait for the pod to be deleted before returning.
- Parameters:
- Raises:
ControllerTimeoutError – Raised if the timeout expires while waiting for a pod phase change.
KubernetesError – Raised if there is some failure in a Kubernetes API call.
TimeoutError – Raised if the timeout expires while performing Kubernetes operations.
- Return type:
- async events_for_pod(name, namespace, timeout)¶
Iterate over Kubernetes events involving a pod.
Watches for events involving a pod, yielding them. Must be cancelled by the caller when the watch is no longer of interest.
- Parameters:
- Yields:
str – The next observed event.
- Raises:
KubernetesError – Raised if there is some failure in a Kubernetes API call.
- Return type:
- async wait_for_phase(name, namespace, timeout, *, until_not)¶
Wait for a pod to exit a set of phases.
Waits for the pod to reach a phase other than the ones given, and returns the new phase.
- Parameters:
- Returns:
New pod phase, or
None
if the pod has disappeared.- Return type:
- Raises:
ControllerTimeoutError – Raised if the timeout expires.
KubernetesError – Raised if there is some failure in a Kubernetes API call.
TimeoutError – Raised if the timeout expires while getting the starting pod phase.
- async watch_pod_changes(namespace)¶
Watches a namespace for pod changes (not creation or deletion).
This watch will continue forever until cancelled. It is meant to be run from a background task handling pod changes continuously.
- Parameters:
namespace (
str
) – Namespace to watch for changes.- Yields:
PodChange – Change to a pod in this namespace.
- Raises:
KubernetesError – Raised if there is some failure in a Kubernetes API call.
- Return type: