state

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocationInfo

type AllocationInfo struct {
	PodUid         string         `json:"pod_uid,omitempty"`
	PodNamespace   string         `json:"pod_namespace,omitempty"`
	PodName        string         `json:"pod_name,omitempty"`
	ContainerName  string         `json:"container_name,omitempty"`
	ContainerType  string         `json:"container_type,omitempty"`
	ContainerIndex uint64         `json:"container_index,omitempty"`
	RampUp         bool           `json:"ramp_up,omitempty"`
	PodRole        string         `json:"pod_role,omitempty"`
	PodType        string         `json:"pod_type,omitempty"`
	Egress         uint32         `json:"egress"`
	Ingress        uint32         `json:"ingress"`
	IfName         string         `json:"if_name"`   // we do not support cross-nic bandwidth
	NumaNodes      machine.CPUSet `json:"numa_node"` // associated numa nodes of the socket connecting to the selected NIC

	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
}

func (*AllocationInfo) CheckMainContainer

func (ai *AllocationInfo) CheckMainContainer() bool

CheckMainContainer returns true if the AllocationInfo is for main container

func (*AllocationInfo) CheckSideCar

func (ai *AllocationInfo) CheckSideCar() bool

CheckSideCar returns true if the AllocationInfo is for side-car container

func (*AllocationInfo) Clone

func (ai *AllocationInfo) Clone() *AllocationInfo

func (*AllocationInfo) String

func (ai *AllocationInfo) String() string

type BandwidthInfo

type BandwidthInfo struct {

	// Actual line speed of a NIC. E.g. a 25Gbps NIC's max bandwidth is around 23.5Gbps
	// It's configurable. Its value = NIC line speed x configured CapacityRate
	Capacity uint32
	// Reserved bandwidth on this NIC (e.g. for system components or high priority tasks)
	// For the sake of safety, we generally keep an overflow buffer and do not allocate all bandwidth to tasks
	// Thus, both reservations should be set slightly larger than the actual required amount
	SysReservation uint32
	Reservation    uint32
	Allocatable    uint32
	Allocated      uint32
	Free           uint32
}

type ContainerEntries

type ContainerEntries map[string]*AllocationInfo // Keyed by container name

type NICMap

type NICMap map[string]*NICState // keyed by NIC name i.e. eth0

func GenerateMachineState

func GenerateMachineState(conf *qrm.QRMPluginsConfiguration, nics []machine.InterfaceInfo, reservation map[string]uint32) (NICMap, error)

GenerateMachineState returns NICResourcesMap based on machine info and reserved resources

func GenerateMachineStateFromPodEntries

func GenerateMachineStateFromPodEntries(conf *qrm.QRMPluginsConfiguration, nics []machine.InterfaceInfo,
	podEntries PodEntries, reservation map[string]uint32) (NICMap, error)

GenerateMachineStateFromPodEntries returns NICMap for bandwidth based on machine info and reserved resources along with existed pod entries

func (NICMap) Clone

func (nm NICMap) Clone() NICMap

func (NICMap) EgressBandwidthPerNIC

func (nm NICMap) EgressBandwidthPerNIC() (uint32, error)

EgressBandwidthPerNIC is a helper function to parse egress bandwidth per NIC

func (NICMap) IngressBandwidthPerNIC

func (nm NICMap) IngressBandwidthPerNIC() (uint32, error)

IngressBandwidthPerNIC is a helper function to parse egress bandwidth per NIC

func (NICMap) String

func (nm NICMap) String() string

type NICState

type NICState struct {
	EgressState  BandwidthInfo `json:"egress_state"`
	IngressState BandwidthInfo `json:"ingress_state"`
	PodEntries   PodEntries    `json:"pod_entries"`
}

NICState indicates the status of a NIC, including the capacity/reservation/allocation (in Mbps)

func (*NICState) Clone

func (ns *NICState) Clone() *NICState

func (*NICState) SetAllocationInfo

func (ns *NICState) SetAllocationInfo(podUID string, containerName string, allocationInfo *AllocationInfo)

SetAllocationInfo adds a new AllocationInfo (for pod/container pairs) into the given NICState

func (*NICState) String

func (ns *NICState) String() string

type NetworkPluginCheckpoint

type NetworkPluginCheckpoint struct {
	PolicyName   string            `json:"policyName"`
	MachineState NICMap            `json:"machineState"`
	PodEntries   PodEntries        `json:"pod_entries"`
	Checksum     checksum.Checksum `json:"checksum"`
}

func NewNetworkPluginCheckpoint

func NewNetworkPluginCheckpoint() *NetworkPluginCheckpoint

func (*NetworkPluginCheckpoint) MarshalCheckpoint

func (cp *NetworkPluginCheckpoint) MarshalCheckpoint() ([]byte, error)

MarshalCheckpoint returns marshaled checkpoint

func (*NetworkPluginCheckpoint) UnmarshalCheckpoint

func (cp *NetworkPluginCheckpoint) UnmarshalCheckpoint(blob []byte) error

UnmarshalCheckpoint tries to unmarshal passed bytes to checkpoint

func (*NetworkPluginCheckpoint) VerifyChecksum

func (cp *NetworkPluginCheckpoint) VerifyChecksum() error

VerifyChecksum verifies that current checksum of checkpoint is valid

type PodEntries

type PodEntries map[string]ContainerEntries // Keyed by pod UID

func (PodEntries) Clone

func (pe PodEntries) Clone() PodEntries

func (PodEntries) GetMainContainerAllocation

func (pe PodEntries) GetMainContainerAllocation(podUID string) (*AllocationInfo, bool)

GetMainContainerAllocation returns AllocationInfo that belongs the main container for this pod

func (PodEntries) String

func (pe PodEntries) String() string

type ReadonlyState

type ReadonlyState interface {
	GetMachineInfo() *info.MachineInfo
	GetEnabledNICs() []machine.InterfaceInfo
	GetReservedBandwidth() map[string]uint32
	// contains filtered or unexported methods
}

ReadonlyState interface only provides methods for tracking pod assignments

type State

type State interface {
	ReadonlyState
	// contains filtered or unexported methods
}

State interface provides methods for tracking and setting pod assignments

func NewCheckpointState

func NewCheckpointState(conf *qrm.QRMPluginsConfiguration, stateDir, checkpointName, policyName string,
	machineInfo *info.MachineInfo, nics []machine.InterfaceInfo, reservedBandwidth map[string]uint32,
	skipStateCorruption bool) (State, error)

func NewNetworkPluginState

func NewNetworkPluginState(conf *qrm.QRMPluginsConfiguration, machineInfo *info.MachineInfo, nics []machine.InterfaceInfo, reservedBandwidth map[string]uint32) (State, error)

Jump to

Keyboard shortcuts

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