util

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ResourceName = "nvidia.com/gpu"
	//ResourceName = "hami.io/vgpu".
	AssignedTimeAnnotations = "hami.io/vgpu-time"
	AssignedNodeAnnotations = "hami.io/vgpu-node"
	BindTimeAnnotations     = "hami.io/bind-time"
	DeviceBindPhase         = "hami.io/bind-phase"

	DeviceBindAllocating = "allocating"
	DeviceBindFailed     = "failed"
	DeviceBindSuccess    = "success"

	DeviceLimit = 100

	BestEffort string = "best-effort"
	Restricted string = "restricted"
	Guaranteed string = "guaranteed"

	// NodeNameEnvName define env var name for use get node name.
	NodeNameEnvName = "NODE_NAME"
)
View Source
const (
	// OneContainerMultiDeviceSplitSymbol this is when one container use multi device, use : symbol to join device info.
	OneContainerMultiDeviceSplitSymbol = ":"

	// OnePodMultiContainerSplitSymbol this is when one pod having multi container and more than one container use device, use ; symbol to join device info.
	OnePodMultiContainerSplitSymbol = ";"
)

Variables

View Source
var (
	DebugMode bool

	DeviceSplitCount    *uint
	DeviceMemoryScaling *float64
	DeviceCoresScaling  *float64
	NodeName            string
	RuntimeSocketFlag   string
	DisableCoreLimit    *bool
)
View Source
var (
	InRequestDevices map[string]string
	SupportDevices   map[string]string
	HandshakeAnnos   map[string]string
)

Functions

func CheckHealth

func CheckHealth(devType string, n *corev1.Node) (bool, bool)

func DecodeNodeDevices

func DecodeNodeDevices(str string) ([]*api.DeviceInfo, error)

func EncodeContainerDeviceType

func EncodeContainerDeviceType(cd ContainerDevices, t string) string

func EncodeContainerDevices

func EncodeContainerDevices(cd ContainerDevices) string

func EncodeNodeDevices

func EncodeNodeDevices(dlist []*api.DeviceInfo) string

func EncodePodDevices

func EncodePodDevices(checklist map[string]string, pd PodDevices) map[string]string

func EncodePodSingleDevice

func EncodePodSingleDevice(pd PodSingleDevice) string

func EraseNextDeviceTypeFromAnnotation

func EraseNextDeviceTypeFromAnnotation(dtype string, p corev1.Pod) error

func GetAllocatePodByNode

func GetAllocatePodByNode(ctx context.Context, nodeName string) (*corev1.Pod, error)

func GetContainerDeviceStrArray

func GetContainerDeviceStrArray(c ContainerDevices) []string

func GetNode

func GetNode(nodename string) (*corev1.Node, error)

func GetPendingPod

func GetPendingPod(ctx context.Context, node string) (*corev1.Pod, error)

func InitKlogFlags

func InitKlogFlags() *flag.FlagSet

func MarkAnnotationsToDelete

func MarkAnnotationsToDelete(devType string, nn string) error

func MarshalNodeDevices

func MarshalNodeDevices(dlist []*api.DeviceInfo) string

func PatchNodeAnnotations

func PatchNodeAnnotations(node *corev1.Node, annotations map[string]string) error

func PatchPodAnnotations

func PatchPodAnnotations(pod *corev1.Pod, annotations map[string]string) error

func UnMarshalNodeDevices

func UnMarshalNodeDevices(str string) ([]*api.DeviceInfo, error)

Types

type ContainerDevice

type ContainerDevice struct {
	// TODO current Idx cannot use, because EncodeContainerDevices method not encode this filed.
	Idx       int
	UUID      string
	Type      string
	Usedmem   int32
	Usedcores int32
}
type ContainerDevices struct {
   Devices []string `json:"devices,omitempty"`
}
type PodDevices struct {
   Containers []ContainerDevices `json:"containers,omitempty"`
}

type ContainerDeviceRequest

type ContainerDeviceRequest struct {
	Nums             int32
	Type             string
	Memreq           int32
	MemPercentagereq int32
	Coresreq         int32
}

type ContainerDeviceRequests

type ContainerDeviceRequests map[string]ContainerDeviceRequest

type ContainerDevices

type ContainerDevices []ContainerDevice

func DecodeContainerDevices

func DecodeContainerDevices(str string) (ContainerDevices, error)

func GetNextDeviceRequest

func GetNextDeviceRequest(dtype string, p corev1.Pod) (corev1.Container, ContainerDevices, error)

type DeviceConfig

type DeviceConfig struct {
	*spec.Config

	ResourceName *string
	DebugMode    *bool
}

type DeviceInfo

type DeviceInfo struct {
	ID           string
	Index        uint
	Count        int32
	Devmem       int32
	Devcore      int32
	Type         string
	Numa         int
	Health       bool
	DeviceVendor string
}

type DevicePluginConfigs

type DevicePluginConfigs struct {
	Nodeconfig []struct {
		Name                string  `json:"name"`
		Devicememoryscaling float64 `json:"devicememoryscaling"`
		Devicecorescaling   float64 `json:"devicecorescaling"`
		Devicesplitcount    uint    `json:"devicesplitcount"`
		Migstrategy         string  `json:"migstrategy"`
	} `json:"nodeconfig"`
}

type DeviceUsage

type DeviceUsage struct {
	ID        string
	Index     uint
	Used      int32
	Count     int32
	Usedmem   int32
	Totalmem  int32
	Totalcore int32
	Usedcores int32
	Numa      int
	Type      string
	Health    bool
}

type NodeInfo

type NodeInfo struct {
	ID      string
	Devices []DeviceInfo
}

type PodDeviceRequests

type PodDeviceRequests []ContainerDeviceRequests

type PodDevices

type PodDevices map[string]PodSingleDevice

func DecodePodDevices

func DecodePodDevices(checklist map[string]string, annos map[string]string) (PodDevices, error)

type PodSingleDevice

type PodSingleDevice []ContainerDevices

type ContainerAllDevices map[string]ContainerDevices.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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