util

package
v0.0.0-...-14a6586 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequeueInterval is the interval to requeue the request.
	RequeueInterval = 5 * time.Second
	// CFGExtension is the extension of the BFB configuration file.
	CFGExtension = "cfg"
	// DPUProvisioningLabelPrefix is the prefix for all DPU provisioning labels.
	DPUProvisioningLabelPrefix = "provisioning.dpu.nvidia.com/"
	// DPUNodeRebootMethodLabel is the label that specify the reboot method
	DPUNodeRebootMethodLabel = DPUProvisioningLabelPrefix + "reboot-method"
	// DPUNodeAdditionalDPURebootLabel is the label that should be added to a DPUNode to trigger an additional DPU reboot
	// after the BFB is installed.
	DPUNodeAdditionalDPURebootLabel = DPUProvisioningLabelPrefix + "dpu-reboot-after-install"
	// DPUNodeScriptNameLabel is the label that specify the script name for the custom script reboot method.
	DPUNodeScriptNameLabel = DPUProvisioningLabelPrefix + "script-name"
	// DPUSetNameLabel is the label that indicates the name of the DPUSet.
	DPUSetNameLabel = DPUProvisioningLabelPrefix + "dpuset-name"
	// DPUSetNamespaceLabel is the label that indicates the namespace of the DPUSet.
	DPUSetNamespaceLabel = DPUProvisioningLabelPrefix + "dpuset-namespace"
	// DPUNodeNameLabel is the label that indicates the name of the DPUNode the DPU is associated with.
	DPUNodeNameLabel = DPUProvisioningLabelPrefix + "dpunode-name"
	// DPUDeviceNameLabel is the label that indicates the name of the DPUDevice the DPU is associated with.
	DPUDeviceNameLabel = DPUProvisioningLabelPrefix + "dpudevice-name"
	// DPUDevicePCIAddressLabel is the label that indicates the PCI address of the DPU device.
	DPUDevicePCIAddressLabel = DPUProvisioningLabelPrefix + "dpudevice-pciAddress"
	// DPUDevicePSIDLabel is the label that indicates the PSID of the DPU device.
	DPUDevicePSIDLabel = DPUProvisioningLabelPrefix + "dpudevice-psid"
	// DPUDeviceOPNLabel is the label that indicates the OPN of the DPU device.
	DPUDeviceOPNLabel = DPUProvisioningLabelPrefix + "dpudevice-opn"
	// DPUDeviceNumOfPFsLabel is the label that indicates the number of PFs on the DPU device.
	DPUDeviceNumOfPFsLabel = DPUProvisioningLabelPrefix + "dpudevice-num-of-pfs"
	// DPUDevicePF0NameLabel is the label that indicates the name of the PF0 on the DPU device.
	DPUDevicePF0NameLabel = DPUProvisioningLabelPrefix + "dpudevice-pf0-name"
	// DPUDeviceBMCIPLabel is the label that indicates the BMC IP of the DPU device.
	DPUDeviceBMCIPLabel = DPUProvisioningLabelPrefix + "dpudevice-bmc-ip"
	// TolerationNotReadyKey is the key for the NotReady taint.
	TolerationNotReadyKey = "node.kubernetes.io/not-ready"
	// TolerationUnreachableKey is the key for the Unreachable taint.
	TolerationUnreachableKey = "node.kubernetes.io/unreachable"
	// TolerationUnschedulableKey is the key for the Unschedulable taint.
	TolerationUnschedulableKey = "node.kubernetes.io/unschedulable"
	// TolerationOVNKubernetesNetworkUnavailableKey is the key for the OVN Kubernetes NotReady taint.
	TolerationOVNKubernetesNetworkUnavailableKey = "k8s.ovn.org/network-unavailable"
	// DPUOOBBridgeConfiguredLabel is the label that indicates that the DPU OOB bridge is configured.
	DPUOOBBridgeConfiguredLabel = "dpu-oob-bridge-configured"
	// NodeFeatureDiscoveryLabelPrefix is the prefix for all NodeFeatureDiscovery labels.
	NodeFeatureDiscoveryLabelPrefix = "feature.node.kubernetes.io/"
	// NodeSelectorLabel is a label for linking Node with DPU.
	NodeSelectorLabel = NodeFeatureDiscoveryLabelPrefix + "dpu-enabled"
	// NodeMaintenanceRequestorID is the requestor ID used for NodeMaintenance CRs
	NodeMaintenanceRequestorID = "dpu.nvidia.com"
	// ProvisioningGroupName is the provisioning group, used to identify provisioning as
	// additional Requestors in NodeMaintenance CR.
	ProvisioningGroupName = "provisioning.dpu.nvidia.com"

	// PCIAddressTargetKey is the key for the PCI address in the metadata context.
	PCIAddressTargetKey = "target"

	OverrideDMSPodNameAnnotationKey = "provisioning.dpu.nvidia.com/override-dms-pod-name"

	// LastAppliedLabelsOnDPUKey is the key for the last applied labels.
	LastAppliedLabelsOnDPUKey = "provisioning.dpu.nvidia.com/last-applied-labels-on-dpu"

	HoldNodeEffectKey             = DPUProvisioningLabelPrefix + "wait-for-external-nodeeffect"
	TrustedSFCount                = DPUProvisioningLabelPrefix + "num-of-trusted-sfs"
	ProvisioningComponentLabelKey = DPUProvisioningLabelPrefix + "component"

	// DPU cluster version is one to one with DPF operator version, need to update this in each dpf release
	KubernetesVersion = "v1.33.0"
	// MaxNameLength is the maximum length of the name of the K8s resource.
	MaxNameLength = validation.DNS1123SubdomainMaxLength // 253

	// HostNameDPULabelKey is the label added to the DPU Kubernetes Node that indicates the hostname of the host that
	// this DPU belongs to.
	HostNameDPULabelKey = "provisioning.dpu.nvidia.com/host"
)

