utils

package
v1.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNodeName

func GetNodeName(pod *corev1.Pod) string

GetNodeName returns the Slurm node name

func GetOrdinal

func GetOrdinal(pod *corev1.Pod) int

GetOrdinal gets pod's ordinal. If pod has no ordinal, -1 is returned.

func GetParentName

func GetParentName(pod *corev1.Pod) string

GetParentName gets the name of pod's parent NodeSet. If pod has not parent, the empty string is returned.

func GetParentNameAndOrdinal

func GetParentNameAndOrdinal(pod *corev1.Pod) (string, int)

GetParentNameAndOrdinal gets the name of pod's parent NodeSet and pod's ordinal as extracted from its Name. If the Pod was not created by a NodeSet, its parent is considered to be empty string, and its ordinal is considered to be -1.

func GetPersistentVolumeClaimName

func GetPersistentVolumeClaimName(nodeset *slinkyv1beta1.NodeSet, claim *corev1.PersistentVolumeClaim, ordinal int) string

GetPersistentVolumeClaimName gets the name of PersistentVolumeClaim for a Pod with an ordinal index of ordinal. claim must be a PersistentVolumeClaim from nodeset's VolumeClaims template.

func GetPersistentVolumeClaims

func GetPersistentVolumeClaims(nodeset *slinkyv1beta1.NodeSet, pod *corev1.Pod) map[string]corev1.PersistentVolumeClaim

GetPersistentVolumeClaims gets a map of PersistentVolumeClaims to their template names, as defined in nodeset. The returned PersistentVolumeClaims are each constructed with a the name specific to the Pod. This name is determined by GetPersistentVolumeClaimName.

func GetPodName

func GetPodName(nodeset *slinkyv1beta1.NodeSet, ordinal int) string

GetPodName gets the name of nodeset's child Pod with an ordinal index of ordinal

func IsIdentityMatch

func IsIdentityMatch(nodeset *slinkyv1beta1.NodeSet, pod *corev1.Pod) bool

IsIdentityMatch returns true if pod has a valid identity and network identity for a member of nodeset.

func IsPodFromNodeSet

func IsPodFromNodeSet(nodeset *slinkyv1beta1.NodeSet, pod *corev1.Pod) bool

IsPodFromNodeSet returns if the name schema matches

func IsStorageMatch

func IsStorageMatch(nodeset *slinkyv1beta1.NodeSet, pod *corev1.Pod) bool

IsStorageMatch returns true if pod's Volumes cover the nodeset of PersistentVolumeClaims

func NewNodeSetPod

func NewNodeSetPod(
	nodeset *slinkyv1beta1.NodeSet,
	controller *slinkyv1beta1.Controller,
	ordinal int,
	revisionHash string,
) *corev1.Pod

NewNodeSetPod returns a new Pod conforming to the nodeset's Spec with an identity generated from ordinal.

func SetOwnerReferences

func SetOwnerReferences(r client.Client, ctx context.Context, object metav1.Object, clusterName string) error

SetOwnerReferences modifies the object with all NodeSets as non-controller owners.

func SplitActivePods

func SplitActivePods(pods []*corev1.Pod, partition int) (pods1, pods2 []*corev1.Pod)

SplitActivePods returns two list of pods partitioned by a number.

func SplitUnhealthyPods

func SplitUnhealthyPods(pods []*corev1.Pod) (unhealthyPods, healthyPods []*corev1.Pod)

SplitUnhealthyPods returns lists of healthy and unhealthy pods.

func UpdateIdentity

func UpdateIdentity(nodeset *slinkyv1beta1.NodeSet, pod *corev1.Pod)

UpdateIdentity updates pod's name, hostname, and subdomain, and StatefulSetPodNameLabel to conform to nodeset's name and headless service.

func UpdateStorage

func UpdateStorage(nodeset *slinkyv1beta1.NodeSet, pod *corev1.Pod)

UpdateStorage updates pod's Volumes to conform with the PersistentVolumeClaim of nodeset's templates. If pod has conflicting local Volumes these are replaced with Volumes that conform to the nodeset's templates.

Types

type ActivePods

type ActivePods []*corev1.Pod

ActivePods type allows custom sorting of pods so a controller can pick the best ones to delete.

func (ActivePods) Len

func (o ActivePods) Len() int

func (ActivePods) Less

func (o ActivePods) Less(i, j int) bool

Less compares two pods and returns true if the first one should be preferred for deletion.

func (ActivePods) Swap

func (o ActivePods) Swap(i, j int)

type PodsByCreationTimestamp

type PodsByCreationTimestamp []*corev1.Pod

PodsByCreationTimestamp sorts a list of Pods by creation timestamp, using their names as a tie breaker.

func (PodsByCreationTimestamp) Len

func (o PodsByCreationTimestamp) Len() int

func (PodsByCreationTimestamp) Less

func (o PodsByCreationTimestamp) Less(i, j int) bool

func (PodsByCreationTimestamp) Swap

func (o PodsByCreationTimestamp) Swap(i, j int)

Jump to

Keyboard shortcuts

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