core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatePodSliceSize

func CalculatePodSliceSize(pods []*v1.Pod, replicas int) int

CalculatePodSliceSize compare max pod index with desired replicas and return larger size

func CalculateServiceSliceSize

func CalculateServiceSliceSize(services []*v1.Service, replicas int) int

CalculateServiceSliceSize compare max pod index with desired replicas and return larger size

func FilterPodsForReplicaType

func FilterPodsForReplicaType(pods []*v1.Pod, replicaType string) ([]*v1.Pod, error)

FilterPodsForReplicaType returns pods belong to a replicaType.

func FilterServicesForReplicaType

func FilterServicesForReplicaType(services []*v1.Service, replicaType string) ([]*v1.Service, error)

FilterServicesForReplicaType returns service belong to a replicaType.

func GenGeneralName

func GenGeneralName(clusterName string, rtype string, index string) string

func GetPodSlices

func GetPodSlices(pods []*v1.Pod, replicas int, logger *log.Entry) [][]*v1.Pod

GetPodSlices returns a slice, which element is the slice of pod. It gives enough information to caller to make decision to up/down scale resources.

func GetPortsFromCluster

func GetPortsFromCluster(spec *kubeclusterorgv1alpha1.ReplicaSpec, defaultContainerName string) (map[string]int32, error)

GetPortsFromCluster gets the ports of cluster container. Port could be nil, if distributed communication strategy doesn't need and no other ports that need to be exposed.

func GetServiceSlices

func GetServiceSlices(services []*v1.Service, replicas int, logger *log.Entry) [][]*v1.Service

GetServiceSlices returns a slice, which element is the slice of service. Assume the return object is serviceSlices, then serviceSlices[i] is an array of pointers to services corresponding to Services for replica i.

func InitializeReplicaStatuses

func InitializeReplicaStatuses(clusterStatus *kubeclusterorgv1alpha1.ClusterStatus, rtype kubeclusterorgv1alpha1.ReplicaType)

InitializeReplicaStatuses initializes the ReplicaStatuses for replica.

func MaxInt

func MaxInt(x, y int) int

func PastActiveDeadline

func PastActiveDeadline(runPolicy *v1alpha1.RunPolicy, clusterStatus v1alpha1.ClusterStatus) bool

PastActiveDeadline checks if cluster has ActiveDeadlineSeconds field set and if it is exceeded.

func PastBackoffLimit

func PastBackoffLimit(clusterName string, runPolicy *v1alpha1.RunPolicy,
	replicas map[v1alpha1.ReplicaType]*v1alpha1.ReplicaSpec, pods []*v1.Pod,
	podFilterFunc func(pods []*v1.Pod, replicaType string) ([]*v1.Pod, error)) (bool, error)

PastBackoffLimit checks if container restartCounts sum exceeds BackoffLimit this method applies only to pods when restartPolicy is one of OnFailure, Always or ExitCode

func RecordAbnormalPods

func RecordAbnormalPods(activePods []*v1.Pod, object runtime.Object, recorder record.EventRecorder)

RecordAbnormalPods records the active pod whose latest condition is not in True status.

func SetRestartPolicy

func SetRestartPolicy(podTemplateSpec *v1.PodTemplateSpec, spec *kubeclusterorgv1alpha1.ReplicaSpec)

SetRestartPolicy check the RestartPolicy defined in cluster spec and overwrite RestartPolicy in podTemplate if necessary

func UpdateClusterReplicaStatuses

func UpdateClusterReplicaStatuses(clusterStatus *kubeclusterorgv1alpha1.ClusterStatus, rtype kubeclusterorgv1alpha1.ReplicaType, pod *corev1.Pod)

UpdateClusterReplicaStatuses updates the ClusterReplicaStatuses according to the pod.

Types

This section is empty.

Jump to

Keyboard shortcuts

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