Documentation ¶
Index ¶
- Constants
- Variables
- func New(logger *zap.Logger, client kubernetes.Interface, cfg Config) *worker
- func NewImagePullBackOffWatcher(logger *zap.Logger, k8s kubernetes.Interface, cfg *config.Config) *imagePullBackOffWatcher
- func NewPodCompletionWatcher(logger *zap.Logger, k8s kubernetes.Interface) *completionsWatcher
- func PatchPodSpec(original *corev1.PodSpec, patch *corev1.PodSpec) (*corev1.PodSpec, error)
- type Config
- type KubernetesPlugin
- type MaxInFlightLimiter
- func (l *MaxInFlightLimiter) Create(ctx context.Context, job *api.CommandJob) error
- func (l *MaxInFlightLimiter) OnAdd(obj any, _ bool)
- func (l *MaxInFlightLimiter) OnDelete(obj any)
- func (l *MaxInFlightLimiter) OnUpdate(_, obj any)
- func (l *MaxInFlightLimiter) RegisterInformer(ctx context.Context, factory informers.SharedInformerFactory) error
- type Metadata
Constants ¶
const ( AgentContainerName = "agent" CopyAgentContainerName = "copy-agent" ImagePullCheckContainerNamePrefix = "imagepullcheck-" CheckoutContainerName = "checkout" )
Variables ¶
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 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
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.