utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateNodeGroup

func CalculateNodeGroup(nodes v1.NodeList, config danav1alpha1.NodeQuotaConfig, nodeGroup string) v1.ResourceList

CalculateNodeGroup calculates the resource list for a node group based on the provided nodes, NodeQuotaConfig, and node group name. It takes a context, a NodeList containing the nodes, the NodeQuotaConfig, and the node group name. It returns the calculated resource list (v1.ResourceList) for the node group.

func CalculateSecondaryNodeGroup

func CalculateSecondaryNodeGroup(ctx context.Context, r client.Client, nodegroup danav1alpha1.NodeGroup, config *danav1alpha1.NodeQuotaConfig) (error, v1.ResourceList)

CalculateSecondaryNodeGroup calculates the resource list for a secondary node group based on the provided nodegroup and NodeQuotaConfig. It takes a context, a client for making API requests, a nodegroup to calculate resources for, and the NodeQuotaConfig. It returns an error (if any occurred) and the calculated resource list (v1.ResourceList).

func DeleteExpiredReservedResources

func DeleteExpiredReservedResources(config *danav1alpha1.NodeQuotaConfig, logger logr.Logger)

DeleteExpiredReservedResources removes the expired reserved resources from the NodeQuotaConfig. It takes the NodeQuotaConfig to modify and a logger for logging informational messages.

func GetRootQuota

func GetRootQuota(r client.Client, ctx context.Context, root string) (v1.ResourceQuota, error)

GetRootQuota retrieves the resource quota for the root namespace with the specified name. It returns the root resource quota and any error encountered during retrieval.

func GetSubnamespaceFromList

func GetSubnamespaceFromList(name string, subnamespacelist danav1.SubnamespaceList) *danav1.Subnamespace

GetSubnamespaceFromList retrieves the subnamespace with the specified name from the given subnamespace list. It returns a pointer to the subnamespace if found, otherwise it returns nil.

func MergeTwoResourceList

func MergeTwoResourceList(resourcelist v1.ResourceList, resourcelist2 v1.ResourceList) v1.ResourceList

MergeTwoResourceList merges two resource lists into a single resource list. It combines the quantities of the same resources from both lists.

func ProcessSecondaryRoot

func ProcessSecondaryRoot(ctx context.Context, r client.Client, secondaryRoot danav1alpha1.NodeGroup, config *danav1alpha1.NodeQuotaConfig, rootSubnamespace string, logger logr.Logger) (danav1.Subnamespace, bool, error)

ProcessSecondaryRoot processes a secondary root node group and updates the corresponding Subnamespace object and add reserved resources to the config if needed. It takes a context, a client for making API requests, the secondary root node group, the NodeQuotaConfig, the root subnamespace, and a logger for logging informational messages. It returns an error (if any occurred) and the updated Subnamespace object (danav1.Subnamespace).

func UpdateProcessedSecondaryRoots

func UpdateProcessedSecondaryRoots(ctx context.Context, processedSecondaryRoots []danav1.Subnamespace, logger logr.Logger, client client.Client) error

UpdateProcessedSecondaryRoots updates the secondaryRoots in the cluster with the new quantity of resources. It takes slice of Subnamespaces that was updated in memory and does API requests to commit the update.

func UpdateRootSubnamespace

func UpdateRootSubnamespace(ctx context.Context, rootResources v1.ResourceList, rootSubnamespace danav1alpha1.SubnamespacesRoots, logger logr.Logger, client client.Client) error

UpdateRootSubnamespace updates the resourceQuota of the rootSubnamespace with the new quantity of resources.

Types

This section is empty.

Jump to

Keyboard shortcuts

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