queue

package
v0.3.0-devel Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BestEffortFIFO = kueue.BestEffortFIFO
View Source
const StrictFIFO = kueue.StrictFIFO

Variables

This section is empty.

Functions

func Key

func Key(q *kueue.LocalQueue) string

Key is the key used to index the queue.

func SetupIndexes

func SetupIndexes(indexer client.FieldIndexer) error

Types

type ClusterQueue

type ClusterQueue interface {
	// Update updates the properties of this ClusterQueue.
	Update(*kueue.ClusterQueue) error
	// Cohort returns the Cohort of this ClusterQueue.
	Cohort() string

	// AddFromQueue pushes all workloads belonging to this queue to
	// the ClusterQueue. If at least one workload is added, returns true.
	// Otherwise returns false.
	AddFromLocalQueue(*LocalQueue) bool
	// DeleteFromQueue removes all workloads belonging to this queue from
	// the ClusterQueue.
	DeleteFromLocalQueue(*LocalQueue)

	// PushOrUpdate pushes the workload to ClusterQueue.
	// If the workload is already present, updates with the new one.
	PushOrUpdate(*workload.Info)
	// Delete removes the workload from ClusterQueue.
	Delete(*kueue.Workload)
	// Pop removes the head of the queue and returns it. It returns nil if the
	// queue is empty.
	Pop() *workload.Info

	// RequeueIfNotPresent inserts a workload that was not
	// admitted back into the ClusterQueue. If the boolean is true,
	// the workloads should be put back in the queue immediately,
	// because we couldn't determine if the workload was admissible
	// in the last cycle. If the boolean is false, the implementation might
	// choose to keep it in temporary placeholder stage where it doesn't
	// compete with other workloads, until cluster events free up quota.
	// The workload should not be reinserted if it's already in the ClusterQueue.
	// Returns true if the workload was inserted.
	RequeueIfNotPresent(*workload.Info, RequeueReason) bool
	// QueueInadmissibleWorkloads moves all workloads put in temporary placeholder stage
	// to the ClusterQueue. If at least one workload is moved,
	// returns true. Otherwise returns false.
	QueueInadmissibleWorkloads(ctx context.Context, client client.Client) bool

	// Pending returns the total number of pending workloads.
	Pending() int

	// PendingActive returns the number of active pending workloads,
	// workloads that are in the admission queue.
	PendingActive() int
	// PendingInadmissible returns the number of inadmissible pending workloads,
	// workloads that were already tried and are waiting for cluster conditions
	// to change to potentially become admissible.
	PendingInadmissible() int

	// Dump produces a dump of the current workloads in the heap of
	// this ClusterQueue. It returns false if the queue is empty.
	// Otherwise returns true.
	Dump() (sets.String, bool)
	DumpInadmissible() (sets.String, bool)
	// Info returns workload.Info for the workload key.
	// Users of this method should not modify the returned object.
	Info(string) *workload.Info
}

ClusterQueue is an interface for a cluster queue to store workloads waiting to be scheduled.

type ClusterQueueBestEffortFIFO

type ClusterQueueBestEffortFIFO struct {
	*ClusterQueueImpl
}

ClusterQueueBestEffortFIFO is the implementation for the ClusterQueue for BestEffortFIFO.

func (*ClusterQueueBestEffortFIFO) RequeueIfNotPresent

func (cq *ClusterQueueBestEffortFIFO) RequeueIfNotPresent(wInfo *workload.Info, reason RequeueReason) bool

type ClusterQueueImpl

type ClusterQueueImpl struct {
	// QueueingStrategy indicates the queueing strategy of the workloads
	// across the queues in this ClusterQueue.
	QueueingStrategy kueue.QueueingStrategy
	// contains filtered or unexported fields
}

ClusterQueueImpl is the base implementation of ClusterQueue interface. It can be inherited and overwritten by other class.

