util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 30 Imported by: 18

Documentation

Index

Constants

View Source
const (
	CNRFieldNameNodeResourceProperties = "NodeResourceProperties"
	CNRFieldNameTopologyStatus         = "TopologyStatus"
	CNRFieldNameResourceAllocatable    = "ResourceAllocatable"
	CNRFieldNameResourceCapacity       = "ResourceCapacity"
)

those fields are used by in-tree reporter plugins to refer specific field names of CNR.

View Source
const (
	CNRKind = "CustomNodeResource"
)

Variables

Functions

func AddOrUpdateCNRTaint

func AddOrUpdateCNRTaint(cnr *apis.CustomNodeResource, taint *apis.Taint) (*apis.CustomNodeResource, bool, error)

AddOrUpdateCNRTaint tries to add a taint to annotations list. Returns a new copy of updated CNR and true if something was updated false otherwise.

func CNRTaintExists

func CNRTaintExists(taints []*apis.Taint, taintToFind *apis.Taint) bool

CNRTaintExists checks if the given taint exists in list of taints. Returns true if exists false otherwise.

func CheckCNRConditionMatched

func CheckCNRConditionMatched(curCondition *nodev1alpha1.CNRCondition, status corev1.ConditionStatus, reason, message string) bool

CheckCNRConditionMatched checks if current CNR condition matches the update condition

func CheckSPDMatchWithPod

func CheckSPDMatchWithPod(pod *core.Pod, spd *apiworkload.ServiceProfileDescriptor, workloadListerMap map[schema.GroupVersionKind]cache.GenericLister) bool

CheckSPDMatchWithPod checks whether the given pod and spd matches with each other

func CheckVPAStatusLegal

func CheckVPAStatusLegal(vpa *apis.KatalystVerticalPodAutoscaler, pods []*core.Pod) (bool, string, error)

CheckVPAStatusLegal checks following things and return a msg 1. recommended resource mustn't change pod qos class 2. recommended resource mustn't scale up in VPA 1.0 todo: remove this in VPA 2.0 3. recommended resource mustn't be negative if vpa status is illegal, we'll refuse update its status

func CheckWorkloadEnableVPA

func CheckWorkloadEnableVPA(runtimeObject runtime.Object) bool

CheckWorkloadEnableVPA is used to check whether the object enables VPA functionality

func CheckWorkloadSPDEnabled

func CheckWorkloadSPDEnabled(workload metav1.Object) bool

CheckWorkloadSPDEnabled checks if the given workload is enabled with service profiling.

func ConvertVPAContainerResourceToRecommendedContainerResources

func ConvertVPAContainerResourceToRecommendedContainerResources(resource apis.ContainerResources) apis.RecommendedContainerResources

ConvertVPAContainerResourceToRecommendedContainerResources converts apis.ContainerResources to apis.RecommendedContainerResources

func ConvertVPAContainerResourceToResourceRequirements

func ConvertVPAContainerResourceToResourceRequirements(containerResource apis.ContainerResources) core.ResourceRequirements

ConvertVPAContainerResourceToResourceRequirements converts target value in apis.ContainerResources to core.ResourceRequirements

func DeleteCNRTaint

func DeleteCNRTaint(taints []*apis.Taint, taintToDelete *apis.Taint) ([]*apis.Taint, bool)

DeleteCNRTaint removes all the taints that have the same key and effect to given taintToDelete.

func GenerateVPAPodResizePolicyAnnotations

func GenerateVPAPodResizePolicyAnnotations(pod *core.Pod, containerPolicies map[string]apis.ContainerResourcePolicy) (map[string]string, error)

GenerateVPAPodResizePolicyAnnotations returns mapping from containerName to policy

func GenerateVPAPodResizeResourceAnnotations

func GenerateVPAPodResizeResourceAnnotations(pod *core.Pod, podResources map[consts.PodContainerName]apis.ContainerResources,
	containerResources map[consts.ContainerName]apis.ContainerResources) (map[string]core.ResourceRequirements, error)

GenerateVPAPodResizeResourceAnnotations returns mapping from containerName to resourceRequirements by merging the given podResources and containerResources; and podResources is always superior to containerResources

func GenerateVPAPolicyMap

GenerateVPAPolicyMap returns vpa resource policy at container-level

func GenerateVPAResourceMap

GenerateVPAResourceMap returns the map of pod resources and container resources; the returned pod resources map use GeneratePodContainerName as key, and apis.ContainerResources as value the returned container resources map use GenerateContainerName as key, and apis.ContainerResources as value

func GetCNRCondition

func GetCNRCondition(status *apis.CustomNodeResourceStatus, conditionType apis.CNRConditionType) (int, *apis.CNRCondition)

GetCNRCondition extracts the provided condition from the given status and returns that. Returns nil and -1 if the condition is not present, and the index of the located condition.

func GetPodListForSPD

func GetPodListForSPD(spd *apiworkload.ServiceProfileDescriptor, podIndexer cache.Indexer, podLabelIndexKeyList []string,
	workloadLister cache.GenericLister, podLister corelisters.PodLister) ([]*core.Pod, error)

GetPodListForSPD is used to get pods that should be managed by the given spd, we'll always get through workload

func GetPodListForVPA

