jobs

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 30 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 AddChecksByCheckId added in v0.5.2

func AddChecksByCheckId(addChecks map[string][]any, commandMap map[string]any)

func AddChecksByPlatform added in v0.5.2

func AddChecksByPlatform(addChecks map[string][]any, commandMap map[string]any)

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 AddChecks added in v0.5.2

type AddChecks func(addChecks map[string][]any, commandMap map[string]any)

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 CollectorArgs added in v0.5.2

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

type CollectorOption

type CollectorOption func(*jobCollector)

func WithCollectorTimeout added in v0.5.2

func WithCollectorTimeout(timeout time.Duration) CollectorOption

func WithCommandsPath added in v0.5.2

func WithCommandsPath(commandPaths []string) CollectorOption

func WithContainerResourceRequirements

func WithContainerResourceRequirements(rr corev1.ResourceRequirements) CollectorOption

func WithContainerSecurityContext

func WithContainerSecurityContext(securityContext *corev1.SecurityContext) CollectorOption

func WithEmbeddedCommandFileSystem added in v0.5.2

func WithEmbeddedCommandFileSystem(commandsFileSystem embed.FS) CollectorOption

func WithEmbeddedNodeConfigFilesystem added in v0.5.2

func WithEmbeddedNodeConfigFilesystem(nodeConfigFileSystem embed.FS) CollectorOption

func WithImageRef

func WithImageRef(imageRef string) CollectorOption

func WithJobAffinity added in v0.5.2

func WithJobAffinity(affinity *corev1.Affinity) 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 WithNodeConfig added in v0.5.2

func WithNodeConfig(nodeConfig bool) 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 WithSpecCommands added in v0.5.2

func WithSpecCommands(specCommandIds []string) CollectorOption

func WithTimetout

func WithTimetout(timeout time.Duration) CollectorOption

func WithUseNodeSelector added in v0.5.2

func WithUseNodeSelector(useNodeSelector bool) 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 WithAffinity added in v0.5.2

func WithAffinity(affinity *corev1.Affinity) JobOption

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 WithJobTimeout added in v0.5.2

func WithJobTimeout(timeout time.Duration) JobOption

func WithK8sKubeletConfigMapping added in v0.5.2

func WithK8sKubeletConfigMapping(kubeletConfigMapping string) JobOption

func WithK8sNodeCommands added in v0.5.2

func WithK8sNodeCommands(nodeCommands string) JobOption

func WithK8sNodeConfigData added in v0.5.2

func WithK8sNodeConfigData(nodeConfigData string) JobOption

func WithKubeletConfig added in v0.5.2

func WithKubeletConfig(kubeletConfig 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 WithNodeConfiguration added in v0.5.2

func WithNodeConfiguration(nodeConfig bool) JobOption

func WithNodeName added in v0.5.2

func WithNodeName(nodeName string) JobOption

func WithPodVolumes

func WithPodVolumes(volumes []corev1.Volume) JobOption

func WithPriorityClassName

func WithPriorityClassName(priorityClassName string) JobOption

func WithReplaceResourceReq added in v0.5.2

func WithReplaceResourceReq(replaceResourceReq bool) JobOption

func WithResourceRequirements

func WithResourceRequirements(rr corev1.ResourceRequirements) JobOption

func WithTemplate

func WithTemplate(template string) JobOption

func WithTolerations

func WithTolerations(tolerations []corev1.Toleration) JobOption

func WithUseNodeSelectorParam added in v0.5.2

func WithUseNodeSelectorParam(useNodeSelector bool) 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 NodeCommands added in v0.5.2

type NodeCommands struct {
	Commands []any `yaml:"commands"`
}

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