context

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintJobSummary added in v0.11.0

func PrintJobSummary(ctx *armadacontext.Context, prefix string, jctxs []*JobSchedulingContext)

PrintJobSummary logs a summary of the job scheduling context It will log a high level summary at Info level, and a list of all queues + jobs affected at debug level

Types

type GangInfo added in v0.4.11

type GangInfo struct {
	Id                string
	Cardinality       int
	PriorityClassName string
	NodeUniformity    string
}

func EmptyGangInfo added in v0.4.11

func EmptyGangInfo(job interfaces.MinimalJob) GangInfo

EmptyGangInfo returns a GangInfo for a job that is not in a gang.

func GangInfoFromLegacySchedulerJob added in v0.4.11

func GangInfoFromLegacySchedulerJob(job interfaces.MinimalJob) (GangInfo, error)

type GangSchedulingContext

type GangSchedulingContext struct {
	Created time.Time
	Queue   string
	GangInfo
	JobSchedulingContexts     []*JobSchedulingContext
	TotalResourceRequests     schedulerobjects.ResourceList
	AllJobsEvicted            bool
	RequestsFloatingResources bool
}

func NewGangSchedulingContext

func NewGangSchedulingContext(jctxs []*JobSchedulingContext) *GangSchedulingContext

func (*GangSchedulingContext) Cardinality added in v0.3.92

func (gctx *GangSchedulingContext) Cardinality() int

Cardinality returns the number of jobs in the gang.

func (*GangSchedulingContext) Fit added in v0.4.2

func (*GangSchedulingContext) JobIds added in v0.4.27

func (gctx *GangSchedulingContext) JobIds() []string

JobIds returns a sliced composed of the ids of the jobs that make up the gang.

type GangSchedulingFit added in v0.4.2

type GangSchedulingFit struct {
	// The number of jobs in the gang that were successfully scheduled.
	NumScheduled int
	// The mean PreemptedAtPriority among successfully scheduled pods in the gang.
	MeanPreemptedAtPriority float64
}

func (GangSchedulingFit) Less added in v0.4.2

type JobSchedulingContext

type JobSchedulingContext struct {
	// Time at which this context was created.
	Created time.Time
	// Id of the job this pod corresponds to.
	JobId string
	// Indicates whether this context is for re-scheduling an evicted job.
	IsEvicted bool
	// Job spec.
	Job *jobdb.Job
	// Scheduling requirements of this job.
	// We currently require that each job contains exactly one pod spec.
	PodRequirements *schedulerobjects.PodRequirements
	// Resource requirements in an efficient internaltypes.ResourceList
	ResourceRequirements internaltypes.ResourceList
	// Node selectors to consider in addition to those included with the PodRequirements.
	// These are added as part of scheduling to further constrain where nodes are scheduled,
	// e.g., to ensure evicted jobs are re-scheduled onto the same node.
	//
	// If some key appears in both PodRequirements.NodeSelector and AdditionalNodeSelectors,
	// the value in AdditionalNodeSelectors trumps that of PodRequirements.NodeSelector.
	AdditionalNodeSelectors map[string]string
	// Tolerations to consider in addition to those included with the PodRequirements.
	// These are added as part of scheduling to expand the set of nodes a job can be scheduled on.
	AdditionalTolerations []v1.Toleration
	// Reason for why the job could not be scheduled.
	// Empty if the job was scheduled successfully.
	UnschedulableReason string
	// Pod scheduling contexts for the individual pods that make up the job.
	PodSchedulingContext *PodSchedulingContext
	// GangInfo holds all the information that is necessary to schedule a gang,
	// such as the lower and upper bounds on its size.
	GangInfo
	// This is the node the pod is assigned to.
	// This is only set for evicted jobs and is set alongside adding an additionalNodeSelector for the node
	AssignedNodeId string
}

JobSchedulingContext is created by the scheduler and contains information about the decision made by the scheduler for a particular job.

func JobSchedulingContextFromJob added in v0.4.1

func JobSchedulingContextFromJob(job *jobdb.Job) *JobSchedulingContext

func JobSchedulingContextsFromJobs added in v0.3.78

func JobSchedulingContextsFromJobs[J *jobdb.Job](jobs []J) []*JobSchedulingContext

func (*JobSchedulingContext) AddNodeSelector added in v0.4.1

func (jctx *JobSchedulingContext) AddNodeSelector(key, value string)

func (*JobSchedulingContext) Fail added in v0.4.2

func (jctx *JobSchedulingContext) Fail(unschedulableReason string)

func (*JobSchedulingContext) GetAssignedNodeId added in v0.8.3

func (jctx *JobSchedulingContext) GetAssignedNodeId() string

func (*JobSchedulingContext) IsSuccessful

func (jctx *JobSchedulingContext) IsSuccessful() bool

func (*JobSchedulingContext) SchedulingKey added in v0.4.1

func (jctx *JobSchedulingContext) SchedulingKey() (schedulerobjects.SchedulingKey, bool)