func (*ClusterQueueImpl) AddFromLocalQueue added in v0.2.0

func (c *ClusterQueueImpl) AddFromLocalQueue(q *LocalQueue) bool

func (*ClusterQueueImpl) Cohort

func (c *ClusterQueueImpl) Cohort() string

func (*ClusterQueueImpl) Delete

func (c *ClusterQueueImpl) Delete(w *kueue.Workload)

func (*ClusterQueueImpl) DeleteFromLocalQueue added in v0.2.0

func (c *ClusterQueueImpl) DeleteFromLocalQueue(q *LocalQueue)

func (*ClusterQueueImpl) Dump

func (c *ClusterQueueImpl) Dump() (sets.String, bool)

func (*ClusterQueueImpl) DumpInadmissible added in v0.2.0

func (c *ClusterQueueImpl) DumpInadmissible() (sets.String, bool)

func (*ClusterQueueImpl) Info

func (c *ClusterQueueImpl) Info(key string) *workload.Info

func (*ClusterQueueImpl) Pending

func (c *ClusterQueueImpl) Pending() int

func (*ClusterQueueImpl) PendingActive added in v0.2.0

func (c *ClusterQueueImpl) PendingActive() int

func (*ClusterQueueImpl) PendingInadmissible added in v0.2.0

func (c *ClusterQueueImpl) PendingInadmissible() int

func (*ClusterQueueImpl) Pop

func (c *ClusterQueueImpl) Pop() *workload.Info

func (*ClusterQueueImpl) PushOrUpdate

func (c *ClusterQueueImpl) PushOrUpdate(wInfo *workload.Info)

func (*ClusterQueueImpl) QueueInadmissibleWorkloads

func (c *ClusterQueueImpl) QueueInadmissibleWorkloads(ctx context.Context, client client.Client) bool

QueueInadmissibleWorkloads moves all workloads from inadmissibleWorkloads to heap. If at least one workload is moved, returns true. Otherwise returns false.

func (*ClusterQueueImpl) RequeueIfNotPresent

func (c *ClusterQueueImpl) RequeueIfNotPresent(wInfo *workload.Info, reason RequeueReason) bool

func (*ClusterQueueImpl) Update

func (c *ClusterQueueImpl) Update(apiCQ *kueue.ClusterQueue) error

type ClusterQueueStrictFIFO

type ClusterQueueStrictFIFO struct {
	*ClusterQueueImpl
}

ClusterQueueStrictFIFO is the implementation for the ClusterQueue for StrictFIFO.

type LocalQueue added in v0.2.0

type LocalQueue struct {
	Key          string
	ClusterQueue string
	// contains filtered or unexported fields
}

LocalQueue is the internal implementation of kueue.LocalQueue.

func (*LocalQueue) AddIfNotPresent added in v0.2.0

func (q *LocalQueue) AddIfNotPresent(w *workload.Info) bool

func (*LocalQueue) AddOrUpdate added in v0.2.0

func (q *LocalQueue) AddOrUpdate(info *workload.Info)

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewManager

func NewManager(client client.Client, checker StatusChecker) *Manager

func (*Manager) AddClusterQueue

func (m *Manager) AddClusterQueue(ctx context.Context, cq *kueue.ClusterQueue) error

func (*Manager) AddLocalQueue added in v0.2.0

func (m *Manager) AddLocalQueue(ctx context.Context, q *kueue.LocalQueue) error

func (*Manager) AddOrUpdateWorkload

func (m *Manager) AddOrUpdateWorkload(w *kueue.Workload) bool

AddOrUpdateWorkload adds or updates workload to the corresponding queue. Returns whether the queue existed.

func (*Manager) Broadcast added in v0.2.0

func (m *Manager) Broadcast()

func (*Manager) CleanUpOnContext

func (m *Manager) CleanUpOnContext(ctx context.Context)

