state

package
v0.5.21 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NetBandwidthImplicitAnnotationKey = "resource.katalyst.kubewharf.io/net_bandwidth_implicit"
)

Variables

This section is empty.

Functions

func NewNetworkPluginState

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

Types

type AllocationInfo

type AllocationInfo struct {
	commonstate.AllocationMeta `json:",inline"`

	Egress     uint32         `json:"egress"`
	Ingress    uint32         `json:"ingress"`
	Identifier string         `json:"identifier"`
	NSName     string         `json:"ns_name"`
	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
	NetClassID string         `json:"net_class_id"`
}

func (*AllocationInfo) Clone

func (ai *AllocationInfo) Clone() *AllocationInfo

func (*AllocationInfo) GetRequestedEgress added in v0.5.21

func (ai *AllocationInfo) GetRequestedEgress() (uint32, error)

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)

Jump to

Keyboard shortcuts

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