Documentation
¶
Index ¶
- Constants
- Variables
- func AsGenerateError(id string, correlationID string, err error) error
- type ActivityStatus
- type App
- type ClusterSnapshot
- type GetNodeScoreSelector
- type GetNodeScorer
- type GetProviderInstancePricingAccessFunc
- type GetWeightsFunc
- type InstancePriceInfo
- type InstancePricingAccess
- type NodeInfo
- type NodePodAssignment
- type NodeResourceInfo
- type NodeScore
- type NodeScoreSelector
- type NodeScorer
- type NodeScorerArgs
- type PodInfo
- type PodResourceInfo
- type PriceKey
- type ResourceMeta
- type ScalingAdviceRequest
- type ScalingAdviceRequestRef
- type ScalingAdviceResponse
- type ScalingAdviceResponseFn
- type ScalingAdviceResult
- type ScalingAdvisorService
- type ScalingAdvisorServiceConfig
- type SchedulerHandle
- type SchedulerLaunchParams
- type SchedulerLauncher
- type SimGroupKey
- type SimGroupRunResult
- type SimGroupScores
- type SimRunResult
- type Simulation
- type SimulationArgs
- type SimulationCreator
- type SimulationCreatorFunc
- type SimulationGroup
- type SimulationGrouper
- type SimulationGrouperFunc
Constants ¶
const (
// ProgramName is the program name for the scaling advisor service.
ProgramName = "scadsvc"
)
Variables ¶
var ( // ErrInitFailed is a sentinel error indicating that the scaling-advisor service failed to initialize. ErrInitFailed = fmt.Errorf(commonerrors.FmtInitFailed, ProgramName) // ErrStartFailed is a sentinel error indicating that the scaling-advisor service failed to start. ErrStartFailed = fmt.Errorf(commonerrors.FmtStartFailed, ProgramName) // ErrGenScalingAdvice is a sentinel error indicating that the service failed to generate scaling advice. ErrGenScalingAdvice = errors.New("failed to generate scaling advice") // ErrCreateSimulation is a sentinel error indicating that the service failed to create a scaling simulation ErrCreateSimulation = errors.New("failed to create simulation") // ErrRunSimulation is a sentinel error indicating that a specific scaling simulation failed ErrRunSimulation = errors.New("failed to run simulation") // ErrRunSimulationGroup is a sentinel error indicating that a scaling simulation group failed ErrRunSimulationGroup = errors.New("failed to run simulation group") // ErrSimulationTimeout is a sentinel error indicating that the simulation timed out ErrSimulationTimeout = errors.New("simulation timed out") // ErrComputeNodeScore is a sentinel error indicating that the NodeScorer failed to compute a score ErrComputeNodeScore = errors.New("failed to compute node score") // ErrNoWinningNodeScore is a sentinel error indicating that there is no winning NodeScore ErrNoWinningNodeScore = errors.New("no winning node score") // ErrSelectNodeScore is a sentinel error indicating that the NodeScoreSelector failed to select a score ErrSelectNodeScore = errors.New("failed to select node score") // ErrParseSchedulerConfig is a sentinel error indicating that the service failed to parse the scheduler configuration. ErrParseSchedulerConfig = errors.New("failed to parse scheduler configuration") // ErrLoadSchedulerConfig is a sentinel error indicating that the service failed to load the scheduler configuration. ErrLoadSchedulerConfig = errors.New("failed to load scheduler configuration") // ErrLaunchScheduler is a sentinel error indicating that the service failed to launch the scheduler. ErrLaunchScheduler = errors.New("failed to launch scheduler") // ErrNoUnscheduledPods is a sentinel error indicating that the service was wrongly invoked with no unscheduled pods. ErrNoUnscheduledPods = errors.New("no unscheduled pods") // ErrNoScalingAdvice is a sentinel error indicating that no scaling advice was generated. ErrNoScalingAdvice = errors.New("no scaling advice") // ErrUnsupportedNodeScoringStrategy is a sentinel error indicating an unsupported node scoring strategy was specified. ErrUnsupportedNodeScoringStrategy = errors.New("unsupported node scoring strategy") // ErrUnsupportedCloudProvider is a sentinel error indicating an unsupported cloud provider was specified. ErrUnsupportedCloudProvider = errors.New("unsupported cloud provider") // ErrLoadInstanceTypeInfo is a sentinel error indicating that instance type information could not be loaded. ErrLoadInstanceTypeInfo = errors.New("cannot load provider instance type info") // ErrMissingRequiredLabel is a sentinel error indicating that a required label is missing from a resource. ErrMissingRequiredLabel = errors.New("missing required label") // ErrInvalidScalingConstraint is a sentinel error indicating that the provided scaling constraint is invalid. ErrInvalidScalingConstraint = errors.New("invalid scaling constraint") )
Functions ¶
Types ¶
type ActivityStatus ¶
type ActivityStatus string
ActivityStatus represents the operational status of an activity.
const ( // ActivityStatusPending indicates the activity is pending execution. ActivityStatusPending ActivityStatus = "Pending" // ActivityStatusRunning indicates the activity is currently running. ActivityStatusRunning ActivityStatus = "Running" // ActivityStatusSuccess indicates the activity completed successfully. ActivityStatusSuccess ActivityStatus = metav1.StatusSuccess // ActivityStatusFailure indicates the activity failed. ActivityStatusFailure ActivityStatus = metav1.StatusFailure )
type App ¶
type App struct {
// Service is the scaling advisor service instance.
Service ScalingAdvisorService
// Ctx is the application context.
Ctx context.Context
// Cancel is the context cancellation function.
Cancel context.CancelFunc
}
App represents an application process that wraps a ScalingAdvisorService, an application context and application cancel func. `main` entry-point functions that embed scadsvc are expected to construct a new App instance via cli.LaunchApp and shutdown applications via cli.ShutdownApp
type ClusterSnapshot ¶
type ClusterSnapshot struct {
// Pods are the pods that are present in the cluster.
Pods []PodInfo
// Nodes are the nodes that are present in the cluster.
Nodes []NodeInfo
// PriorityClasses are the priority classes that are present in the cluster.
PriorityClasses []schedulingv1.PriorityClass
// RuntimeClasses are the runtime classes that are present in the cluster.
RuntimeClasses []nodev1.RuntimeClass
}
ClusterSnapshot represents a snapshot of the cluster at a specific time and encapsulates the scheduling relevant information required by the kube-scheduler. Pods inside the ClusterSnapshot should not have SchedulingGates - these should be filtered out by creator of the ClusterSnapshot.
func (*ClusterSnapshot) GetNodeCountByPlacement ¶
func (c *ClusterSnapshot) GetNodeCountByPlacement() (map[sacorev1alpha1.NodePlacement]int32, error)
GetNodeCountByPlacement returns a map of node placements to their respective node counts in the cluster.
func (*ClusterSnapshot) GetUnscheduledPods ¶
func (c *ClusterSnapshot) GetUnscheduledPods() []PodInfo
GetUnscheduledPods returns all pods in the cluster snapshot that are not scheduled to any node.
type GetNodeScoreSelector ¶
type GetNodeScoreSelector func(scoringStrategy commontypes.NodeScoringStrategy) (NodeScoreSelector, error)
GetNodeScoreSelector is a factory function for creating NodeScoreSelector implementations.
type GetNodeScorer ¶
type GetNodeScorer func(scoringStrategy commontypes.NodeScoringStrategy, instanceTypeInfoAccess InstancePricingAccess, weightsFn GetWeightsFunc) (NodeScorer, error)
GetNodeScorer is a factory function for creating NodeScorer implementations.
type GetProviderInstancePricingAccessFunc ¶
type GetProviderInstancePricingAccessFunc func(provider commontypes.CloudProvider, instanceTypeInfoPath string) (InstancePricingAccess, error)
GetProviderInstancePricingAccessFunc is a factory function for creating InstancePricingAccess implementations.
type GetWeightsFunc ¶
type GetWeightsFunc func(instanceType string) (map[corev1.ResourceName]float64, error)
GetWeightsFunc is a function type for retrieving resource weights for scoring.
type InstancePriceInfo ¶
type InstancePriceInfo struct {
// InstanceType is the name of the instance type.
InstanceType string `json:"instanceType"`
// Region is the cloud region where the instance is available.
Region string `json:"region"`
// OS is the operating system for the instance type.
OS string `json:"os"`
// Memory is the amount of memory in GB for the instance type.
Memory int64 `json:"memory"`
// GPUMemory is the amount of GPU memory in GB for the instance type.
GPUMemory int64 `json:"GPUMemory"`
// HourlyPrice is the hourly cost for the instance type.
HourlyPrice float64 `json:"hourlyPrice"`
// GPU is the number of GPUs for the instance type.
GPU int32 `json:"GPU"`
// VCPU is the number of virtual CPUs for the instance type.
VCPU int32 `json:"VCPU"`
}
InstancePriceInfo contains pricing and specification information for a cloud instance type.
type InstancePricingAccess ¶
type InstancePricingAccess interface {
// GetInfo gets the InstancePriceInfo (whicn includes price) for the given region and instance type.
// TODO: should we also pass OS name here ? if so, we need to need to change ClusterScalingConstraint.
GetInfo(region, instanceTypeName string) (InstancePriceInfo, error)
}
InstancePricingAccess defines an interface for accessing instance pricing information.
type NodeInfo ¶
type NodeInfo struct {
// Capacity is the total resource capacity of the node.
Capacity map[corev1.ResourceName]int64 `json:"capacity,omitempty"`
// Allocatable is the allocatable resource capacity of the node.
Allocatable map[corev1.ResourceName]int64 `json:"allocatable,omitempty"`
// CSIDriverVolumeMaximums is a map of CSI driver names to the maximum number of unique volumes managed by the
// CSI driver that can be used on a node.
CSIDriverVolumeMaximums map[string]int32 `json:"csiDriverVolumeMaximums,omitempty"`
// InstanceType is the instance type for the Node.
InstanceType string `json:"instanceType"`
ResourceMeta
// Taints are the node's taints.
Taints []corev1.Taint `json:"taints,omitempty"`
// Conditions are the node's conditions.
Conditions []corev1.NodeCondition `json:"conditions,omitempty"`
// Unschedulable indicates whether the node is unschedulable.
Unschedulable bool `json:"unschedulable"`
}
NodeInfo contains the minimum set of information about corev1.Node that will be required by the kube-scheduler.
func (*NodeInfo) GetResourceInfo ¶
func (n *NodeInfo) GetResourceInfo() NodeResourceInfo
GetResourceInfo returns the resource information for the node.
type NodePodAssignment ¶
type NodePodAssignment struct {
// Node contains the resource information for the node.
Node NodeResourceInfo
// ScheduledPods contains the list of pods scheduled to this node.
ScheduledPods []PodResourceInfo
}
NodePodAssignment represents the assignment of pods to a node for simulation purposes.
type NodeResourceInfo ¶
type NodeResourceInfo struct {
// Capacity is the total resource capacity of the node.
Capacity map[corev1.ResourceName]int64
// Allocatable is the allocatable resource capacity of the node.
Allocatable map[corev1.ResourceName]int64
// Name is the node name.
Name string
// InstanceType is the cloud instance type of the node.
InstanceType string
}
NodeResourceInfo represents the subset of NodeInfo such that NodeScorer can compute an effective NodeScore. TODO think of a better name.
type NodeScore ¶
type NodeScore struct {
ScaledNodeResource NodeResourceInfo
// Placement represents the placement information for the Node.
Placement sacorev1alpha1.NodePlacement
// ID uniquely identifies this NodeScore
ID string
UnscheduledPods []types.NamespacedName
// Value is the score value for this Node.
Value int
}
NodeScore represents the scoring result for a node in scaling simulations.
type NodeScoreSelector ¶
type NodeScoreSelector func(groupNodeScores []NodeScore, weightsFn GetWeightsFunc, pricing InstancePricingAccess) (winningNodeScore *NodeScore, err error)
NodeScoreSelector selects the winning NodeScore amongst the NodeScores of a given simulation pass and returns the pointer to the same. If there is no winning node score amongst the group, then it returns nil.
type NodeScorer ¶
type NodeScorer interface {
// Compute computes the node score given the NodeScorerArgs. On failure, it must return an error with the sentinel error api.ErrComputeNodeScore
Compute(args NodeScorerArgs) (NodeScore, error)
}
NodeScorer defines an interface for computing node scores for scaling decisions.
type NodeScorerArgs ¶
type NodeScorerArgs struct {
// ID that must be given to the NodeScore produced by the NodeScorer
ID string
// Placement represents the placement information for the Node.
Placement sacorev1alpha1.NodePlacement
// ScaledAssignment represents the assignment of the scaled Node for the current run.
ScaledAssignment *NodePodAssignment
// OtherAssignments represent the assignment of unscheduled Pods to either an existing Node which is part of the ClusterSnapshot
// or it is a winning simulated Node from a previous run.
OtherAssignments []NodePodAssignment
// UnscheduledPods is the slice of unscheduled pods that remain unscheduled after simulation is completed.
UnscheduledPods []types.NamespacedName
}
NodeScorerArgs contains arguments for node scoring computation.
type PodInfo ¶
type PodInfo struct {
ResourceMeta
// AggregatedRequests is an aggregated resource requests for all containers of the Pod.
AggregatedRequests map[corev1.ResourceName]int64 `json:"aggregatedRequests,omitempty"`
// Volumes are the volumes that are attached to the Pod.
Volumes []corev1.Volume `json:"volumes,omitempty"`
// NodeSelector is the node selector for the Pod.
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// NodeName is the name of the node where the Pod is scheduled.
NodeName string `json:"nodeName,omitempty"`
// Affinity is the affinity rules for the Pod.
Affinity *corev1.Affinity `json:"affinity,omitempty"`
// SchedulerName is the name of the scheduler that should be used to schedule the Pod.
SchedulerName string `json:"schedulerName,omitempty"`
// Tolerations are the tolerations for the Pod.
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// PriorityClassName is the name of the priority class that should be used to schedule the Pod.
PriorityClassName string `json:"priorityClassName,omitempty"`
Priority *int32 `json:"priority,omitempty"`
PreemptionPolicy *corev1.PreemptionPolicy `json:"preemptionPolicy,omitempty"`
RuntimeClassName *string `json:"runtimeClassName,omitempty"`
Overhead map[corev1.ResourceName]int64 `json:"overhead,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
ResourceClaims []corev1.PodResourceClaim `json:"resourceClaims,omitempty"`
}
PodInfo contains the minimum set of information about corev1.Pod that will be required by the kube-scheduler. NOTES:
- PodSchedulingGates should not be not part of PodInfo. It is expected that pods having scheduling gates will be filtered out before setting up simulation runs.
- Consider including PodSpec.Resources in future when it graduates to beta/GA.
func (*PodInfo) GetResourceInfo ¶
func (p *PodInfo) GetResourceInfo() PodResourceInfo
GetResourceInfo returns the resource information for the pod.
type PodResourceInfo ¶
type PodResourceInfo struct {
// AggregatedRequests is an aggregated resource requests for all containers of the Pod.
AggregatedRequests map[corev1.ResourceName]int64
// NamespacedName contains the namespace and name of the pod.
types.NamespacedName
// UID is the unique identifier for the pod.
UID types.UID
}
PodResourceInfo contains resource information for a pod used in scoring calculations.
type PriceKey ¶
type PriceKey struct {
// Name is the instance type name.
Name string
// Region is the cloud region.
Region string
}
PriceKey represents the key for a instance type price within a cloud provider.
type ResourceMeta ¶
type ResourceMeta struct {
// UID is the unique identifier for the resource.
UID types.UID `json:"uid"`
types.NamespacedName
// Labels are the labels associated with the resource.
Labels map[string]string `json:"labels,omitempty"`
// Annotations are the annotations associated with the resource.
Annotations map[string]string `json:"annotations,omitempty"`
// DeletionTimestamp is the timestamp when the resource deletion was triggered.
DeletionTimestamp *metav1.Time `json:"deletionTimestamp,omitempty"`
// OwnerReferences are the owner references associated with the resource.
OwnerReferences []metav1.OwnerReference `json:"ownerReferences,omitempty"`
}
ResourceMeta contains common metadata fields for Kubernetes resources.
type ScalingAdviceRequest ¶
type ScalingAdviceRequest struct {
// Snapshot is the snapshot of the resources in the cluster at the time of the request.
Snapshot *ClusterSnapshot
// Feedback captures feedback from the consumer of the scaling advice, which can be used to improve future scaling advice generation.
Feedback *sacorev1alpha1.ClusterScalingFeedback
// Constraint represents the constraints using which the scaling advice is generated.
Constraint *sacorev1alpha1.ClusterScalingConstraint
ScalingAdviceRequestRef
// EnableDiagnostics indicates whether diagnostics should be enabled for the scaling advice generation.
// If it is enabled then it will populate ScalingAdviceResponse.ScalingAdvice.Status.Diagnostic field.
EnableDiagnostics bool
}
ScalingAdviceRequest encapsulates the request parameters for generating scaling advice.
type ScalingAdviceRequestRef ¶
type ScalingAdviceRequestRef struct {
// ID is the Request unique identifier for which this response is generated.
ID string
// CorrelationID is the correlation identifier for the request. It can be used to correlate a response with a request.
CorrelationID string
}
ScalingAdviceRequestRef is the unique reference to a scaling advice request.
type ScalingAdviceResponse ¶
type ScalingAdviceResponse struct {
// ScalingAdvice contains the scaling advice generated by the scaling advisor service.
ScalingAdvice *sacorev1alpha1.ClusterScalingAdvice
// Diagnostic provides diagnostics information for the scaling advice.
// This is only set by the scaling advisor service if ScalingAdviceRequest.EnableDiagnostics is set to true.
Diagnostics *sacorev1alpha1.ScalingAdviceDiagnostic
// RequestRef encapsulates the unique reference to a request for which this response is produced.
RequestRef ScalingAdviceRequestRef
// Message is a human-readable message providing additional context about the response.
Message string
}
ScalingAdviceResponse encapsulates the response from the scaling advisor service.
type ScalingAdviceResponseFn ¶
type ScalingAdviceResponseFn func(response ScalingAdviceResponse) error
ScalingAdviceResponseFn is a callback function which is invoked by the scaling advisor service when generating scaling advice. The callback maybe invoked zero or more times during the generation of scaling advice with callbackType representing the type of change in the scaling advice.
type ScalingAdviceResult ¶
type ScalingAdviceResult struct {
// Response contains a piece of scaling advice generated by the service.
// It is non-nil only when Err is nil.
Response *ScalingAdviceResponse
// Err contains a fatal error that occurred during generation.
// It is non-nil only when Response is nil.
Err error
}
ScalingAdviceResult represents a single result emitted by the ScalingAdvisorService during the generation of scaling advice.
Each result will contain either a Response or an Err:
- If Response is non-nil, it contains one piece of scaling advice.
- If Err is non-nil, it represents a terminal error that occurred during advice generation. No further results will be sent after an error result.
The caller should treat the channel of ScalingAdviceResult as a stream of results that may end either because the service has finished generating responses or because an error was encountered. The stream ends when the channel is closed.
Usage:
results := svc.GenerateAdvice(ctx, req)
for r := range results {
if r.Err != nil {
log.Printf("advice generation failed: %v", r.Err)
break
}
process(r.Response)
}
If the provided context is canceled, the service should stop generation and close the channel.
type ScalingAdvisorService ¶
type ScalingAdvisorService interface {
commontypes.Service
// GenerateAdvice begins generating scaling advice for the given request.
//
// It returns a channel of ScalingAdviceResult values. The channel will be closed
// when advice generation is completed or a fatal error has occurred.
//
// The caller must consume all events from the channel until it is closed to
// avoid leaking goroutines inside the service implementation.
//
// The provided context can be used to cancel generation prematurely. In this
// case, the channel will be closed without further events.
GenerateAdvice(ctx context.Context, req ScalingAdviceRequest) <-chan ScalingAdviceResult
}
ScalingAdvisorService is the high-level facade for the scaling advisor service.
type ScalingAdvisorServiceConfig ¶
type ScalingAdvisorServiceConfig struct {
// CloudProvider is the cloud provider for which the scaling advisor service is initialized.
CloudProvider commontypes.CloudProvider
// LogBaseDir is the base directory for storing log files used by the scaling advisor service.
LogBaseDir string
commontypes.ServerConfig
// MinKAPIConfig holds the configuration for the MinKAPI server used by the scaling advisor service.
MinKAPIConfig mkapi.Config
commontypes.QPSBurst
// MaxParallelSimulations is the maximum number of parallel simulations that can be run by the scaling advisor service.
MaxParallelSimulations int
}
ScalingAdvisorServiceConfig holds the configuration for the scaling advisor service.
type SchedulerHandle ¶
type SchedulerHandle interface {
io.Closer
// GetParams returns the parameters used to launch the scheduler instance.
GetParams() SchedulerLaunchParams
}
SchedulerHandle defines the interface for managing a kube-scheduler instance.
type SchedulerLaunchParams ¶
type SchedulerLaunchParams struct {
// EventSink is the event sink used to send events from the kube-scheduler.
EventSink events.EventSink
commontypes.ClientFacades
}
SchedulerLaunchParams holds the parameters required to launch a kube-scheduler instance.
type SchedulerLauncher ¶
type SchedulerLauncher interface {
// Launch launches and runs an embedded scheduler instance asynchronously.
// If the limit of running schedulers is reached, it will block.
// An error is returned if the scheduler fails to start.
Launch(ctx context.Context, params *SchedulerLaunchParams) (SchedulerHandle, error)
}
SchedulerLauncher defines the interface for launching a kube-scheduler instance. There will be a limited number of kube-scheduler instances that can be launched at a time.
type SimGroupKey ¶
type SimGroupKey struct {
// NodePoolPriority is the priority of the node pool.
NodePoolPriority int32
// NodeTemplatePriority is the priority of the node template.
NodeTemplatePriority int32
}
SimGroupKey represents the key for a SimulationGroup.
func (SimGroupKey) String ¶
func (k SimGroupKey) String() string
String returns a string representation of the SimGroupKey.
type SimGroupRunResult ¶
type SimGroupRunResult struct {
// Name of the group that produced this result.
Name string
// SimulationResults contains the results from all simulations in the group.
SimulationResults []SimRunResult
// Key is the simulation group key (partition key)
Key SimGroupKey
}
SimGroupRunResult contains the results of running a simulation group.
type SimGroupScores ¶
type SimGroupScores struct {
// WinnerNodeScore is the highest scoring node in the group.
WinnerNodeScore *NodeScore
// WinnerNode is the actual node corresponding to the winner score.
WinnerNode *corev1.Node
// AllNodeScores contains all computed node scores for the group.
AllNodeScores []NodeScore
}
SimGroupScores represents the scoring results for the simulation group after running the NodeScorer against the SimGroupRunResult.
type SimRunResult ¶
type SimRunResult struct {
// Name of the Simulation that produced this result.
Name string
// ScaledNode is the simulated scaled node.
ScaledNode *corev1.Node
NodeScorerArgs
}
SimRunResult contains the results of a completed simulation run.
type Simulation ¶
type Simulation interface {
// Name returns the logical simulation name
Name() string
// ActivityStatus returns the current ActivityStatus of the simulation
ActivityStatus() ActivityStatus
// NodePool returns the target node pool against which the simulation should be run
NodePool() *sacorev1alpha1.NodePool
// NodeTemplate returns the target node template against which the simulation should be run
NodeTemplate() *sacorev1alpha1.NodeTemplate
// Run executes the simulation to completion and returns any encountered error. This is a blocking call and callers are
// expected to manage concurrency and SimRunResult consumption.
Run(ctx context.Context) error
// Result returns the latest SimRunResult if the simulation is in ActivityStatusSuccess,
// or nil if the simulation is in ActivityStatusPending or ActivityStatusRunning
// or an error if the ActivityStatus is ActivityStatusFailure
Result() (SimRunResult, error)
}
Simulation represents an activity that performs valid unscheduled pod to ready node assignments on a minkapi View. A simulation implementation may use a k8s scheduler - either embedded or external to do this, or it may form a SAT/MIP model from the pod/node data and run a tool that solves the model.
type SimulationArgs ¶
type SimulationArgs struct {
// SchedulerLauncher is used to launch scheduler instances for the simulation.
SchedulerLauncher SchedulerLauncher
// View is the MinKAPI view used for the simulation.
View mkapi.View
// NodePool is the target node pool for the simulation.
NodePool *sacorev1alpha1.NodePool
// GroupRunPassCounter is an atomic counter for tracking simulation group passes.
GroupRunPassCounter *atomic.Uint32
// AvailabilityZone is the target availability zone for the simulation.
AvailabilityZone string
// NodeTemplateName is the name of the node template to use in the simulation.
NodeTemplateName string
// TrackPollInterval is the polling interval for tracking pod scheduling in the view and reconciling simulation state
TrackPollInterval time.Duration
}
SimulationArgs represents the argument necessary for creating a simulation instance.
type SimulationCreator ¶
type SimulationCreator interface {
// Create creates a simulation instance with the given name and arguments.
Create(name string, args *SimulationArgs) (Simulation, error)
}
SimulationCreator is an interface that wraps a method that satisfied SimulationCreatorFunc
type SimulationCreatorFunc ¶
type SimulationCreatorFunc func(name string, args *SimulationArgs) (Simulation, error)
SimulationCreatorFunc is a factory function for constructing a simulation instance. It implements the SimulationCreator interface.
func (SimulationCreatorFunc) Create ¶
func (f SimulationCreatorFunc) Create(name string, args *SimulationArgs) (Simulation, error)
Create constructs a new simulation instance with the given name and arguments. Satisfies SimulationCreatorFunc
type SimulationGroup ¶
type SimulationGroup interface {
// Name returns the name of the simulation group.
Name() string
// GetKey returns the simulation group key.
GetKey() SimGroupKey
// GetSimulations returns all simulations in this group.
GetSimulations() []Simulation
// Run executes all simulations in the group and returns the results.
Run(ctx context.Context) (SimGroupRunResult, error)
}
SimulationGroup is a group of simulations at the same priority level (ie a partition of simulations). We attempt to run simulations for the given group and get a preferred NodeScore for simulations belonging to a group before moving to the group at the next priority.
Example:1
np-a: 1 {nt-a: 1, nt-b: 2, nt-c: 1}
np-b: 2 {nt-q: 2, nt-r: 1, nt-s: 1}
p1: {PoolPriority: 1, NTPriority: 1, nt-a, nt-c}
p2: {PoolPriority: 1, NTPriority: 2, nt-b}
p3: {PoolPriority: 2, NTPriority: 1, nt-r, nt-s}
p4: {PoolPriority: 2, NTPriority: 2, nt-q}
Example:2
np-a: 1 {nt-a: 1, nt-b: 2, nt-c: 1}
np-b: 2 {nt-q: 2, nt-r: 1, nt-s: 1}
np-c: 1 {nt-x: 2, nt-y: 1}
g1: {PoolPriority: 1, NTPriority: 1, nt-a, nt-c, nt-y}
g2: {PoolPriority: 1, NTPriority: 2, nt-b, nt-x}
g3: {PoolPriority: 2, NTPriority: 1, nt-r, nt-s}
g4: {PoolPriority: 2, NTPriority: 2, nt-q}
type SimulationGrouper ¶
type SimulationGrouper interface {
Group(simulations []Simulation) ([]SimulationGroup, error)
}
SimulationGrouper is an interface that wraps a method that satisfies SimulationGrouperFunc
type SimulationGrouperFunc ¶
type SimulationGrouperFunc func(simulations []Simulation) ([]SimulationGroup, error)
SimulationGrouperFunc represents a factory function for grouping Simulation instances into one or more SimulationGroups
func (SimulationGrouperFunc) Group ¶
func (f SimulationGrouperFunc) Group(simulations []Simulation) ([]SimulationGroup, error)
Group groups Simulation instances into one or more SimulationGroups. Satisfies SimulationGrouperFunc