worker

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoUnleasedPods = errors.New("no unleased pods found")
)

Functions

This section is empty.

Types

type AutoscalingPool added in v0.1.17

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

func NewPool

func NewPool(
	ctx context.Context,
	clientset kubernetes.Interface,
	conf config.Buildkit,
	opts ...PoolOption,
) *AutoscalingPool

NewPool creates a new worker pool that can be used to lease buildkit workers for image builds.

func (*AutoscalingPool) Close added in v0.1.17

func (p *AutoscalingPool) Close()

Close shuts down the pool by terminating all background routines used to manage requests and garbage collection.

func (*AutoscalingPool) Get added in v0.1.17

func (p *AutoscalingPool) Get(ctx context.Context, owner string) (string, error)

Get a lease for a worker in the pool and return a routable address.

Adds "lease"/"manager-identity" metadata and removes "expiry-time". The worker will remain leased until the caller provides the address to Release().

func (*AutoscalingPool) Release added in v0.1.17

func (p *AutoscalingPool) Release(ctx context.Context, addr string) error

Release an address back into the worker pool.

Adds "expiry-time" and removes "lease"/"manager-identity" metadata. The underlying worker will be terminated after its expiry time has passed.

type BuilderState added in v0.1.24

type BuilderState int

BuilderState is an observed buildkit pod state.

const (
	// BuilderStateUnmanaged indicates a pod's manager ID is not current.
	BuilderStateUnmanaged BuilderState = iota
	// BuilderStateLeased indicates a pod has been leased for building.
	BuilderStateLeased
	// BuilderStatePending indicates a pod is not fully-operational.
	BuilderStatePending
	// BuilderStatePendingExpired indicates a pod has been in a pending state longer than its expiry.
	BuilderStatePendingExpired
	// BuilderStateStarting indicates a pod is running but not ready for work.
	BuilderStateStarting
	// BuilderStateStartingExpired indicates a pod has been in a starting state longer than its expiry.
	BuilderStateStartingExpired
	// BuilderStateOperational indicates a pod is ready to build.
	BuilderStateOperational
	// BuilderStateOperationalExpired indicates an operational pod's TTL has expired.
	BuilderStateOperationalExpired
	// BuilderStateOperationalInvalidExpiry indicates an operational pod has bad expiry data in its annotations.
	BuilderStateOperationalInvalidExpiry
	// BuilderStateUnusable indicates a pod has an unknown phase or set of conditions.
	BuilderStateUnusable
)

func (BuilderState) String added in v0.1.24

func (bs BuilderState) String() string

String representation of the builder state.

type Options

type Options struct {
	Log                         logr.Logger
	MaxIdleTime                 time.Duration
	SyncWaitTime                time.Duration
	EndpointWatchTimeoutSeconds int64
}

type PodObservation added in v0.1.24

type PodObservation struct {
	Pod   corev1.Pod
	State BuilderState
}

PodObservation records the builder state for a single pod.

func (*PodObservation) MarkLeased added in v0.1.24

func (m *PodObservation) MarkLeased()

MarkLeased should be invoked whenever the caller leases a pod that has been previously evaluated.

func (*PodObservation) String added in v0.1.24

func (m *PodObservation) String() string

String renders the name and state of the observed pod.

type PodRequest added in v0.1.4

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

type PodRequestResult

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

type Pool

type Pool interface {
	Get(ctx context.Context, owner string) (workerAddr string, err error)
	Release(ctx context.Context, workerAddr string) error
	Close()
}

type PoolOption

type PoolOption func(o Options) Options

func EndpointWatchTimeoutSeconds added in v0.1.16

func EndpointWatchTimeoutSeconds(s int64) PoolOption

func Logger

func Logger(log logr.Logger) PoolOption

func MaxIdleTime

func MaxIdleTime(d time.Duration) PoolOption

func SyncWaitTime

func SyncWaitTime(d time.Duration) PoolOption

type Queue added in v0.1.14

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

func NewRequestQueue

func NewRequestQueue() *Queue

func (*Queue) Dequeue added in v0.1.14

func (q *Queue) Dequeue() *PodRequest

func (*Queue) Enqueue added in v0.1.14

func (q *Queue) Enqueue(req *PodRequest)

func (*Queue) Len added in v0.1.14

func (q *Queue) Len() int

func (*Queue) Remove added in v0.1.14

func (q *Queue) Remove(req *PodRequest) bool

type RequestQueue

type RequestQueue interface {
	Enqueue(*PodRequest)
	Dequeue() *PodRequest
	Len() int
	Remove(*PodRequest) bool
}

type ScaleArbiter added in v0.1.24

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

ScaleArbiter can be used to determine the proper number of replicas for a buildkit statefulset based on the number of build requests and existing pods.

func NewScaleArbiter added in v0.1.24

func NewScaleArbiter(log logr.Logger, podClient corev1typed.PodInterface, podExpiry time.Duration) *ScaleArbiter

NewScaleArbiter initializes

func (*ScaleArbiter) DetermineReplicas added in v0.1.24

func (a *ScaleArbiter) DetermineReplicas(requests int) int

DetermineReplicas calculates the number of buildkit replicas required to service the incoming requests.

func (*ScaleArbiter) EvaluatePod added in v0.1.24

func (a *ScaleArbiter) EvaluatePod(ctx context.Context, uuid string, pod corev1.Pod)

EvaluatePod builder state and store the observation for use when determining the scale replicas.

func (*ScaleArbiter) LeasablePods added in v0.1.24

func (a *ScaleArbiter) LeasablePods() (observations []*PodObservation)

LeasablePods returns a list of pods that are ready to build images.

Jump to

Keyboard shortcuts

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