util

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 19 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// common metrics for all types of qrm plugins
	MetricNameHeartBeat               = "heartbeat"
	MetricNameAllocateFailed          = "alloc_failed"
	MetricNameGetTopologyHintsFailed  = "get_topology_hints_failed"
	MetricNameRemovePodFailed         = "remove_pod_failed"
	MetricNameLWAdvisorServerFailed   = "lw_advisor_server_failed"
	MetricNameHandleAdvisorRespCalled = "handle_advisor_resp_called"
	MetricNameHandleAdvisorRespFailed = "handle_advisor_resp_failed"
	MetricNameLWRecvStuck             = "lw_recv_stuck"

	// metrics for cpu plugin
	MetricNamePoolSize         = "pool_size"
	MetricNameRealStateInvalid = "real_state_invalid"
	MetricNameCPUSetInvalid    = "cpuset_invalid"
	MetricNameCPUSetOverlap    = "cpuset_overlap"

	// metrics for memory plugin
	MetricNameMemSetInvalid                           = "memset_invalid"
	MetricNameMemSetOverlap                           = "memset_overlap"
	MetricNameNodeMemsetInvalid                       = "node_memset_invalid"
	MetricNameMemoryHandleAdvisorContainerEntryFailed = "memory_handle_advisor_container_entry_failed"
	MetricNameMemoryHandleAdvisorExtraEntryFailed     = "memory_handle_advisor_extra_entry_failed"
	MetricNameMemoryHandleAdvisorMemoryLimit          = "memory_handle_advisor_memory_limit"
	MetricNameMemoryHandleAdvisorDropCache            = "memory_handle_advisor_drop_cache"
	MetricNameMemoryHandleAdvisorCPUSetMems           = "memory_handle_advisor_cpuset_mems"
	MetricNameMemoryHandlerAdvisorMemoryOffload       = "memory_handler_advisor_memory_offloading"
	MetricNameMemoryOOMPriorityDeleteFailed           = "memory_oom_priority_delete_failed"
	MetricNameMemoryOOMPriorityUpdateFailed           = "memory_oom_priority_update_failed"
	MetricNameMemoryNumaBalance                       = "memory_handle_numa_balance"
	MetricNameMemoryNumaBalanceCost                   = "memory_numa_balance_cost"
	MetricNameMemoryNumaBalanceResult                 = "memory_numa_balance_result"
)
View Source
const (
	OCIPropertyNameCPUSetCPUs         = "CpusetCpus"
	OCIPropertyNameCPUSetMems         = "CpusetMems"
	OCIPropertyNameMemoryLimitInBytes = "MemoryLimitInBytes"
)

those are OCI property names to be used by QRM plugins

View Source
const QRMPluginPolicyTagName = "policy"
View Source
const QRMTimeFormat = "2006-01-02 15:04:05.999999999 -0700 MST"

Variables

This section is empty.

Functions

func GetAsyncWorkNameByPrefix added in v0.5.1

func GetAsyncWorkNameByPrefix(prefix, topic string) string

func GetCgroupAsyncWorkName added in v0.5.1

func GetCgroupAsyncWorkName(cgroup, topic string) string

func GetContainerAsyncWorkName added in v0.3.0

func GetContainerAsyncWorkName(podUID, containerName, topic string) string

func GetHintsFromExtraStateFile

func GetHintsFromExtraStateFile(podName, resourceName, extraHintsStateFileAbsPath string,
	availableNUMAs machine.CPUSet,
) (map[string]*pluginapi.ListOfTopologyHints, error)

GetHintsFromExtraStateFile if you want to specify cpuset.mems for specific pods (eg. for existing pods) when switching to katalyst the first time, you can provide an extra hints state file with content like below:

{
	"memoryEntries": {
		"dp-18a916b04c-bdc9d5fd9-8m7vr-0": "0-1",
		"dp-18a916b04c-bdc9d5fd9-h9tgp-0": "5,7",
		"dp-47320a8d77-f46d6cbc7-5r27s-0": "2-3",
		"dp-d7e988f508-5f66655c5-8n2tf-0": "4,6"
	},
}

func GetKatalystQoSLevelFromResourceReq

