get_logs_for_job
Returns logs from a Kubernetes Job's most recently created pod, locating it by job-name label to skip manual pod listing and sorting.
Instructions
Retrieves logs from the most-recently-created pod of a Job.
Job pods are short-lived, so this convenience finds the newest pod belonging to
the Job (via its `job-name` label) and returns its logs, saving the caller from
listing pods and sorting by creation time.
Parameters
----------
job_name : str
Name of the Job.
namespace : str, optional
Namespace of the Job (default is "default").
container_name : str, optional
Container within the pod. If None, defaults to the first container.
tail : int, optional
Number of lines from the end of the log (default: last 1000).
since_seconds : int, optional
If set, only return logs newer than this many seconds.
previous : bool, default False
If True, return logs from the previous terminated container instance.
See `get_logs_for_pod_and_container` for the cases - CrashLoopBackOff, a
restart racing the call, a reclaimed log file - where that legitimately
returns the same text as `previous=False`, or a 200 whose body is an
error message.
Returns
-------
str, optional
Log content, or None if the Job has no pods.
Raises
------
K8sConfigError
If unable to initialize the K8S API.
K8sApiError
If the API call fails.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tail | No | ||
| job_name | Yes | ||
| previous | No | ||
| namespace | No | default | |
| since_seconds | No | ||
| container_name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |