scheduler

package
v2.0.0-...-ccc99ed Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentContainerName                = "agent"
	CopyAgentContainerName            = "copy-agent"
	ImagePullCheckContainerNamePrefix = "imagepullcheck-"
	CheckoutContainerName             = "checkout"
)

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 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 Config

type Config struct {
	Namespace              string
	Image                  string
	AgentTokenSecretName   string
	JobTTL                 time.Duration
	AdditionalRedactedVars []string
	DefaultCheckoutParams  *config.CheckoutParams
	DefaultCommandParams   *config.CommandParams
	DefaultSidecarParams   *config.SidecarParams
	PodSpecPatch           *corev1.PodSpec
	ProhibitK8sPlugin      bool
}

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"`
	CheckoutParams    *config.CheckoutParams `json:"checkout,omitempty"`
	CommandParams     *config.CommandParams  `json:"commandParams,omitempty"`
	SidecarParams     *config.SidecarParams  `json:"sidecarParams,omitempty"`
}

type MaxInFlightLimiter

type MaxInFlightLimiter struct {
	// MaxInFlight sets the upper limit on number of jobs running concurrently
	// in the cluster. 0 means no limit.
	MaxInFlight int
	// contains filtered or unexported fields
}

MaxInFlightLimiter is a job handler that wraps another job handler (typically the actual job scheduler) and only creates new jobs if the total number of jobs currently running is below a limit.

func NewLimiter

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

NewLimiter creates a MaxInFlightLimiter.

func (*MaxInFlightLimiter) Create

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

Create either creates the job immediately, or blocks until there is capacity. It may also ignore the job if it is already in flight.

func (*MaxInFlightLimiter) OnAdd

func (l *MaxInFlightLimiter) OnAdd(obj any, _ bool)

OnAdd is called by k8s to inform us a resource is added.

func (*MaxInFlightLimiter) OnDelete

func (l *MaxInFlightLimiter) OnDelete(obj any)

OnDelete is called by k8s to inform us a resource is deleted.

func (*MaxInFlightLimiter) OnUpdate

func (l *MaxInFlightLimiter) OnUpdate(_, obj any)

OnUpdate is called by k8s to inform us a resource is updated.

func (*MaxInFlightLimiter) RegisterInformer

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

RegisterInformer registers the limiter to listen for Kubernetes job events, 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