Documentation
¶
Index ¶
- Constants
- Variables
- func CreateEmptyAllocationResponse(resourceReq *pluginapi.ResourceRequest, resourceName string) *pluginapi.ResourceAllocationResponse
- func GetAsyncWorkNameByPrefix(prefix, topic string) string
- func GetCgroupAsyncWorkName(cgroup, topic string) string
- func GetContainerAsyncWorkName(podUID, containerName, topic string) string
- func GetHintsFromExtraStateFile(podName, extraHintsStateFileAbsPath string, availableNUMAs machine.CPUSet, ...) (map[string]*pluginapi.ListOfTopologyHints, error)
- func GetKatalystQoSLevelFromResourceReq(qosConf *generic.QoSConfiguration, req *pluginapi.ResourceRequest, ...) (qosLevel string, err error)
- func GetMainContainer(pod *v1.Pod, mainContainerAnnotationKey string) string
- func GetNUMANodesCountToFitCPUReq(cpuReq float64, cpuTopology *machine.CPUTopology) (int, int, error)
- func GetNUMANodesCountToFitMemoryReq(memoryReq, bytesPerNUMA uint64, numaCount int) (int, uint64, error)
- func GetPodAggregatedRequestResource(req *pluginapi.ResourceRequest) (int, float64, error)
- func GetPodAggregatedRequestResourceByAnnotations(annotations map[string]string, resourceName v1.ResourceName, ...) (int, float64, error)
- func GetPodAggregatedRequestResourceMap(req *pluginapi.ResourceRequest, allowedResources sets.String) (map[v1.ResourceName]int, map[v1.ResourceName]float64, error)
- func GetQuantityFromResourceReq(req *pluginapi.ResourceRequest) (int, float64, error)
- func GetQuantityFromResourceRequests(resourceRequests map[string]float64, resourceName string, ...) (int, float64, error)
- func GetQuantityMapFromResourceReq(req *pluginapi.ResourceRequest, allowedResources sets.String) (map[v1.ResourceName]int, map[v1.ResourceName]float64, error)
- func GetTopologyAwareQuantityFromAssignments(assignments map[int]machine.CPUSet) []*pluginapi.TopologyAwareQuantity
- func GetTopologyAwareQuantityFromAssignmentsSize(assignments map[int]uint64) []*pluginapi.TopologyAwareQuantity
- func HintToIntArray(hint *pluginapi.TopologyHint) []int
- func IsAnyResourceQuantityExist(resourceRequests map[string]float64, resourceNames sets.String) bool
- func IsDebugPod(podAnnotations map[string]string, podDebugAnnoKeys []string) bool
- func IsNetworkAffinityRestricted(reqAnnotations map[string]string) bool
- func IsQuantityFromQRMDeclaration(podAnnotations map[string]string) bool
- func IsReallocation(podAnnotations map[string]string) (bool, string)
- func IsResourceQuantityExist(resourceRequests map[string]float64, resourceName string) bool
- func MakeTopologyAllocationResourceAllocationAnnotations(topologyAllocation v1alpha1.TopologyAllocation, ...) map[string]string
- func PackResourceHintsResponse(req *pluginapi.ResourceRequest, resourceName string, ...) (*pluginapi.ResourceHintsResponse, error)
- func PodInplaceUpdateResizing(req *pluginapi.ResourceRequest) bool
- type AllocationHandler
- type EnhancementHandler
- type HintHandler
- type ResourceEnhancementHandlerMap
Constants ¶
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" MetricNameGetAdviceFailed = "get_advice_failed" MetricNameGetAdviceFeatureNotSupported = "get_advice_feature_not_supported" MetricNameHandleAdvisorRespCalled = "handle_advisor_resp_called" MetricNameHandleAdvisorRespFailed = "handle_advisor_resp_failed" MetricNameAdvisorUnhealthy = "advisor_unhealthy" MetricNameCheckApplyV1Error = "check_apply_v1_error" MetricNameGetAccompanyResourceTopologyHintsFailed = "get_accompany_resource_topology_hints_failed" MetricNameAllocateAccompanyResourceFailed = "allocate_accompany_resource_failed" MetricNameAllocateAssociatedDeviceDuration = "allocate_associated_device_duration" MetricNameAllocateAssociatedDeviceFailed = "allocate_associated_device_failed" MetricNameGetAssociatedDeviceTopologyHintsFailed = "get_associated_device_topology_hints_failed" MetricNameAllocateFilterDuration = "allocate_filter_duration" MetricNameAllocateSortDuration = "allocate_sort_duration" MetricNameAllocateBindDuration = "allocate_bind_duration" MetricNameReleaseAccompanyResourceFailed = "release_accompany_resource_failed" MetricNameSyncResourcePackagePinnedCPUSetFailed = "sync_resource_package_pinned_cpuset_failed" MetricNameResourcePackagePinnedCPUSetSize = "resource_package_pinned_cpuset_size" MetricNameSyncNumaResourcePackageFailed = "sync_numa_resource_package_failed" // metrics for cpu plugin MetricNamePoolSize = "pool_size" MetricNameRealStateInvalid = "real_state_invalid" MetricNameCgroupPathNotFound = "cgroup_path_not_found" MetricNameCPUSetInvalid = "cpuset_invalid" MetricNameCPUSetOverlap = "cpuset_overlap" MetricNameOrphanContainer = "orphan_container" MetricNameGetMemBWPreferenceFailed = "get_mem_bw_preference_failed" MetricNameGetNUMAAllocatedMemBWFailed = "get_numa_allocated_mem_bw_failed" MetricNameSetExclusiveIRQCPUSize = "set_exclusive_irq_cpu_size" // 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" MetricNameMemoryHandleAdvisorMemoryHigh = "memory_handle_advisor_memory_high" MetricNameMemoryHandleAdvisorDropCache = "memory_handle_advisor_drop_cache" MetricNameMemoryHandleAdvisorCPUSetMems = "memory_handle_advisor_cpuset_mems" MetricNameMemoryHandlerAdvisorMemoryOffload = "memory_handler_advisor_memory_offloading" MetricNameMemoryHandlerAdvisorDyingMemcgReclaim = "memory_handler_advisor_dying_memcg_reclaim" MetricNameMemoryHandlerAdvisorMemoryOffloadTime = "memory_handler_advisor_memory_offloading_time" MetricNameMemoryHandlerAdvisorMemoryNUMAHeadroom = "memory_handler_advisor_memory_numa_headroom" 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" // metrics for some cases MetricNameHintAnnotationInconsistent = "hint_annotation_inconsistent" MetricNameHintAnnotationMismatch = "hint_annotation_mismatch" // metrics for numa allocation MetricNameMetricBasedNUMAAllocationEnabled = "metric_based_numa_allocation_enabled" MetricNameMetricBasedNUMAAllocationSuccess = "metric_based_numa_allocation_success" MetricNameCollectNUMAMetrics = "collect_numa_metrics" MetricNameNUMAMetricOverThreshold = "numa_metric_over_threshold" // metrics for irq tuning MetricNameIrqTuningEnabled = "irq_tuning_enabled" MetricNameIrqTuningPolicy = "irq_tuning_policy" MetricNameIrqTuningNicsCount = "irq_tuning_nics_count" MetricNameIrqTuningLowThroughputNicsCount = "irq_tuning_low_throughput_nics_count" MetricNameIrqTuningNormalThroughputNicsCount = "irq_tuning_normal_throughput_nics_count" MetricNameIrqTuningBalanceFair = "irq_tuning_balance_fair" MetricNameIrqTuningSetIrqAffinityFailed = "irq_tuning_set_irq_affinity_failed" MetricNameIrqTuningIrqAffintityInconsistent = "irq_tuning_irq_affinity_inconsistent" MetricNameIrqTuningRPSEnabled = "irq_tuning_rps_enabled" MetricNameIrqTuningNicThroughputClass = "irq_tuning_throughput_class" MetricNameIrqTuningSriovContainersCount = "irq_tuning_sriov_containers_count" MetricNameIrqTuningIrqAffForbiddenContainersCount = "irq_tuning_irq_aff_forbidden_containers_count" MetricNameIrqTuningNicIrqAffinityPolicy = "irq_tuning_nic_irq_affinity_policy" MetricNameIrqTuningNicExclusiveIrqCores = "irq_tuning_nic_exclusive_irq_cores" MetricNameIrqTuningTotalExclusiveIrqCores = "irq_tuning_total_exclusive_irq_cores" MetricNameIrqTuningNicIrqLoadBalance = "irq_tuning_nic_irq_load_balance" MetricNameIrqTuningNicExclusiveIrqCoresIrqUtilAvg = "irq_tuning_nic_exclusive_irq_cores_irq_util_avg" MetricNameIrqTuningNicExclusiveIrqCoresIrqUtilMax = "irq_tuning_nic_exclusive_irq_cores_irq_util_Max" MetricNameIrqTuningNicExclusiveIrqCoresIrqUtilMin = "irq_tuning_nic_exclusive_irq_cores_irq_util_Min" MetricNameIrqTuningNicExclusiveIrqCoresIrqUsage = "irq_tuning_nic_exclusive_irq_cores_irq_usage" MetricNameIrqTuningNicExclusiveIrqCoresCpuUtilAvg = "irq_tuning_nic_exclusive_irq_cores_cpu_util_avg" MetricNameIrqTuningNicExclusiveIrqCoresCpuUtilMax = "irq_tuning_nic_exclusive_irq_cores_cpu_util_Max" MetricNameIrqTuningNicExclusiveIrqCoresCpuUtilMin = "irq_tuning_nic_exclusive_irq_cores_cpu_util_Min" MetricNameIrqTuningNicExclusiveIrqCoresCpuUsage = "irq_tuning_nic_exclusive_irq_cores_cpu_usage" MetricNameIrqTuningErr = "irq_tuning_err" )
const ( OCIPropertyNameCPUSetCPUs = "CpusetCpus" OCIPropertyNameCPUSetMems = "CpusetMems" OCIPropertyNameMemoryLimitInBytes = "MemoryLimitInBytes" )
those are OCI property names to be used by QRM plugins
const ( //[TODO]: move them to apiserver PodAnnotationQuantityFromQRMDeclarationKey = "qrm.katalyst.kubewharf.io/quantity-from-qrm-declaration" PodAnnotationQuantityFromQRMDeclarationTrue = "true" PodAnnotationResourceReallocationKey = "qrm.katalyst.kubewharf.io/resource-reallocation" )
const ( AdvisorRPCMetadataKeySupportsGetAdvice = "supports_get_advice" AdvisorRPCMetadataValueSupportsGetAdvice = "true" // resctrl related annotations AnnotationRdtClosID = "rdt.resources.beta.kubernetes.io/pod" AnnotationRdtNeedPodMonGroups = "rdt.resources.beta.kubernetes.io/need-mon-groups" )
const (
MetricTagNameInplaceUpdateResizing = "inplaceUpdateResizing"
)
const QRMPluginPolicyTagName = "policy"
const QRMTimeFormat = "2006-01-02 15:04:05.999999999 -0700 MST"
Variables ¶
var ErrNotImplemented = errors.New("not implemented")
Functions ¶
func CreateEmptyAllocationResponse ¶ added in v0.5.41
func CreateEmptyAllocationResponse(resourceReq *pluginapi.ResourceRequest, resourceName string) *pluginapi.ResourceAllocationResponse
CreateEmptyAllocationResponse creates an empty allocation response
func GetAsyncWorkNameByPrefix ¶ added in v0.5.1
func GetCgroupAsyncWorkName ¶ added in v0.5.1
func GetContainerAsyncWorkName ¶ added in v0.3.0
func GetHintsFromExtraStateFile ¶
func GetHintsFromExtraStateFile(podName, extraHintsStateFileAbsPath string, availableNUMAs machine.CPUSet, requestedResources []v1.ResourceName, ) (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, podAnnotationKeptKeys, podLabelKeptKeys []string, ) (qosLevel string, err error)
GetKatalystQoSLevelFromResourceReq retrieves QoS Level for a given request
func GetMainContainer ¶ added in v0.5.43
GetMainContainer returns the name of main container
func GetNUMANodesCountToFitCPUReq ¶
func GetNUMANodesCountToFitCPUReq(cpuReq float64, 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 GetPodAggregatedRequestResource ¶ added in v0.5.9
func GetPodAggregatedRequestResource(req *pluginapi.ResourceRequest) (int, float64, error)
GetPodAggregatedRequestResource returns both integer and float64 quantities for the main resource in the pod request.
func GetPodAggregatedRequestResourceByAnnotations ¶ added in v0.5.49
func GetPodAggregatedRequestResourceByAnnotations(annotations map[string]string, resourceName v1.ResourceName, fallback func() (int, float64, error)) (int, float64, error)
GetPodAggregatedRequestResourceByAnnotations returns both integer and float64 quantities for the main resource based on annotations. If the annotations contain aggregated resource keys, those values are used; otherwise, it falls back to the fallback function. Returns an error if any calculation fails.
func GetPodAggregatedRequestResourceMap ¶ added in v0.5.48
func GetPodAggregatedRequestResourceMap(req *pluginapi.ResourceRequest, allowedResources sets.String) (map[v1.ResourceName]int, map[v1.ResourceName]float64, error)
GetPodAggregatedRequestResourceMap returns both integer and float64 quantities for all resources in the pod request. If the pod has aggregated resource annotations, those values are used; otherwise, it falls back to the original request quantities. Returns an error if any calculation fails.
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 GetQuantityFromResourceRequests ¶ added in v0.5.41
func GetQuantityMapFromResourceReq ¶ added in v0.5.48
func GetQuantityMapFromResourceReq(req *pluginapi.ResourceRequest, allowedResources sets.String) (map[v1.ResourceName]int, map[v1.ResourceName]float64, error)
GetQuantityMapFromResourceReq parses all resources quantity into maps of resources to 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 IsAnyResourceQuantityExist ¶ added in v0.5.49
func IsAnyResourceQuantityExist(resourceRequests map[string]float64, resourceNames sets.String) bool
IsAnyResourceQuantityExist returns true when any resource in the set exists in the request map and its quantity is greater than zero.
func IsDebugPod ¶ added in v0.2.0
IsDebugPod returns true if the pod annotations show up any configurable debug key
func IsNetworkAffinityRestricted ¶ added in v0.5.48
IsNetworkAffinityRestricted returns true if allocated network interface must have affinity with allocated numa
func IsQuantityFromQRMDeclaration ¶ added in v0.5.41
func IsReallocation ¶ added in v0.5.24
func IsResourceQuantityExist ¶ added in v0.5.49
IsResourceQuantityExist returns true when the resource exists in the request map and its quantity is greater than zero.
func MakeTopologyAllocationResourceAllocationAnnotations ¶ added in v0.5.49
func MakeTopologyAllocationResourceAllocationAnnotations(topologyAllocation v1alpha1.TopologyAllocation, topologyAllocationAnnotationKey string, ) map[string]string
MakeTopologyAllocationResourceAllocationAnnotations converts the topology allocation to annotations.
func PackResourceHintsResponse ¶
func PackResourceHintsResponse(req *pluginapi.ResourceRequest, resourceName string, resourceHints map[string]*pluginapi.ListOfTopologyHints, ) (*pluginapi.ResourceHintsResponse, error)
PackResourceHintsResponse returns the standard QRM ResourceHintsResponse
func PodInplaceUpdateResizing ¶ added in v0.5.9
func PodInplaceUpdateResizing(req *pluginapi.ResourceRequest) bool
Types ¶
type AllocationHandler ¶
type AllocationHandler func(context.Context, *pluginapi.ResourceRequest, bool) (*pluginapi.ResourceAllocationResponse, error)
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 ¶
type HintHandler func(context.Context, *pluginapi.ResourceRequest) (*pluginapi.ResourceHintsResponse, error)
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