scheduler

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	api.MachineClient
	api.VolumeClient
}

type ClusterState

type ClusterState struct {
	Machines []*Machine
}

ClusterState represents the current and planned state of machines and their resources in the cluster.

func InspectClusterState

func InspectClusterState(ctx context.Context, cli Client) (*ClusterState, error)

InspectClusterState creates a new cluster state by inspecting the machines using the cluster client.

func (*ClusterState) Machine

func (s *ClusterState) Machine(nameOrID string) (*Machine, bool)

Machine returns the machine with the given name or ID from the cluster state.

type Constraint

type Constraint interface {
	// Evaluate determines if a machine satisfies the constraint.
	Evaluate(machine *Machine) bool

	// Description returns a human-readable description of the constraint.
	Description() string
}

Constraint is the base interface for all scheduling constraints.

type Machine

type Machine struct {
	Info             *pb.MachineInfo
	Volumes          []volume.Volume
	ScheduledVolumes []api.VolumeSpec
}

type PlacementConstraint

type PlacementConstraint struct {
	// Machines is a list of machine names or IDs where service containers are allowed to be deployed.
	// If empty, containers can be deployed to any available machine in the cluster.
	Machines []string
}

func (*PlacementConstraint) Description

func (c *PlacementConstraint) Description() string

func (*PlacementConstraint) Evaluate

func (c *PlacementConstraint) Evaluate(machine *Machine) bool

type ServiceScheduler

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

func NewServiceScheduler

func NewServiceScheduler(state *ClusterState, spec api.ServiceSpec) *ServiceScheduler

NewServiceScheduler creates a new ServiceScheduler with the given cluster state and service specification.

func (*ServiceScheduler) EligibleMachines

func (s *ServiceScheduler) EligibleMachines() ([]*Machine, error)

EligibleMachines returns a list of machines that satisfy all constraints for the next scheduled container.

func (*ServiceScheduler) ScheduleContainer

func (s *ServiceScheduler) ScheduleContainer() ([]*pb.MachineInfo, error)

type VolumeScheduler

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

VolumeScheduler determines what missing volumes should be created and where for a multi-service deployment. It satisfies the following constraints:

  • Services that share a volume must be placed on the same machine where the volume is located. If the volume is located on multiple machines, services can be placed on any of them.
  • Services must respect their individual placement constraints.
  • If a volume already exists on a machine, it must be used instead of creating a new one.
  • A missing volume must only be created on one machine.

func NewVolumeScheduler

func NewVolumeScheduler(state *ClusterState, specs []api.ServiceSpec) (*VolumeScheduler, error)

NewVolumeScheduler creates a new VolumeScheduler with the given cluster state and service specifications.

func (*VolumeScheduler) Schedule

func (s *VolumeScheduler) Schedule() (map[string][]api.VolumeSpec, error)

Schedule determines what missing volumes should be created and where for services in the multi-service deployment. It returns a map of machine IDs to a list of api.VolumeSpec that should be created on that machine, or an error if services can't be scheduled due to scheduling constraints.

type VolumesConstraint

type VolumesConstraint struct {
	// Volumes is a list of named Docker volumes of type api.VolumeTypeVolume that must exist on the machine.
	Volumes []api.VolumeSpec
}

VolumesConstraint restricts container placement to machines that have the required named Docker volumes.

func (*VolumesConstraint) Description

func (c *VolumesConstraint) Description() string

func (*VolumesConstraint) Evaluate

func (c *VolumesConstraint) Evaluate(machine *Machine) bool

Evaluate determines if a machine has all the required volumes. Returns true if all required volumes exist or scheduled on the machine or if there are no required volumes.

Jump to

Keyboard shortcuts

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