SchedulingKey returns the scheduling key of the embedded job. If the jctx contains additional node selectors or tolerations, the key is invalid and the second return value is false.

func (*JobSchedulingContext) SetAssignedNodeId added in v0.8.3

func (jctx *JobSchedulingContext) SetAssignedNodeId(assignedNodeId string)

func (*JobSchedulingContext) String

func (jctx *JobSchedulingContext) String() string

type PodSchedulingContext

type PodSchedulingContext struct {
	// Time at which this context was created.
	Created time.Time
	// ID of the node that the pod was assigned to, or empty.
	NodeId string
	// If set, indicates that the pod was scheduled on a specific node type.
	WellKnownNodeTypeName string
	// Priority this pod was most recently attempted to be scheduled at.
	// If scheduling was successful, resources were marked as allocated to the job at this priority.
	ScheduledAtPriority int32
	// Maximum priority that this pod preempted other pods at.
	PreemptedAtPriority int32
	// Total number of nodes in the cluster when trying to schedule.
	NumNodes int
	// Number of nodes excluded by reason.
	NumExcludedNodesByReason map[string]int
}

PodSchedulingContext is returned by SelectAndBindNodeToPod and contains detailed information on the scheduling decision made for this pod.

func (*PodSchedulingContext) IsSuccessful added in v0.4.2

func (pctx *PodSchedulingContext) IsSuccessful() bool

func (*PodSchedulingContext) String

func (pctx *PodSchedulingContext) String() string

type QueueSchedulingContext

type QueueSchedulingContext struct {
	// The scheduling context to which this QueueSchedulingContext belongs.
	SchedulingContext *SchedulingContext
	// Time at which this context was created.
	Created time.Time
	// Queue name.
	Queue string
	// Determines the fair share of this queue relative to other queues.
	Weight float64
	// Limits job scheduling rate for this queue.
	// Use the "Started" time to ensure limiter state remains constant within each scheduling round.
	Limiter *rate.Limiter
	// Total resources assigned to the queue across all clusters by priority class priority.
	// Includes jobs scheduled during this invocation of the scheduler.
	Allocated schedulerobjects.ResourceList
	// Total demand from this queue.  This is essentially the cumulative resources of all non-terminal jobs at the
	// start of the scheduling cycle
	Demand schedulerobjects.ResourceList
	// Capped Demand for this queue. This differs from Demand in that it takes into account any limits that we have
	// placed on the queue
	CappedDemand schedulerobjects.ResourceList
	// Fair share is the weight of this queue over the sum of the weights of all queues
	FairShare float64
	// AdjustedFairShare modifies fair share such that queues that have a demand cost less than their fair share, have their fair share reallocated.
	AdjustedFairShare float64
	// Total resources assigned to the queue across all clusters by priority class.
	// Includes jobs scheduled during this invocation of the scheduler.
	AllocatedByPriorityClass schedulerobjects.QuantityByTAndResourceType[string]
	// Resources assigned to this queue during this scheduling cycle.
	ScheduledResourcesByPriorityClass schedulerobjects.QuantityByTAndResourceType[string]
	// Resources evicted from this queue during this scheduling cycle.
	EvictedResourcesByPriorityClass schedulerobjects.QuantityByTAndResourceType[string]
	// Job scheduling contexts associated with successful scheduling attempts.
	SuccessfulJobSchedulingContexts map[string]*JobSchedulingContext
	// Job scheduling contexts associated with unsuccessful scheduling attempts.
	UnsuccessfulJobSchedulingContexts map[string]*JobSchedulingContext
	// Jobs evicted in this round.
	EvictedJobsById map[string]bool
}

QueueSchedulingContext captures the decisions made by the scheduler during one invocation for a particular queue.

func (*QueueSchedulingContext) ClearJobSpecs

func (qctx *QueueSchedulingContext) ClearJobSpecs()

ClearJobSpecs zeroes out job specs to reduce memory usage.

func (*QueueSchedulingContext) GetAllocation added in v0.3.90

GetAllocation is necessary to implement the fairness.Queue interface.

func (*QueueSchedulingContext) GetWeight added in v0.3.90

func (qctx *QueueSchedulingContext) GetWeight() float64

GetWeight is necessary to implement the fairness.Queue interface.

func (*QueueSchedulingContext) ReportString added in v0.3.71

func (qctx *QueueSchedulingContext) ReportString(verbosity int32) string

func (*QueueSchedulingContext) String

func (qctx *QueueSchedulingContext) String() string

type SchedulingContext