func GetPodListForVPA(vpa *apis.KatalystVerticalPodAutoscaler, podIndexer cache.Indexer, podLabelIndexKeyList []string,
	workloadLister cache.GenericLister, podLister corelisters.PodLister) ([]*core.Pod, error)

GetPodListForVPA is used to get pods that should be managed by the given vpa, we'll always get through workload

func GetSPDForPod

GetSPDForPod is used to get spd that should manage the given vpa, we'll try to find by annotation for pod, and then go through workload if not exist, and we will find it recursively since we don't know in which level the owner will be.

func GetSPDForVPA

GetSPDForVPA is used to get spd that matches with the workload belongs to the given vpa the preference is indexer --> GetSPDForWorkload

func GetSPDForWorkload

GetSPDForWorkload is used to get spd that should manage the given workload the preference is annotation ---> indexer --> lister

func GetVPAForPod

GetVPAForPod is used to get vpa that should manage the given vpa, we'll always get through workload, and we will find it recursively since we don't know in which level the owner will be.

func GetVPAForVPARec

GetVPAForVPARec is used to get vpa that should manage the given vpaRec

func GetVPAForWorkload

GetVPAForWorkload is used to get vpa that should manage the given workload

func GetVPARecForVPA

GetVPARecForVPA is used to get vpaRec that should be managed the given vpa

func GetWorkloadForSPD

func GetWorkloadForSPD(spd *apiworkload.ServiceProfileDescriptor, lister cache.GenericLister) (runtime.Object, error)

GetWorkloadForSPD is used to get workload that should be managed the given spd

func GetWorkloadForVPA

func GetWorkloadForVPA(vpa *apis.KatalystVerticalPodAutoscaler, workloadLister cache.GenericLister) (runtime.Object, error)

GetWorkloadForVPA is used to get workload that should be managed by the given vpa

func MatchCNRTaint

func MatchCNRTaint(taintToMatch, taint *apis.Taint) bool

MatchCNRTaint checks if the taint matches taintToMatch. Taints are unique by key:effect, if the two taints have same key:effect, regard as they match.

func RemoveCNRTaint

func RemoveCNRTaint(cnr *apis.CustomNodeResource, taint *apis.Taint) (*apis.CustomNodeResource, bool, error)

RemoveCNRTaint tries to remove a taint cnr taints. Returns a new copy of updated CNR and true if something was updated false otherwise.

func SPDTargetReferenceIndex

func SPDTargetReferenceIndex(obj interface{}) ([]string, error)

SPDTargetReferenceIndex is used to construct informer index for target reference in SPD

func SetCNRCondition

func SetCNRCondition(cnr *apis.CustomNodeResource, conditionType apis.CNRConditionType, status corev1.ConditionStatus, reason, message string, now metav1.Time)

SetCNRCondition set specific cnr condition.

func VPATargetReferenceIndex

func VPATargetReferenceIndex(obj interface{}) ([]string, error)

VPATargetReferenceIndex is used to construct informer index for target reference in VPA

Types

type KCCTargetResource

type KCCTargetResource struct {
	*unstructured.Unstructured
}

KCCTargetResource is used to provide util function to get detailed information about KCC Target fields.

func ToKCCTargetResource

func ToKCCTargetResource(obj *unstructured.Unstructured) KCCTargetResource

func (KCCTargetResource) CheckExpired

func (g KCCTargetResource) CheckExpired(now time.Time) bool

func (KCCTargetResource) CheckValid

func (g KCCTargetResource) CheckValid() bool

func (KCCTargetResource) DeepCopy

func (g KCCTargetResource) DeepCopy() KCCTargetResource

func (KCCTargetResource) GenerateConfigHash

func (g KCCTargetResource) GenerateConfigHash(length int) (string, error)

func (KCCTargetResource) GetCollisionCount

func (g KCCTargetResource) GetCollisionCount() *int32

func (KCCTargetResource) GetGenericStatus

func (g KCCTargetResource) GetGenericStatus() v1alpha1.GenericConfigStatus

func (KCCTargetResource) GetHash

func (g KCCTargetResource) GetHash() string

func (KCCTargetResource) GetLabelSelector

func (g KCCTargetResource) GetLabelSelector() string

func (KCCTargetResource) GetLastDuration

func (g KCCTargetResource) GetLastDuration() *time.Duration

func (KCCTargetResource) GetNodeNames

func (g KCCTargetResource) GetNodeNames() []string

func (KCCTargetResource) GetObservedGeneration

func (g KCCTargetResource) GetObservedGeneration() int64

func (KCCTargetResource) GetRevisionHistoryLimit

func (g KCCTargetResource) GetRevisionHistoryLimit() int64

func (KCCTargetResource) IsUpdated

func (g KCCTargetResource) IsUpdated() bool

func (KCCTargetResource) SetCollisionCount

func (g KCCTargetResource) SetCollisionCount(count *int32)

func (KCCTargetResource) SetGenericStatus

func (g KCCTargetResource) SetGenericStatus(status v1alpha1.GenericConfigStatus)

func (KCCTargetResource) SetHash

func (g KCCTargetResource) SetHash(hash string)

func (KCCTargetResource) SetObservedGeneration

func (g KCCTargetResource) SetObservedGeneration(generation int64)

func (KCCTargetResource) Unmarshal

func (g KCCTargetResource) Unmarshal(conf interface{}) error

Directories

Path Synopsis
cgroup

Jump to

Keyboard shortcuts

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