jobs

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeCollectorName = "node-collector"

	// job headers
	TunnelCollectorName = "tunnel.collector.name"
	TunnelAutoCreated   = "tunnel.automatic.created"
	TunnelResourceName  = "tunnel.resource.name"
	TunnelResourceKind  = "tunnel.resource.kind"
)

Variables

View Source
var ErrTimeout = errors.New("runner received timeout")

ErrTimeout is returned when Runner's Run method fails due to a timeout event.

Functions

func ComputeHash

func ComputeHash(obj interface{}) string

ComputeHash returns a hash value calculated from a given object. The hash will be safe encoded to avoid bad words.

func GetActiveDeadlineSeconds

func GetActiveDeadlineSeconds(d time.Duration) *int64

func GetJob

func GetJob(opts ...JobOption) (*batchv1.Job, error)

func GetTerminatedContainersStatusesByPod

func GetTerminatedContainersStatusesByPod(pod *corev1.Pod) map[string]*corev1.ContainerStateTerminated

GetTerminatedContainersStatusesByPod collect information about contianer status by pod

func IsPodControlledByJobNotFound

func IsPodControlledByJobNotFound(err error) bool

Types

type Collector

type Collector interface {
	ApplyAndCollect(ctx context.Context, nodeName string) (string, error)
	Apply(ctx context.Context, nodeName string) (*batchv1.Job, error)
	AppendLabels(opts ...CollectorOption)
	Cleanup(ctx context.Context)
}

func NewCollector

func NewCollector(
	cluster k8s.Cluster,
	opts ...CollectorOption,
) Collector

type CollectorOption

type CollectorOption func(*jobCollector)

func WithContainerResourceRequirements

func WithContainerResourceRequirements(rr *corev1.ResourceRequirements) CollectorOption

func WithContainerSecurityContext

func WithContainerSecurityContext(securityContext *corev1.SecurityContext) CollectorOption

func WithImageRef

func WithImageRef(imageRef string) CollectorOption

func WithJobAnnotation

func WithJobAnnotation(annotation map[string]string) CollectorOption

func WithJobLabels

func WithJobLabels(labels map[string]string) CollectorOption

func WithJobNamespace

func WithJobNamespace(namespace string) CollectorOption

func WithJobTemplateName

func WithJobTemplateName(name string) CollectorOption

func WithJobTolerations

func WithJobTolerations(tolerations []corev1.Toleration) CollectorOption

func WithName

func WithName(name string) CollectorOption

func WithPodImagePullSecrets

func WithPodImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) CollectorOption

func WithPodPriorityClassName

func WithPodPriorityClassName(priorityClassName string) CollectorOption

func WithPodSpecSecurityContext

func WithPodSpecSecurityContext(podSecurityContext *corev1.PodSecurityContext) CollectorOption

func WithServiceAccount

func WithServiceAccount(sa string) CollectorOption

func WithTimetout

func WithTimetout(timeout time.Duration) CollectorOption

func WithVolumes

func WithVolumes(volumes []corev1.Volume) CollectorOption

func WithVolumesMount

func WithVolumesMount(volumesMount []corev1.VolumeMount) CollectorOption

type JobBuilder

type JobBuilder struct {
	// contains filtered or unexported fields
}

type JobOption

type JobOption func(*JobBuilder)

func WithAnnotation

func WithAnnotation(annotations map[string]string) JobOption

func WithContainerVolumeMounts

func WithContainerVolumeMounts(volumeMounts []corev1.VolumeMount) JobOption

func WithImagePullSecrets

func WithImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) JobOption

func WithJobName

func WithJobName(name string) JobOption

func WithJobServiceAccount

func WithJobServiceAccount(sa string) JobOption

func WithLabels

func WithLabels(labels map[string]string) JobOption

func WithNamespace

func WithNamespace(namespace string) JobOption

func WithNodeCollectorImageRef

func WithNodeCollectorImageRef(imageRef string) JobOption

func WithNodeSelector

func WithNodeSelector(nodeSelector string) JobOption

func WithPodVolumes

func WithPodVolumes(volumes []corev1.Volume) JobOption

func WithPriorityClassName

func WithPriorityClassName(priorityClassName string) JobOption

func WithResourceRequirements

func WithResourceRequirements(rr *corev1.ResourceRequirements) JobOption

func WithTemplate

func WithTemplate(template string) JobOption

func WithTolerations

func WithTolerations(tolerations []corev1.Toleration) JobOption

type LogsReader

type LogsReader interface {
	GetLogsByJobAndContainerName(ctx context.Context, job *batchv1.Job, containerName string) (io.ReadCloser, error)
	GetTerminatedContainersStatusesByJob(ctx context.Context, job *batchv1.Job) (map[string]*corev1.ContainerStateTerminated, error)
}

LogsReader responsible for collecting container status and logs

func NewLogsReader

func NewLogsReader(clientset kubernetes.Interface) LogsReader

NewLogsReader instansiate new log reader

type ObjectRef

type ObjectRef struct {
	Kind      string
	Name      string
	Namespace string
}

type Runnable

type Runnable interface {
	Run(ctx context.Context) error
}

Runnable is the interface that wraps the basic Run method.

Run should be implemented by any task intended to be executed by the Runner.

func NewRunnableJob

func NewRunnableJob(
	clientset kubernetes.Interface,
	job *batchv1.Job,
) Runnable

NewRunnableJob constructs a new Runnable task defined as Kubernetes

type RunnableFunc

type RunnableFunc func(ctx context.Context) error

The RunnableFunc type is an adapter to allow the use of ordinary functions as Runnable tasks. If f is a function with the appropriate signature, RunnableFunc(f) is a Runnable that calls f.

func (RunnableFunc) Run

func (f RunnableFunc) Run(ctx context.Context) error

Run calls f()

type Runner

type Runner interface {
	Run(ctx context.Context, task Runnable) error
}

Runner is the interface that wraps the basic Run method.

Run executes submitted Runnable tasks.

func New

func New(opts ...RunnerOption) Runner

New constructs a new ready-to-use Runner for running a Runnable task.

type RunnerOption

type RunnerOption func(*runner)

func WithTimeout

func WithTimeout(timeout time.Duration) RunnerOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL