utils

package
v4.2.0-dev1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DockerHubImagePrefix = "docker.io/"

	// ReasonImagePullBackOff when pod status is Pending as container image pull failed.
	ReasonImagePullBackOff = "ImagePullBackOff"
	// ReasonImageInspectError is error inspecting image.
	ReasonImageInspectError = "ImageInspectError"
	// ReasonErrImagePull is general image pull error.
	ReasonErrImagePull = "ErrImagePull"
	// ReasonRegistryUnavailable is the http error when pulling image from registry.
	ReasonRegistryUnavailable = "RegistryUnavailable"
)

Variables

This section is empty.

Functions

func CheckPodFailed

func CheckPodFailed(pod *corev1.Pod) error

CheckPodFailed checks if pod has failed or has terminated or is in an irrecoverable waiting state.

func CheckPodImageFailed

func CheckPodImageFailed(pod *corev1.Pod) error

CheckPodImageFailed checks if pod has failed or has terminated or is in an irrecoverable waiting state due to an image related error.

func ClusterNamespacedName

func ClusterNamespacedName(aeroCluster *asdbv1.AerospikeCluster) string

ClusterNamespacedName return namespaced name

func ContainsString

func ContainsString(slice []string, s string) bool

ContainsString returns true if a string exists in a slice of strings.

func Exec

func Exec(podNamespacedName types.NamespacedName, container string, cmd []string, kubeClient *kubernetes.Clientset,
	kubeConfig *rest.Config) (stdoutStr, stderrStr string, err error)

Exec executes a non-interactive command on a pod.

func GetAerospikeClusterRackLabelSelector

func GetAerospikeClusterRackLabelSelector(
	clName string, rackID int, rackRevision string,
) ls.Selector

func GetDesiredImage

func GetDesiredImage(
	aeroCluster *asdbv1.AerospikeCluster, containerName string,
) (string, error)

GetDesiredImage returns the desired image for the input containerName from the aeroCluster spec.

func GetHash

func GetHash(str string) (string, error)

GetHash return ripemd160 hash for given string

func GetNamespacedName

func GetNamespacedName(obj meta.Object) types.NamespacedName

func GetNamespacedNameForSTSOrConfigMap

func GetNamespacedNameForSTSOrConfigMap(
	aeroCluster *asdbv1.AerospikeCluster, rackIdentifier string,
) types.NamespacedName

func GetRackIDAndRevisionFromPodName

func GetRackIDAndRevisionFromPodName(clusterName, podName string) (rackID int, rackRevision string, err error)

GetRackIDAndRevisionFromPodName returns the rack id and revision from a given pod name.

func GetRackIDAndRevisionFromSTSName

func GetRackIDAndRevisionFromSTSName(clusterName, statefulSetName string) (rackID int, rackRevision string, err error)

GetRackIDAndRevisionFromSTSName gets rackID and rackRevision from the statefulset name. It assumes statefulset name is of format <cluster-name>-<rack-id> or <cluster-name>-<rack-id>-<rack-revision>

func GetRackIdentifier

func GetRackIdentifier(rackID int, rackRevision string) string

func IsImageEqual

func IsImageEqual(image1, image2 string) bool

IsImageEqual returns true if image name image1 is equal to image name image2.

func IsPVCTerminating

func IsPVCTerminating(pvc *corev1.PersistentVolumeClaim) bool

IsPVCTerminating returns true if pvc's DeletionTimestamp has been set

func IsPodReasonUnschedulable

func IsPodReasonUnschedulable(pod *corev1.Pod) (isPodUnschedulable bool, reason string)

func IsPodRunningAndReady

func IsPodRunningAndReady(pod *corev1.Pod) bool

IsPodRunningAndReady returns true if pod is in the PodRunning Phase, if it has a condition of PodReady. TODO: check if its is properly running, error crashLoop also passed in this

func IsPodTerminating

func IsPodTerminating(pod *corev1.Pod) bool

IsPodTerminating returns true if pod's DeletionTimestamp has been set

func LabelsForAerospikeBackupService

func LabelsForAerospikeBackupService(clName string) map[string]string

LabelsForAerospikeBackupService returns the labels for selecting the resources belonging to the given AerospikeBackupService CR name.

func LabelsForAerospikeCluster

func LabelsForAerospikeCluster(clName string) map[string]string

LabelsForAerospikeCluster returns the labels for selecting the resources belonging to the given AerospikeCluster CR name.

func LabelsForAerospikeClusterRack

func LabelsForAerospikeClusterRack(
	clName string, rackID int, rackRevision string,
) map[string]string

LabelsForAerospikeClusterRack returns the labels for specific rack

func LabelsForPodAntiAffinity

func LabelsForPodAntiAffinity(clName string) map[string]string

LabelsForPodAntiAffinity returns the labels to use for setting pod anti-affinity.

func Len32

func Len32[T any](v []T) int32

Len32 returns length of slice in int32 range.

func MergeLabels

func MergeLabels(operatorLabels, userLabels map[string]string) map[string]string

MergeLabels merges operator an user defined labels

func NamespacedName

func NamespacedName(namespace, name string) string

NamespacedName return namespaced name

func ParseDockerImageTag

func ParseDockerImageTag(tag string) (
	registry string, name string, version string,
)

ParseDockerImageTag parses input tag into registry, name and version.

func RemoveString

func RemoveString(slice []string, s string) (result []string)

RemoveString removes a string from a slice of strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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