Variables

View Source
var (
	// Location of BFB binary files
	BFBBaseDir        = "bfb"
	KubeconfigBaseDir = "kubeconfig"
)

Functions

func AddLabelsToObject

func AddLabelsToObject(ctx context.Context, client crclient.Client, obj metav1.Object, labels map[string]string) error

AddLabelsToObject adds the given labels to any Kubernetes object implementing metav1.Object

func BuildContextWithTargetPCIAddress

func BuildContextWithTargetPCIAddress(ctx context.Context, pciAddressFromDPUObject string) context.Context

func CopyLabelsOrAnnotations

func CopyLabelsOrAnnotations(target, source map[string]string) map[string]string

CopyLabelsOrAnnotations merges source labels/annotations into target. If target is nil, it will be initialized.

func DPUCondition

func DPUCondition(condType provisioningv1.DPUConditionType, reason, message string) *metav1.Condition

func DeleteObjects

func DeleteObjects(ctx context.Context, client crclient.Client, objs ...crclient.Object) error

func GenerateBFBCFGFilePath

func GenerateBFBCFGFilePath(filename string) string

func GenerateBFBFilePath

func GenerateBFBFilePath(filename string) string

func GenerateBFBTMPFilePath

func GenerateBFBTMPFilePath(uid string) string

func GenerateBFBTaskName

func GenerateBFBTaskName(bfb provisioningv1.BFB) string

func GenerateBFCFGFileName

func GenerateBFCFGFileName(dpuName string, uid string) string

func GenerateBmcFwFilePath

func GenerateBmcFwFilePath(filename string) string

func GenerateDMSPodName

func GenerateDMSPodName(dpuNode crclient.Object) string

GenerateDMSPodName creates a name for the DMS pod based off the name of the passed object. This allows the passed object to be either a DPUNode or a corev1.Node.

func GenerateDMSServerCertName

func GenerateDMSServerCertName(dpuName string) string

func GenerateDMSServerSecretName

func GenerateDMSServerSecretName(dpuName string) string

func GenerateDPUName

func GenerateDPUName(dpuNodeName string, dpuDeviceName string) string

func GenerateNodeName

func GenerateNodeName(dpu *provisioningv1.DPU) string

func GetDPUCondition

func GetDPUCondition(status *provisioningv1.DPUStatus, conditionType string) (int, *metav1.Condition)

func GetNamespacedName

func GetNamespacedName(obj metav1.Object) types.NamespacedName

func GetObjects

func GetObjects(ctx context.Context, client crclient.Client, objects []crclient.Object) (existObjects []crclient.Object, err error)

func GetPCIAddrFromDPU

func GetPCIAddrFromDPU(dpu *provisioningv1.DPU, removePrefix bool) (string, error)

func GetRemovedLabels

func GetRemovedLabels(oldLabels, newLabels map[string]string) []string

GetRemovedLabels returns the labels that are present in oldLabels but not in newLabels

func IsClusterCreated

func IsClusterCreated(conditions []metav1.Condition) bool

func IsDPUAfterProvisioningPhase

func IsDPUAfterProvisioningPhase(phase provisioningv1.DPUPhase) bool

func IsDPUBeforeProvisioningPhase

func IsDPUBeforeProvisioningPhase(phase provisioningv1.DPUPhase) bool

func IsDPUInProvisioningPhase

func IsDPUInProvisioningPhase(phase provisioningv1.DPUPhase) bool

IsDPUInProvisioningPhase returns true if the phase is between Pending (exclusive) and OSInstalling

func IsNodeReady

func IsNodeReady(node *corev1.Node) bool

func MarshalJSON

func MarshalJSON(obj interface{}) (string, error)

func NeedUpdateLabels

func NeedUpdateLabels(label1 map[string]string, label2 map[string]string) bool

NeedUpdateLabels compares two labels. If label 2 does not contain all the key-value pairs of label 1, then return true. otherwise return false

func NewCondition

func NewCondition(condType string, err error, reason, message string) *metav1.Condition

NewCondition creates a new metav1.Condition with the given parameters. todo: merge with DPUCondition()

func RemoteExec

func RemoteExec(ns, name, container, cmd string) (string, string, error)

func ReplaceDaemonSetPodNodeNameNodeAffinity

func ReplaceDaemonSetPodNodeNameNodeAffinity(affinity *corev1.Affinity, nodename string) *corev1.Affinity

ReplaceDaemonSetPodNodeNameNodeAffinity replaces the RequiredDuringSchedulingIgnoredDuringExecution NodeAffinity of the given affinity with a new NodeAffinity that selects the given nodeName. Note that this function assumes that no NodeAffinity conflicts with the selected nodeName.

This method is copied from https://github.com/kubernetes/kubernetes/blob/dbc2b0a5c7acc349ea71a14e49913661eaf708d2/pkg/controller/daemon/util/daemonset_util.go#L176

func SetDPUCondition

func SetDPUCondition(status *provisioningv1.DPUStatus, condition *metav1.Condition) bool

func UpdateLabelsToNode

func UpdateLabelsToNode(ctx context.Context, client crclient.Client, node *corev1.Node, labels map[string]string) error

UpdateLabelsToNode updates the labels of the given node. It will add the new labels and remove the labels that are not in the new labels. It will also update the last applied labels annotation.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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