helper

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package helper provides shared utilities for v2 validator containers.

Index

Constants

View Source
const AKSRdmaSharedResource = "rdma/hca_shared_devices_a"

AKSRdmaSharedResource is the extended resource the network operator's rdma-shared-device-plugin publishes on Mellanox RDMA nodes. Its name is pinned by recipes/components/network-operator/manifests/nic-cluster-policy-aks.yaml (resourceName hca_shared_devices_a). The resource is transport-agnostic — the same pool backs InfiniBand and RoCE — so nothing keyed off it is IB-specific. Both the deployment-phase RDMA fabric readiness gate and the NCCL performance consumer key off this exact resource, so it lives here as the single source of truth rather than a duplicated literal in each validator binary.

View Source
const GpuResourceName = "nvidia.com/gpu"

GpuResourceName is the Kubernetes resource name for NVIDIA GPUs.

View Source
const PCIMellanoxPresentLabel = "feature.node.kubernetes.io/pci-15b3.present"

PCIMellanoxPresentLabel is the NFD feature label marking nodes with a Mellanox (PCI vendor 15b3) NIC — the vendor NFD detects for any ConnectX card, whether it runs InfiniBand or RoCE, so this is an RDMA-capability marker, not an IB one. It is the nodeAffinity the AKS NicClusterPolicy uses to place the RDMA fabric (nic-cluster-policy-aks.yaml), so it identifies exactly the nodes that can ever advertise AKSRdmaSharedResource.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to the given bool value.

func FindSchedulableGpuNodes

func FindSchedulableGpuNodes(ctx context.Context, clientset kubernetes.Interface) ([]v1.Node, error)

FindSchedulableGpuNodes finds nodes that are schedulable and have allocatable GPU resources.

func GroupVersionResources

func GroupVersionResources(ctx context.Context, clientset kubernetes.Interface, gv string) (*metav1.APIResourceList, error)

GroupVersionResources fetches the APIResourceList for gv with the caller's context. DiscoveryInterface.ServerResourcesForGroupVersion issues its request with context.TODO() internally (client-go), so an unresponsive apiserver could outlive the validator timeout and hang until the Job is killed; issuing the same GET through the discovery REST client keeps the request cancelable. Fake discovery clients in tests expose no RESTClient — fall back to the interface method there (test-only, in-memory, no I/O).

func Int32Ptr

func Int32Ptr(i int32) *int32

Int32Ptr returns a pointer to the given int32 value.

func IsNodeGpuBusy

func IsNodeGpuBusy(ctx context.Context, client kubernetes.Interface, nodeName string) (bool, error)

IsNodeGpuBusy checks if any non-terminal pods on the specified node are currently using GPU resources.

func LoadPodFromTemplate

func LoadPodFromTemplate(templatePath string, data map[string]string) (*v1.Pod, error)

LoadPodFromTemplate reads and processes a pod template file with variable substitution.

func StrPtr

func StrPtr(s string) *string

StrPtr returns a pointer to the given string value.

func VerifyResource

func VerifyResource(ctx context.Context, clientset kubernetes.Interface, er recipe.ExpectedResource) error

VerifyResource checks that a single expected resource exists and is healthy. Supports Deployment, DaemonSet, StatefulSet, Service, ConfigMap, Secret.

Types

type GpuNode

type GpuNode struct {
	Node     v1.Node
	Cordoned bool
}

GpuNode pairs a GPU-capable node with its cordon (Spec.Unschedulable) state. Node-scoped checks that enumerate every GPU node (rather than only the schedulable cohort) need this to disclose cordoned nodes instead of silently narrowing coverage — see FindGpuNodes.

func FindGpuNodes

func FindGpuNodes(ctx context.Context, clientset kubernetes.Interface) ([]GpuNode, error)

FindGpuNodes finds every node with allocatable GPU resources, schedulable or cordoned. Use this (not FindSchedulableGpuNodes) for checks that report per-node results: a cordon must appear in the check's evidence as an explicit "skipped: cordoned" entry, not vanish from the node count — a spuriously narrowed passing check is the dangerous direction (#1668). Deliberate, durable exclusion from GPU service should instead be expressed via the GPU Operator's nvidia.com/gpu.deploy.operands=false node label, which removes the node from allocatable nvidia.com/gpu entirely (see docs/contributor/validator.md).

type PodLifecycle

type PodLifecycle struct {
	ClientSet kubernetes.Interface
	Namespace string
}

PodLifecycle handles creation, verification, and cleanup of a pod.

func (*PodLifecycle) CleanupPod

func (p *PodLifecycle) CleanupPod(ctx context.Context, pod *v1.Pod) error

CleanupPod deletes a pod.

func (*PodLifecycle) CreatePodFromTemplate

func (p *PodLifecycle) CreatePodFromTemplate(ctx context.Context, templatePath string, data map[string]string) (*v1.Pod, error)

CreatePodFromTemplate creates a pod from a YAML template file.

func (*PodLifecycle) GetPodLogs

func (p *PodLifecycle) GetPodLogs(ctx context.Context, pod *v1.Pod) (string, error)

GetPodLogs retrieves logs from a pod.

func (*PodLifecycle) WaitForPodByName

func (p *PodLifecycle) WaitForPodByName(ctx context.Context, podName string, timeout time.Duration) (*v1.Pod, error)

WaitForPodByName waits for a pod with the given name to be created in the namespace.

func (*PodLifecycle) WaitForPodRunning

func (p *PodLifecycle) WaitForPodRunning(ctx context.Context, pod *v1.Pod, timeout time.Duration) error

WaitForPodRunning waits for a pod to reach Running phase.

func (*PodLifecycle) WaitForPodSuccess

func (p *PodLifecycle) WaitForPodSuccess(ctx context.Context, v1Pod *v1.Pod, timeout time.Duration) error

WaitForPodSuccess waits for a pod to reach Succeeded phase.

Jump to

Keyboard shortcuts

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