const ( // The state key for storing a NodeEligibilityStats object. NodeEligibilityStatsInfoStateKey = "polaris-internal.node-eligibility-stats" )
const ( // StopwatchStateKey can be used as a key in the scheduler's state data for storing a single Stopwatch. StopwatchStateKey = "polaris-internal.stopwatch" )
func ParseYamlFile(path string, dest interface{}) error
Loads and parses the YAML file in the specified path and stores the result into the dest object.
The dest object must not be nil. Returns nil on success or an error, if any occurs.
func SetupSignalHandlingContext() context.Context
Creates a Context that gets cancelled upon an interrupt or TERM signal. If the signal is received a second time, the program will be exited immediately.
Information about sampled and eligible node counts.
type NodeEligibilityStats struct { // The total number of nodes that were sampled. SampledNodesCount int // The number of nodes that are eligible to host a pod after the Filter stage in the decision pipeline. EligibleNodesCount int }
A random number generator interface, for easily switching between multiple random number generator implementations. Implementations of this interface are generally NOT thread-safe.
type Random interface { // Generates a random integer in the interval [0, max) Int(max int) int }
func NewCryptoRandom() Random
Creates an instance of a Random implementation using the crypto/rand package.
func NewDefaultRandom() Random
Creates an instance of the default Random implementation.
func NewMathRandom() Random
Creates an instance of a Random implementation using the math/rand package, seeded using rand.Int63().
Represents a set of resources requested or consumed by a Pod.
type Resources struct { MilliCPU int64 `json:"milliCpu" yaml:"milliCpu"` MemoryBytes int64 `json:"memoryBytes" yaml:"memoryBytes"` EphemeralStorage int64 `json:"ephemeralStorage" yaml:"ephemeralStorage"` ExtendedResources map[core.ResourceName]int64 `json:"extendedResources" yaml:"extendedResources"` }
func CalculateNodeAvailableResources(node *core.Node, assignedPods []core.Pod) *Resources
Calculates a node's available resources, i.e., its total resource - resources used by already assigned pods.
func CalculateTotalPodResources(pod *core.Pod) *Resources
Calculates the total resource limits across all of the specified pod's containers.
func NewResources() *Resources
Creates a new, empty Resources object.
func NewResourcesFromList(rl core.ResourceList) *Resources
Creates a Resources object and initializes it with the specified ResourceList.
func (r *Resources) Add(other *Resources)
Adds the values in the specified Resources object to this Resources object.
func (r *Resources) AddResourceList(rl core.ResourceList)
Adds the specified ResourceList to this Resources object.
func (r *Resources) DeepCopy() *Resources
Creates a deep copy of this Resources object.
func (r *Resources) Equals(other *Resources) bool
Returns true if the values in this object are the same as in the other resources object.
func (r *Resources) LessThanOrEqual(other *Resources) bool
Returns true if all resource numbers expressed by this object are less than or equal to the ones expressed in the other object.
func (r *Resources) Subtract(other *Resources)
Subtracts the values in the specified Resources object from this Resources object.
func (r *Resources) SubtractResourceList(rl core.ResourceList)
Subtracts the specified ResourceList from this Resources object.
Stopwatch can be used to measure the time between two instants.
type Stopwatch struct {
// contains filtered or unexported fields
}
func NewStopwatch() *Stopwatch
NewStopwatch creates a new Stopwatch.
func (me *Stopwatch) Duration() time.Duration
Duration returns the duration of the time that was measured by this Stopwatch.
func (me *Stopwatch) IsStarted() bool
IsStarted returns true if the stopwatch has been started.
Note that this is not reset after the stopwatch is stopped. A stopped stopwatch has both IsStarted() and IsStopped() return true.
func (me *Stopwatch) IsStopped() bool
IsStopped returns true if the stopwatch has already been stopped.
func (me *Stopwatch) Start()
Start sets the current time as the start time of the Stopwatch.
func (me *Stopwatch) StartAt(startTime time.Time)
StartAt sets the specified time as the start time of the Stopwatch.
func (me *Stopwatch) StartTime() time.Time
Returns the start time of this stopwatch. Note that this value only makes sense, if the stopwatch has been started.
func (me *Stopwatch) Stop()
Stop sets the current time as the stop time of the Stopwatch.
It is explicitly supported to stop a stopwatch multiple times and read the duration after every stoppage to get multiple time readings.
func (me *Stopwatch) StopTime() time.Time
Returns the stop time of this stopwatch. Note that this value only makes sense, if the stopwatch has been stopped.