Documentation ¶
Overview ¶
Package runner provides an interface to run a Job from a CronJob.
CAVEAT: This package is designed for the internal use of cronjob-runner command. The specification may be changed in the future.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunJob ¶ added in v0.6.0
func RunJob(ctx context.Context, clientset kubernetes.Interface, job *batchv1.Job, opts RunJobOptions) error
RunJob creates the Job and waits for the completion.
It runs a new Job as follows:
- Create a Job.
- Show the statuses of Job, Pod(s) and container(s) when changed.
- Tail the log streams of all containers.
- Wait for the Job to be succeeded or failed.
If the job is succeeded, it returns nil. If the job is failed, it returns JobFailedError. Otherwise, it returns an error. If the context is canceled, it stops gracefully.
func RunJobFromCronJob ¶ added in v0.7.0
func RunJobFromCronJob(ctx context.Context, clientset kubernetes.Interface, namespace, cronJobName string, opts RunCronJobOptions) error
RunJobFromCronJob creates a Job from the existing CronJob, and waits for the completion.
It runs a new Job as follows:
- Create a Job from the CronJob template.
- Run the Job. See RunJob().
If the job is succeeded, it returns nil. If the job is failed, it returns JobFailedError. Otherwise, it returns an error. If the context is canceled, it stops gracefully.
Types ¶
type ContainerLogRecord ¶ added in v0.6.0
ContainerLogRecord represents a record of container logs.
type ContainerLogger ¶ added in v0.6.0
type ContainerLogger interface { // Handle processes a line of container logs. Handle(record ContainerLogRecord) }
ContainerLogger is an interface to handle the container logs.
type JobFailedError ¶
JobFailedError represents an error that the Job has failed.
func (JobFailedError) Error ¶
func (err JobFailedError) Error() string
type RunCronJobOptions ¶ added in v0.6.0
type RunCronJobOptions struct { // Env is a map of environment variables injected to all containers of a Pod. // Optional. Env map[string]string // ContainerLogger is an implementation of ContainerLogger interface. // Default to the defaultContainerLogger. ContainerLogger ContainerLogger }
RunCronJobOptions represents a set of options for RunJobFromCronJob.
type RunJobOptions ¶ added in v0.6.0
type RunJobOptions struct { // ContainerLogger is an implementation of ContainerLogger interface. // Default to the defaultContainerLogger. ContainerLogger ContainerLogger }
RunJobOptions represents a set of options for RunJob.