Documentation
¶
Overview ¶
Package podread is the only place controller code reads Pods (ADR-102).
The manager's cache holds only Pods that carry the NVCRE job label. A Pod read therefore has to know whether every pod it needs carries that label, and the answer belongs to what is being read, not to each caller. Each method here names what it reads and picks its source: the cache, under a selector the method builds itself, or the API server. A new kind of read is a new method, where its source is decided and reviewed.
Index ¶
- Constants
- type Reader
- func (r *Reader) ActiveJobPods(ctx context.Context, namespace, job string) ([]corev1.Pod, error)
- func (r *Reader) JobPods(ctx context.Context, namespace, job string) ([]corev1.Pod, error)
- func (r *Reader) JobPodsOnNode(ctx context.Context, node string) ([]corev1.Pod, error)
- func (r *Reader) NamespacePods(ctx context.Context, namespace string) ([]corev1.Pod, error)
- func (r *Reader) WorkloadPods(ctx context.Context, namespace, workload, replicatedJob string) ([]corev1.Pod, error)
Constants ¶
const ( // JobLabel is injected into the pod template of an NVCRE Job's workers and // names the Job. The manager's cache holds only Pods that carry it. JobLabel = "nvcre.nvidia.com/job" // LauncherLabel is injected into the pod template of an MPI workload's // launcher and names the Job. The manager's Pod cache does not hold these // pods; a second cache that holds only them backs the Job controller's // launcher watch and answers no reads (ADR-102, amendment). The launcher // is read here, live, through WorkloadPods. LauncherLabel = "nvcre.nvidia.com/launcher" // JobIndexField indexes cached Pods by JobLabel's value. JobIndexField = "metadata.labels." + JobLabel // NodeNameIndexField indexes cached Pods by spec.nodeName. NodeNameIndexField = "spec.nodeName" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads Pods from the manager's job-scoped cache or from the API server, whichever the read needs.
func New ¶
New returns a Reader. cached is the manager's client, which reads through the job-scoped cache; live reads the API server, normally the manager's APIReader. A unit test may pass the same fake client for both.
A nil live is not replaced by cached: the live reads exist because the cache cannot answer them, and ActiveJobPods' check against the API server would quietly become a second cached read. Every live read then fails with errNoLiveReader instead, logged and counted like any failed read.
func (*Reader) ActiveJobPods ¶
ActiveJobPods returns a Job's workload pods that have not finished: the pods carrying JobLabel=job in namespace whose phase is neither Succeeded nor Failed. It reads the cache, and when no active pod remains there it reads the API server before returning none.
A caller acts on "none active": the drain barrier lets teardown proceed. The cache can hold a Job's finished pods and miss a newer one that is still running, so the API server is checked whenever filtering leaves no active pod, not only when the cached list is empty. The check selects on the job label, so it sees what the cache would hold once it catches up.
func (*Reader) JobPods ¶
JobPods returns a Job's workload pods from the cache: the pods carrying JobLabel=job in namespace. No pods is an empty slice and a nil error.
func (*Reader) JobPodsOnNode ¶
JobPodsOnNode returns the NVCRE workload pods bound to node, from the cache, through the spec.nodeName index and JobLabel. Pods of other components on the node are not returned.
func (*Reader) NamespacePods ¶
NamespacePods returns every pod in namespace from the API server, for reads of other components' pods, such as installers in kube-system.
func (*Reader) WorkloadPods ¶
func (r *Reader) WorkloadPods(ctx context.Context, namespace, workload, replicatedJob string) ([]corev1.Pod, error)
WorkloadPods returns a workload's pods from the API server: every pod JobSet labelled with the workload's name, in one replicatedJob when replicatedJob is not empty. Launchers carry no JobLabel, so the cache cannot hold them.