scheduler

package
v2.0.0-...-04e5d85 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentContainerName = "agent"
)

Variables

View Source
var ErrNoCommandModification = errors.New("modifying container commands or args via podSpecPatch is not supported. Specify the command in the job's command field instead")

Functions

func New

func New(logger *zap.Logger, client kubernetes.Interface, cfg Config) *worker

func NewImagePullBackOffWatcher

func NewImagePullBackOffWatcher(
	logger *zap.Logger,
	k8s kubernetes.Interface,
	cfg *config.Config,
) *imagePullBackOffWatcher

NewImagePullBackOffWatcher creates an informer that will use the Buildkite GraphQL API to cancel jobs that have pods with containers in the ImagePullBackOff state

func NewJobWrapper

func NewJobWrapper(logger *zap.Logger, job *api.CommandJob, config Config) *jobWrapper

func NewPodCompletionWatcher

func NewPodCompletionWatcher(logger *zap.Logger, k8s kubernetes.Interface) *completionsWatcher

func PatchPodSpec

func PatchPodSpec(original *corev1.PodSpec, patch *corev1.PodSpec) (*corev1.PodSpec, error)

Types

type Checkout

type Checkout struct {
	Skip       bool   `json:"skip,omitempty"`
	CloneFlags string `json:"cloneFlags,omitempty"`
	FetchFlags string `json:"fetchFlags,omitempty"`
}

type Config

type Config struct {
	Namespace              string
	Image                  string
	AgentToken             string
	JobTTL                 time.Duration
	AdditionalRedactedVars []string
	PodSpecPatch           *corev1.PodSpec
}

type KubernetesPlugin

type KubernetesPlugin struct {
	PodSpec           *corev1.PodSpec        `json:"podSpec,omitempty"`
	PodSpecPatch      *corev1.PodSpec        `json:"podSpecPatch,omitempty"`
	GitEnvFrom        []corev1.EnvFromSource `json:"gitEnvFrom,omitempty"`
	Sidecars          []corev1.Container     `json:"sidecars,omitempty"`
	Metadata          Metadata               `json:"metadata,omitempty"`
	ExtraVolumeMounts []corev1.VolumeMount   `json:"extraVolumeMounts,omitempty"`
	Checkout          Checkout               `json:"checkout,omitempty"`
}

type MaxInFlightLimiter

type MaxInFlightLimiter struct {
	MaxInFlight int
	// contains filtered or unexported fields
}

func NewLimiter

func NewLimiter(
	logger *zap.Logger,
	scheduler monitor.JobHandler,
	maxInFlight int,
) *MaxInFlightLimiter

func (*MaxInFlightLimiter) Create

func (l *MaxInFlightLimiter) Create(ctx context.Context, job *api.CommandJob) error

func (*MaxInFlightLimiter) InFlight

func (l *MaxInFlightLimiter) InFlight() int

func (*MaxInFlightLimiter) OnAdd

func (l *MaxInFlightLimiter) OnAdd(obj interface{}, isInInitialList bool)

load jobs at controller startup/restart

func (*MaxInFlightLimiter) OnDelete

func (l *MaxInFlightLimiter) OnDelete(obj interface{})

if jobs are deleted before they complete, ensure we remove them from inFlight

func (*MaxInFlightLimiter) OnUpdate

func (l *MaxInFlightLimiter) OnUpdate(_, obj interface{})

if a job is still running, add it to inFlight, otherwise try to remove it

func (*MaxInFlightLimiter) RegisterInformer

func (l *MaxInFlightLimiter) RegisterInformer(
	ctx context.Context,
	factory informers.SharedInformerFactory,
) error

Creates a Jobs informer, registers the handler on it, and waits for cache sync

type Metadata

type Metadata struct {
	Annotations map[string]string
	Labels      map[string]string
}

Jump to

Keyboard shortcuts

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