scaledecider

package
v0.0.0-...-3511abf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ScaleDecider

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

ScaleDecider makes decisions based on the following assumptions:

  1. All pending tasks cannot fit into all agents when receiving the snapshots from the scheduler, i.e. we need to launch new agents to fit the pending tasks.
  2. All tasks, agents, and instances don't have empty identifiers.
  3. All tasks, agents, and instances are not duplicated.

ScaleDecider ignores the agents that cannot be associated with any instances. ScaleDecider considers the following two cases:

  1. Instances that can be associated with agents.
  2. Instances that cannot be associated with agents. There are several possible causes: a. The provider is starting up the instances. b. The instances are already running but agents on them are starting up. c. The agents are disconnected to the master due to misconfiguration or some unknown reason.

func New

func New(
	resourcePool string,
	maxIdlePeriod, maxStartingPeriod,
	maxDisconnectPeriod time.Duration,
	minInstanceNum int,
	maxInstanceNum int,
	db db.DB,
) *ScaleDecider

New creates a new scale decider.

func (*ScaleDecider) CalculateInstanceStates

func (s *ScaleDecider) CalculateInstanceStates()

CalculateInstanceStates calculates the instance states.

func (*ScaleDecider) CalculateNumInstancesToLaunch

func (s *ScaleDecider) CalculateNumInstancesToLaunch() int

CalculateNumInstancesToLaunch calculates the number of instances to launch.

func (*ScaleDecider) FindInstancesToTerminate

func (s *ScaleDecider) FindInstancesToTerminate() sproto.TerminateDecision

FindInstancesToTerminate finds instances to terminate.

func (*ScaleDecider) RecordInstanceStats

func (s *ScaleDecider) RecordInstanceStats(slots int) error

RecordInstanceStats records the instance stats.

func (*ScaleDecider) UpdateInstanceSnapshot

func (s *ScaleDecider) UpdateInstanceSnapshot(instances []*model.Instance) bool

UpdateInstanceSnapshot updates the instance snapshot.

func (*ScaleDecider) UpdateInstancesEndStats

func (s *ScaleDecider) UpdateInstancesEndStats(instIDs []string) error

UpdateInstancesEndStats updates the instance end stats.

func (*ScaleDecider) UpdateScalingInfo

func (s *ScaleDecider) UpdateScalingInfo(info *sproto.ScalingInfo)

UpdateScalingInfo updates the scaling information.

Jump to

Keyboard shortcuts

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