func GetKatalystQoSLevelFromResourceReq(qosConf *generic.QoSConfiguration, req *pluginapi.ResourceRequest) (qosLevel string, err error)

GetKatalystQoSLevelFromResourceReq retrieves QoS Level for a given request

func GetKubeletReservedQuantity added in v0.4.0

func GetKubeletReservedQuantity(resourceName string, klConfig *kubeletconfigv1beta1.KubeletConfiguration) (resource.Quantity, bool, error)

func GetNUMANodesCountToFitCPUReq

func GetNUMANodesCountToFitCPUReq(cpuReq int, cpuTopology *machine.CPUTopology) (int, int, error)

GetNUMANodesCountToFitCPUReq is used to calculate the amount of numa nodes we need if we try to allocate cpu cores among them, assuming that all numa nodes contain the same cpu capacity

func GetNUMANodesCountToFitMemoryReq

func GetNUMANodesCountToFitMemoryReq(memoryReq, bytesPerNUMA uint64, numaCount int) (int, uint64, error)

GetNUMANodesCountToFitMemoryReq is used to calculate the amount of numa nodes we need if we try to allocate memory among them, assuming that all numa nodes contain the same memory capacity

func GetQuantityFromResourceReq added in v0.2.0

func GetQuantityFromResourceReq(req *pluginapi.ResourceRequest) (int, float64, error)

GetQuantityFromResourceReq parses resources quantity into value, since pods with reclaimed_cores and un-reclaimed_cores have different representations, we may to adapt to both cases.

func GetTopologyAwareQuantityFromAssignments

func GetTopologyAwareQuantityFromAssignments(assignments map[int]machine.CPUSet) []*pluginapi.TopologyAwareQuantity

GetTopologyAwareQuantityFromAssignments returns TopologyAwareQuantity based on assignments

func GetTopologyAwareQuantityFromAssignmentsSize

func GetTopologyAwareQuantityFromAssignmentsSize(assignments map[int]uint64) []*pluginapi.TopologyAwareQuantity

GetTopologyAwareQuantityFromAssignmentsSize returns TopologyAwareQuantity based on assignments, and assignments will use resource size (instead of resource struct)

func HintToIntArray

func HintToIntArray(hint *pluginapi.TopologyHint) []int

HintToIntArray transforms TopologyHint to int slices

func IsDebugPod added in v0.2.0

func IsDebugPod(podAnnotations map[string]string, podDebugAnnoKeys []string) bool

IsDebugPod returns true if the pod annotations show up any configurable debug key

func PackResourceHintsResponse

func PackResourceHintsResponse(req *pluginapi.ResourceRequest, resourceName string,
	resourceHints map[string]*pluginapi.ListOfTopologyHints,
) (*pluginapi.ResourceHintsResponse, error)

PackResourceHintsResponse returns the standard QRM ResourceHintsResponse

Types

type AllocationHandler

AllocationHandler and HintHandler are used as standard functions for qrm plugins to acquire resource allocation/hint info

type EnhancementHandler added in v0.4.0

type EnhancementHandler func(ctx context.Context,
	emitter metrics.MetricEmitter,
	metaServer *metaserver.MetaServer,
	req interface{},
	podResourceEntries interface{}) error

EnhancementHandler is used as standard function for qrm plugins to do resource enhancement for the specific lifecycle phase of qrm

type HintHandler

AllocationHandler and HintHandler are used as standard functions for qrm plugins to acquire resource allocation/hint info

type ResourceEnhancementHandlerMap added in v0.4.0

type ResourceEnhancementHandlerMap map[apiconsts.QRMPhase]map[string]EnhancementHandler

ResourceEnhancementHandlerMap is used to store enhancement handlers for specific resource the first key is the lifecycle phase of qrm, like QRMPhaseGetTopologyHints, QRMPhaseRemovePod etc. the second key is the last level of enhancement key, like PodAnnotationMemoryEnhancementOOMPriority in memory enhancement

func (ResourceEnhancementHandlerMap) Register added in v0.4.0

func (r ResourceEnhancementHandlerMap) Register(
	phase apiconsts.QRMPhase, enhancementKey string, handler EnhancementHandler,
)

Register registers a handler for the specified phase and last level enhancement key

Jump to

Keyboard shortcuts

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