plugin

package
v0.31.1-ecr-test-2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxHTTPBodySize  int64  = 1 << 10 // 1 KiB
	ContentTypeJSON  string = "application/json"
	ContentTypeError string = "text/plain"
)
View Source
const (
	MinPluginProtocolVersion api.PluginProtoVersion = api.PluginProtoV3_0
	MaxPluginProtocolVersion api.PluginProtoVersion = api.PluginProtoV5_0
)

The scheduler plugin currently supports v3.0 to v5.0 of the agent<->scheduler plugin protocol.

If you update either of these values, make sure to also update VERSIONING.md.

View Source
const DefaultConfigPath = "/etc/scheduler-plugin-config/autoscale-enforcer-config.json"
View Source
const LabelPluginCreatedMigration = "autoscaling.neon.tech/created-by-scheduler"
View Source
const Name = "AutoscaleEnforcer"

Variables

This section is empty.

Functions

func NewAutoscaleEnforcerPlugin

func NewAutoscaleEnforcerPlugin(ctx context.Context, logger *zap.Logger, config *Config) func(runtime.Object, framework.Handle) (framework.Plugin, error)

Types

type AutoscaleEnforcer

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

AutoscaleEnforcer is the scheduler plugin to coordinate autoscaling

func (*AutoscaleEnforcer) Filter

func (e *AutoscaleEnforcer) Filter(
	ctx context.Context,
	state *framework.CycleState,
	pod *corev1.Pod,
	nodeInfo *framework.NodeInfo,
) (status *framework.Status)

Filter gives our plugin a chance to signal that a pod shouldn't be put onto a particular node

Required for framework.FilterPlugin

func (*AutoscaleEnforcer) Name

func (e *AutoscaleEnforcer) Name() string

Name returns the name of the AutoscaleEnforcer plugin

Required for framework.Plugin

func (*AutoscaleEnforcer) NormalizeScore added in v0.17.4

func (e *AutoscaleEnforcer) NormalizeScore(
	ctx context.Context,
	state *framework.CycleState,
	pod *corev1.Pod,
	scores framework.NodeScoreList,
) (status *framework.Status)

NormalizeScore weights scores uniformly in the range [minScore, trueScore], where minScore is framework.MinNodeScore + 1.

func (*AutoscaleEnforcer) PostFilter added in v0.11.0

func (e *AutoscaleEnforcer) PostFilter(
	ctx context.Context,
	state *framework.CycleState,
	pod *corev1.Pod,
	filteredNodeStatusMap framework.NodeToStatusMap,
) (_ *framework.PostFilterResult, status *framework.Status)

PostFilter is used by us for metrics on filter cycles that reject a Pod by filtering out all applicable nodes.

Quoting the docs for PostFilter:

> These plugins are called after Filter phase, but only when no feasible nodes were found for the > pod.

Required for framework.PostFilterPlugin

func (*AutoscaleEnforcer) PreFilter added in v0.12.0

func (e *AutoscaleEnforcer) PreFilter(
	ctx context.Context,
	state *framework.CycleState,
	pod *corev1.Pod,
) (_ *framework.PreFilterResult, status *framework.Status)

PreFilter is called at the start of any Pod's filter cycle. We use it in combination with PostFilter (which is only called on failure) to provide metrics for pods that are rejected by this process.

func (*AutoscaleEnforcer) PreFilterExtensions added in v0.12.0

func (e *AutoscaleEnforcer) PreFilterExtensions() framework.PreFilterExtensions

PreFilterExtensions is required for framework.PreFilterPlugin, and can return nil if it's not used

func (*AutoscaleEnforcer) Reserve

func (e *AutoscaleEnforcer) Reserve(
	ctx context.Context,
	state *framework.CycleState,
	pod *corev1.Pod,
	nodeName string,
) (status *framework.Status)

Reserve signals to our plugin that a particular pod will (probably) be bound to a node, giving us a chance to both (a) reserve the resources it needs within the node and (b) reject the pod if there aren't enough.

Required for framework.ReservePlugin

func (*AutoscaleEnforcer) Score

func (e *AutoscaleEnforcer) Score(
	ctx context.Context,
	state *framework.CycleState,
	pod *corev1.Pod,
	nodeName string,
) (_ int64, status *framework.Status)

Score allows our plugin to express which nodes should be preferred for scheduling new pods onto

Even though this function is given (pod, node) pairs, our scoring is only really dependent on values of the node. However, we have special handling for when the pod no longer fits in the node (even though it might have during the Filter plugin) - we can't return a failure, because that would cause *all* scheduling of the pod to fail, so we instead return the minimum score.

The scores might not be consistent with each other, due to ongoing changes in the node. That's ok, because nothing relies on strict correctness here, and they should be approximately correct anyways.

