state

package
v0.50.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVPod

func GetVPod(key types.NamespacedName, vpods []scheduler.VPod) scheduler.VPod

Get retrieves the VPod from the vpods lister for a given namespace and name.

func OrdinalFromPodName

func OrdinalFromPodName(podName string) int32

func PodNameFromOrdinal

func PodNameFromOrdinal(name string, ordinal int32) string

func ToJSONable added in v0.42.4

func ToJSONable(ps map[types.NamespacedName]map[string]int32) map[string]map[string]int32

Types

type State

type State struct {
	// free tracks the free capacity of each pod.
	//
	// Including pods that might not exist anymore, it reflects the free capacity determined by
	// placements in the vpod status.
	FreeCap []int32

	// schedulable pods tracks the pods that aren't being evicted.
	SchedulablePods []int32

	// Pod capacity.
	Capacity int32

	// Replicas is the (cached) number of statefulset replicas.
	Replicas int32

	StatefulSetName string

	PodLister corev1.PodNamespaceLister

	// Stores for each vpod, a map of podname to number of vreplicas placed on that pod currently
	PodSpread map[types.NamespacedName]map[string]int32

	// Pending tracks the number of virtual replicas that haven't been scheduled yet
	// because there wasn't enough free capacity.
	Pending map[types.NamespacedName]int32

	// ExpectedVReplicaByVPod is the expected virtual replicas for each vpod key
	ExpectedVReplicaByVPod map[types.NamespacedName]int32
}

state provides information about the current scheduling of all vpods It is used by for the scheduler and the autoscaler

func (*State) Free

func (s *State) Free(ordinal int32) int32

Free safely returns the free capacity at the given ordinal

func (*State) FreeCapacity

func (s *State) FreeCapacity() int32

FreeCapacity returns the number of vreplicas that can be used, up to the last ordinal

func (*State) IsSchedulablePod added in v0.35.6

func (s *State) IsSchedulablePod(ordinal int32) bool

func (*State) MarshalJSON added in v0.35.6

func (s *State) MarshalJSON() ([]byte, error)

func (*State) SetFree

func (s *State) SetFree(ordinal int32, value int32)

SetFree safely sets the free capacity at the given ordinal

func (*State) TotalExpectedVReplicas added in v0.38.2

func (s *State) TotalExpectedVReplicas() int32

func (*State) TotalPending added in v0.38.2

func (s *State) TotalPending() int32

type StateAccessor

type StateAccessor interface {
	// State returns the current state (snapshot) about placed vpods
	// Take into account reserved vreplicas and update `reserved` to reflect
	// the current state.
	State(ctx context.Context) (*State, error)
}

func NewStateBuilder

func NewStateBuilder(sfsname string, lister scheduler.VPodLister, podCapacity int32, podlister corev1.PodNamespaceLister, statefulSetCache *scheduler.ScaleCache) StateAccessor

NewStateBuilder returns a StateAccessor recreating the state from scratch each time it is requested

Jump to

Keyboard shortcuts

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