CleanUpOnContext tracks the context. When closed, it wakes routines waiting on elements to be available. It should be called before doing any calls to Heads.

func (*Manager) ClusterQueueForWorkload

func (m *Manager) ClusterQueueForWorkload(wl *kueue.Workload) (string, bool)

ClusterQueueForWorkload returns the name of the ClusterQueue where the workload should be queued and whether it exists. Returns empty string if the queue doesn't exist.

func (*Manager) DeleteClusterQueue

func (m *Manager) DeleteClusterQueue(cq *kueue.ClusterQueue)

func (*Manager) DeleteLocalQueue added in v0.2.0

func (m *Manager) DeleteLocalQueue(q *kueue.LocalQueue)

func (*Manager) DeleteWorkload

func (m *Manager) DeleteWorkload(w *kueue.Workload)

func (*Manager) Dump

func (m *Manager) Dump() map[string]sets.String

Dump is a dump of the queues and it's elements (unordered). Only use for testing purposes.

func (*Manager) DumpInadmissible added in v0.2.0

func (m *Manager) DumpInadmissible() map[string]sets.String

DumpInadmissible is a dump of the inadmissible workloads list. Only use for testing purposes.

func (*Manager) Heads

func (m *Manager) Heads(ctx context.Context) []workload.Info

Heads returns the heads of the queues, along with their associated ClusterQueue. It blocks if the queues empty until they have elements or the context terminates.

func (*Manager) Pending

func (m *Manager) Pending(cq *kueue.ClusterQueue) int

func (*Manager) PendingWorkloads

func (m *Manager) PendingWorkloads(q *kueue.LocalQueue) (int32, error)

func (*Manager) QueueAssociatedInadmissibleWorkloads

func (m *Manager) QueueAssociatedInadmissibleWorkloads(ctx context.Context, w *kueue.Workload)

QueueAssociatedInadmissibleWorkloads moves all associated workloads from inadmissibleWorkloads to heap. If at least one workload is moved, returns true. Otherwise returns false.

func (*Manager) QueueForWorkloadExists

func (m *Manager) QueueForWorkloadExists(wl *kueue.Workload) bool

func (*Manager) QueueInadmissibleWorkloads added in v0.2.0

func (m *Manager) QueueInadmissibleWorkloads(ctx context.Context, cqNames sets.String)

QueueInadmissibleWorkloads moves all inadmissibleWorkloads in corresponding ClusterQueues to heap. If at least one workload queued, we will broadcast the event.

func (*Manager) RequeueWorkload

func (m *Manager) RequeueWorkload(ctx context.Context, info *workload.Info, reason RequeueReason) bool

RequeueWorkload requeues the workload ensuring that the queue and the workload still exist in the client cache and it's not admitted. It won't requeue if the workload is already in the queue (possible if the workload was updated).

func (*Manager) UpdateClusterQueue

func (m *Manager) UpdateClusterQueue(ctx context.Context, cq *kueue.ClusterQueue) error

func (*Manager) UpdateLocalQueue added in v0.2.0

func (m *Manager) UpdateLocalQueue(q *kueue.LocalQueue) error

func (*Manager) UpdateWorkload

func (m *Manager) UpdateWorkload(oldW, w *kueue.Workload) bool

UpdateWorkload updates the workload to the corresponding queue or adds it if it didn't exist. Returns whether the queue existed.

type RequeueReason added in v0.2.0

type RequeueReason string
const (
	RequeueReasonFailedAfterNomination RequeueReason = "FailedAfterNomination"
	RequeueReasonNamespaceMismatch     RequeueReason = "NamespaceMismatch"
	RequeueReasonGeneric               RequeueReason = ""
)

type StatusChecker added in v0.2.0

type StatusChecker interface {
	// ClusterQueueActive returns whether the clusterQueue is active.
	ClusterQueueActive(name string) bool
}

StatusChecker checks status of clusterQueue.

Jump to

Keyboard shortcuts

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