resourcepackage

package
v0.5.50 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricScope = "resource-package"
)
View Source
const (
	OwnerPoolNameSeparator = "/"
)

Variables

This section is empty.

Functions

func ConvertResourcePackagesToNPDMetrics

func ConvertResourcePackagesToNPDMetrics(resourcePackageMetrics []ResourcePackageMetric, timestamp metav1.Time) []nodev1alpha1.ScopedNodeMetrics

ConvertResourcePackagesToNPDMetrics converts resource packages to NPD metrics. converted npd metrics are sorted by packageName, numaID, and metricName

func GetMatchedPackages added in v0.5.49

func GetMatchedPackages[T ResourcePackageState](states map[string]T, selector labels.Selector) sets.String

GetMatchedPackages returns a set of package names that match the given selector.

func GetMatchedPinnedCPUSet added in v0.5.49

func GetMatchedPinnedCPUSet[T ResourcePackageState](states map[string]T, selector labels.Selector) machine.CPUSet

GetMatchedPinnedCPUSet returns the union of PinnedCPUSets from resource packages that match the given selector.

func GetNUMAMatchedPinnedCPUSet added in v0.5.49

func GetNUMAMatchedPinnedCPUSet[T ResourcePackageState](numaStates map[int]map[string]T, selector labels.Selector) map[int]machine.CPUSet

GetNUMAMatchedPinnedCPUSet returns a map of NUMA ID to the union of PinnedCPUSets from resource packages that match the selector.

func GetOwnerPoolName added in v0.5.49

func GetOwnerPoolName(ownerPoolName string) string

GetOwnerPoolName extracts the base owner pool name from a potentially wrapped name. It ignores the package name suffix if present.

func GetResourcePackageName

func GetResourcePackageName(annotations map[string]string) string

GetResourcePackageName retrieves the resource package name from pod annotations. It looks for the key "katalyst.kubewharf.io/resource_package" in the annotations map.

Parameters:

  • annotations: A map of pod annotations where to look for the resource package name.

Returns:

  • string: The resource package name if found, otherwise an empty string.

func ResourcePackageSuffixTranslatorWrapper added in v0.5.49

func ResourcePackageSuffixTranslatorWrapper(translator general.SuffixTranslator) general.SuffixTranslator

ResourcePackageSuffixTranslatorWrapper wraps a SuffixTranslator to handle resource package names in owner pool names. It ensures that the translation logic is applied to the base owner pool name, stripping the package suffix first.

func UnwrapOwnerPoolName added in v0.5.49

func UnwrapOwnerPoolName(ownerPoolName string) (string, string)

UnwrapOwnerPoolName unwraps the owner pool name to get the original owner pool name and the package name. It splits the string by the last occurrence of the separator.

Returns:

  • string: The original owner pool name (suffix).
  • string: The package name (prefix).

func WrapOwnerPoolName added in v0.5.49

func WrapOwnerPoolName(ownerPoolName, pkgName string) string

WrapOwnerPoolName wraps the owner pool name with the package name. If the package name is empty, it returns the owner pool name as is. Otherwise, it prepends the package name to the owner pool name with a separator. Format: <pkgName>/<ownerPoolName>

Types

type NUMAResourcePackageItems added in v0.5.43

type NUMAResourcePackageItems map[int]map[string]ResourcePackageItem

func (NUMAResourcePackageItems) GetAllPinnedCPUSetSizeSum added in v0.5.49

func (r NUMAResourcePackageItems) GetAllPinnedCPUSetSizeSum() (map[int]int, error)

GetAllPinnedCPUSetSizeSum calculates the total size of pinned CPU sets for each NUMA node. It sums up the CPU values of all pinned packages per NUMA node.

func (NUMAResourcePackageItems) GetAttributesMap added in v0.5.49

func (r NUMAResourcePackageItems) GetAttributesMap(numaID int, pkgName string) map[string]string

GetAttributesMap retrieves the attributes map for a specific resource package on a NUMA node. It returns a map of string to string, or nil if no attributes are found.

func (NUMAResourcePackageItems) GetPinnedCPUSetSize added in v0.5.49

func (r NUMAResourcePackageItems) GetPinnedCPUSetSize(numaID int, pkgName string) (*int, error)

GetPinnedCPUSetSize returns the size of the pinned CPU set for a specific resource package. It checks if the package is configured to use a pinned CPU set and if it has allocatable resources.

Returns:

  • *int: The size of the pinned CPU set (number of CPUs), or nil if not pinned/configured.
  • error: An error if the item is not found or not properly configured.

func (NUMAResourcePackageItems) GetResourcePackageConfig added in v0.5.49

func (r NUMAResourcePackageItems) GetResourcePackageConfig(numaID int, pkgName string) (*ResourcePackageConfig, error)

GetResourcePackageConfig retrieves the configuration for a specific resource package on a NUMA node.

Parameters:

  • numaID: The ID of the NUMA node.
  • pkgName: The name of the resource package.

Returns:

  • *ResourcePackageConfig: The configuration if found.
  • error: An error if the receiver is nil, or if the NUMA ID or package name is not found.

func (NUMAResourcePackageItems) ListAllPinnedCPUSetSize added in v0.5.49

func (r NUMAResourcePackageItems) ListAllPinnedCPUSetSize() (map[int]map[string]int, error)

ListAllPinnedCPUSetSize lists the sizes of pinned CPU sets for all resource packages across all NUMA nodes. It filters out packages that do not have PinnedCPUSet enabled.

type ResourcePackageConfig added in v0.5.43

type ResourcePackageConfig struct {
	// PinnedCPUSet indicates whether the resource package is pinned to cpuset.
	PinnedCPUSet *bool `json:"pinnedCPUSet,omitempty"`
}

ResourcePackageConfig holds the configuration of a resource package.

type ResourcePackageItem added in v0.5.43

type ResourcePackageItem struct {
	nodev1alpha1.ResourcePackage `json:",inline"`
	// Config is the configuration of the resource package.
	Config *ResourcePackageConfig `json:"config,omitempty"`
}

ResourcePackageItem wraps the ResourcePackage and its configuration.

type ResourcePackageMetric

type ResourcePackageMetric struct {
	NumaID           string                `json:"numaID"`
	ResourcePackages []ResourcePackageItem `json:"resourcePackages"`
}

ResourcePackageMetric is the intermediate structure for resource package metrics.

func ConvertNPDMetricsToResourcePackages

func ConvertNPDMetricsToResourcePackages(metrics []nodev1alpha1.ScopedNodeMetrics) []ResourcePackageMetric

ConvertNPDMetricsToResourcePackages converts NPD metrics to resource packages. converted resource packages are sorted by packageName and numaID

type ResourcePackageState added in v0.5.49

type ResourcePackageState interface {
	GetAttributes() map[string]string
	GetPinnedCPUSet() machine.CPUSet
}

ResourcePackageState is an interface that provides methods to get the attributes and pinned CPUSet of a resource package. It is implemented by both qrm state.ResourcePackageState and sysadvisor types.ResourcePackageState, allowing generic utilities to work with both representations.

Jump to

Keyboard shortcuts

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