Required for framework.ScorePlugin

func (*AutoscaleEnforcer) ScoreExtensions

func (e *AutoscaleEnforcer) ScoreExtensions() framework.ScoreExtensions

ScoreExtensions is required for framework.ScorePlugin, and can return nil if it's not used. However, we do use it, to randomize scores.

func (*AutoscaleEnforcer) Unreserve

func (e *AutoscaleEnforcer) Unreserve(
	ctx context.Context,
	state *framework.CycleState,
	pod *corev1.Pod,
	nodeName string,
)

Unreserve marks a pod as no longer on-track to being bound to a node, so we can release the resources we previously reserved for it.

Required for framework.ReservePlugin.

Note: the documentation for ReservePlugin indicates that Unreserve both (a) must be idempotent and (b) may be called without a previous call to Reserve for the same pod.

type Config added in v0.1.17

type Config struct {
	// NodeConfig defines our policies around node resources and scoring
	NodeConfig nodeConfig `json:"nodeConfig"`

	// SchedulerName informs the scheduler of its name, so that it can identify pods that a previous
	// version handled.
	SchedulerName string `json:"schedulerName"`

	// EventQueueWorkers sets the number of worker threads responsible for handling items from the
	// event queue.
	EventQueueWorkers int `json:"eventQueueWorkers"`

	// StartupEventHandlingTimeoutSeconds gives the maximum duration, in seconds, that we are
	// allowed to wait to finish handling all of the initial events generated by reading the cluster
	// state on startup.
	//
	// If event processing takes longer than this time, then plugin creation will fail, and the
	// scheduler pod will retry.
	StartupEventHandlingTimeoutSeconds int `json:"startupEventHandlingTimeoutSeconds"`

	// RandomizeScores, if true, will cause the scheduler to score a node with a random number in
	// the range [minScore + 1, trueScore], instead of the trueScore
	RandomizeScores bool `json:"randomizeScores"`

	// MigrationDeletionRetrySeconds gives the duration, in seconds, we should wait between retrying
	// a failed attempt to delete a VirtualMachineMigration that's finished.
	MigrationDeletionRetrySeconds uint `json:"migrationDeletionRetrySeconds"`

	// DoMigration, if provided, allows VM migration to be disabled
	//
	// This flag is intended to be temporary, just until NeonVM supports mgirations and we can
	// re-enable it.
	DoMigration *bool `json:"doMigration"`

	// K8sNodeGroupLabel, if provided, gives the label to use when recording k8s node groups in the
	// metrics (like for autoscaling_plugin_node_{cpu,mem}_resources_current)
	K8sNodeGroupLabel string `json:"k8sNodeGroupLabel"`

	// K8sAvailabilityZoneLabel, if provided, gives the label to use when recording nodes'
	// availability zones in the metrics (like for autoscaling_plugin_node_{cpu,mem}_resources_current)
	K8sAvailabilityZoneLabel string `json:"k8sAvailabilityZoneLabel"`

	// IgnoreNamespaces, if provided, gives a list of namespaces that the plugin should completely
	// ignore, as if pods from those namespaces do not exist.
	//
	// This is specifically designed for our "overprovisioning" namespace, which creates paused pods
	// to trigger cluster-autoscaler.
	//
	// The only exception to this rule is during Filter method calls, where we do still count the
	// resources from such pods. The reason to do that is so that these overprovisioning pods can be
	// evicted, which will allow cluster-autoscaler to trigger scale-up.
	IgnoreNamespaces []string `json:"ignoreNamespaces"`

	// DumpState, if provided, enables a server to dump internal state
	DumpState *dumpStateConfig `json:"dumpState"`

	// JSONString is the JSON string that was used to generate this config struct
	JSONString string `json:"-"`
}

func ReadConfig added in v0.1.17

func ReadConfig(path string) (*Config, error)

type IndexedNodeStore added in v0.12.0

type IndexedNodeStore = watch.IndexedStore[corev1.Node, *watch.FlatNameIndex[corev1.Node]]

type IndexedVMStore added in v0.6.0

abbreviations, because these types are pretty verbose

type PromMetrics added in v0.6.0

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

func (*PromMetrics) IncFailIfNotSuccess added in v0.11.0

func (m *PromMetrics) IncFailIfNotSuccess(method string, pod *corev1.Pod, ignored bool, status *framework.Status)

func (*PromMetrics) IncMethodCall added in v0.13.3

func (m *PromMetrics) IncMethodCall(method string, pod *corev1.Pod, ignored bool)

func (*PromMetrics) IncReserveShouldDeny added in v0.28.0

func (m *PromMetrics) IncReserveShouldDeny(pod *corev1.Pod, node *nodeState)

Jump to

Keyboard shortcuts

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