type SchedulingContext struct {
	// Time at which the scheduling cycle started.
	Started time.Time
	// Time at which the scheduling cycle finished.
	Finished time.Time
	// Pool for which we're currently scheduling jobs.
	Pool string
	// Determines how fairness is computed.
	FairnessCostProvider fairness.FairnessCostProvider
	// Limits job scheduling rate globally across all queues.
	// Use the "Started" time to ensure limiter state remains constant within each scheduling round.
	Limiter *rate.Limiter
	// Sum of queue weights across all queues.
	WeightSum float64
	// Per-queue scheduling contexts.
	QueueSchedulingContexts map[string]*QueueSchedulingContext
	// Total resources across all clusters in this pool available at the start of the scheduling cycle.
	TotalResources schedulerobjects.ResourceList
	// Allocated resources across all clusters in this pool
	Allocated schedulerobjects.ResourceList
	// Resources assigned across all queues during this scheduling cycle.
	ScheduledResources                schedulerobjects.ResourceList
	ScheduledResourcesByPriorityClass schedulerobjects.QuantityByTAndResourceType[string]
	// Resources evicted across all queues during this scheduling cycle.
	EvictedResources                schedulerobjects.ResourceList
	EvictedResourcesByPriorityClass schedulerobjects.QuantityByTAndResourceType[string]
	// Total number of successfully scheduled jobs.
	NumScheduledJobs int
	// Total number of successfully scheduled gangs.
	NumScheduledGangs int
	// Total number of evicted jobs.
	NumEvictedJobs int
	// TODO(reports): Count the number of evicted gangs.
	// Reason for why the scheduling round finished.
	TerminationReason string
	// Used to efficiently generate scheduling keys.
	SchedulingKeyGenerator *schedulerobjects.SchedulingKeyGenerator
	// Record of job scheduling requirements known to be unfeasible.
	// Used to immediately reject new jobs with identical reqirements.
	// Maps to the JobSchedulingContext of a previous job attempted to schedule with the same key.
	UnfeasibleSchedulingKeys map[schedulerobjects.SchedulingKey]*JobSchedulingContext
}

SchedulingContext contains information necessary for scheduling and records what happened in a scheduling round.

func NewSchedulingContext

func NewSchedulingContext(
	pool string,
	fairnessCostProvider fairness.FairnessCostProvider,
	limiter *rate.Limiter,
	totalResources schedulerobjects.ResourceList,
) *SchedulingContext

func (*SchedulingContext) AddGangSchedulingContext

func (sctx *SchedulingContext) AddGangSchedulingContext(gctx *GangSchedulingContext) (bool, error)

func (*SchedulingContext) AddJobSchedulingContext

func (sctx *SchedulingContext) AddJobSchedulingContext(jctx *JobSchedulingContext) (bool, error)

AddJobSchedulingContext adds a job scheduling context. Automatically updates scheduled resources.

func (*SchedulingContext) AddQueueSchedulingContext added in v0.3.68

func (sctx *SchedulingContext) AddQueueSchedulingContext(
	queue string, weight float64,
	initialAllocatedByPriorityClass schedulerobjects.QuantityByTAndResourceType[string],
	demand schedulerobjects.ResourceList,
	cappedDemand schedulerobjects.ResourceList,
	limiter *rate.Limiter,
) error

func (*SchedulingContext) AllocatedByQueueAndPriority

func (sctx *SchedulingContext) AllocatedByQueueAndPriority() map[string]schedulerobjects.QuantityByTAndResourceType[string]

AllocatedByQueueAndPriority returns map from queue name and priority to resources allocated.

func (*SchedulingContext) ClearJobSpecs

func (sctx *SchedulingContext) ClearJobSpecs()

ClearJobSpecs zeroes out job specs to reduce memory usage.

func (*SchedulingContext) ClearUnfeasibleSchedulingKeys added in v0.3.68

func (sctx *SchedulingContext) ClearUnfeasibleSchedulingKeys()

func (*SchedulingContext) EvictGang

func (sctx *SchedulingContext) EvictGang(jobs []*jobdb.Job) (bool, error)

func (*SchedulingContext) EvictJob

func (sctx *SchedulingContext) EvictJob(job *jobdb.Job) (bool, error)

func (*SchedulingContext) FairnessError added in v0.11.0

func (sctx *SchedulingContext) FairnessError() float64

FairnessError returns the cumulative delta between adjusted fair share and actual share for all users who are below their fair share

func (*SchedulingContext) GetQueue added in v0.3.90

func (sctx *SchedulingContext) GetQueue(queue string) (fairness.Queue, bool)

GetQueue is necessary to implement the fairness.QueueRepository interface.

func (*SchedulingContext) ReportString added in v0.3.71

func (sctx *SchedulingContext) ReportString(verbosity int32) string

func (*SchedulingContext) String

func (sctx *SchedulingContext) String() string

func (*SchedulingContext) SuccessfulJobSchedulingContexts

func (sctx *SchedulingContext) SuccessfulJobSchedulingContexts() []*JobSchedulingContext

func (*SchedulingContext) UpdateFairShares added in v0.8.3

func (sctx *SchedulingContext) UpdateFairShares()

UpdateFairShares updates FairShare and AdjustedFairShare for every QueueSchedulingContext associated with the SchedulingContext. This works by calculating a far share as queue_weight/sum_of_all_queue_weights and an AdjustedFairShare by resharing any unused capacity (as determined by a queue's demand)

Jump to

Keyboard shortcuts

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