Documentation ¶
Index ¶
- Constants
- Variables
- func AvailableReplicasAreConsistent(componentReplicas, podCount, workloadAvailableReplicas int32) bool
- func ComponentRuntimeReqArgsCheck(cli client.Client, cluster *appsv1alpha1.Cluster, ...) error
- func ConvertToStatefulSet(obj client.Object) *appsv1.StatefulSet
- func DeleteStsPods(ctx context.Context, cli client.Client, sts *appsv1.StatefulSet) error
- func GetClusterByObject(ctx context.Context, cli client.Client, obj client.Object) (*appsv1alpha1.Cluster, error)
- func GetClusterComponentSpecByName(cluster appsv1alpha1.Cluster, compSpecName string) *appsv1alpha1.ClusterComponentSpec
- func GetCompPhaseByConditions(existLatestRevisionFailedPod bool, primaryReplicasAvailable bool, ...) appsv1alpha1.ClusterComponentPhase
- func GetCompRelatedObjectList(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (*corev1.PodList, error)
- func GetComponentDefByCluster(ctx context.Context, cli client2.ReadonlyClient, cluster appsv1alpha1.Cluster, ...) (*appsv1alpha1.ClusterComponentDefinition, error)
- func GetComponentDeployMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (minReadySeconds int32, err error)
- func GetComponentInfoByPod(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (componentName string, componentDef *appsv1alpha1.ClusterComponentDefinition, ...)
- func GetComponentMatchLabels(clusterName, componentName string) map[string]string
- func GetComponentPhase(isFailed, isAbnormal bool) appsv1alpha1.ClusterComponentPhase
- func GetComponentPhaseWhenPodsNotReady(podList *corev1.PodList, workload metav1.Object, ...) appsv1alpha1.ClusterComponentPhase
- func GetComponentPodList(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (*corev1.PodList, error)
- func GetComponentStatusMessageKey(kind, name string) string
- func GetComponentStsMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (minReadySeconds int32, err error)
- func GetComponentWorkloadMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (minReadySeconds int32, err error)
- func GetCustomLabelWorkloadKind() []string
- func GetObjectListByComponentName(ctx context.Context, cli client2.ReadonlyClient, cluster appsv1alpha1.Cluster, ...) error
- func GetObjectListByCustomLabels(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) error
- func GetPhaseWithNoAvailableReplicas(componentReplicas int32) appsv1alpha1.ClusterComponentPhase
- func GetPodListByStatefulSet(ctx context.Context, cli client.Client, stsObj *appsv1.StatefulSet) ([]corev1.Pod, error)
- func GetPodOwnerReferencesSts(ctx context.Context, cli client.Client, podObj *corev1.Pod) (*appsv1.StatefulSet, error)
- func InitClusterComponentStatusIfNeed(cluster *appsv1alpha1.Cluster, componentName string, ...) error
- func IsFailedOrAbnormal(phase appsv1alpha1.ClusterComponentPhase) bool
- func IsMemberOf(set *appsv1.StatefulSet, pod *corev1.Pod) bool
- func IsProbeTimeout(componentDef *appsv1alpha1.ClusterComponentDefinition, ...) bool
- func IsStsAndPodsRevisionConsistent(ctx context.Context, cli client.Client, sts *appsv1.StatefulSet) (bool, error)
- func MarkPrimaryStsToReconcile(ctx context.Context, cli client.Client, sts *appsv1.StatefulSet) error
- func ParseCustomLabelPattern(pattern string) (schema.GroupVersionKind, error)
- func ParseParentNameAndOrdinal(s string) (string, int32)
- func PatchGVRCustomLabels(ctx context.Context, cli client.Client, cluster *appsv1alpha1.Cluster, ...) error
- func SortPods(pods []corev1.Pod, priorityMap map[string]int, idLabelKey string)
- func StatefulSetOfComponentIsReady(sts *appsv1.StatefulSet, statefulStatusRevisionIsEquals bool, ...) bool
- func StatefulSetPodsAreReady(sts *appsv1.StatefulSet, targetReplicas int32) bool
- func UpdateObjLabel[T generics.Object, PT generics.PObject[T]](ctx context.Context, cli client.Client, obj T, labelKey, labelValue string) error
- type DescendingOrdinalSts
- type Plan
- type Step
- type WalkFunc
Constants ¶
const (
ComponentStatusDefaultPodName = "Unknown"
)
Variables ¶
var ( ErrReqCtrlClient = errors.New("required arg client.Client is nil") ErrReqClusterObj = errors.New("required arg *appsv1alpha1.Cluster is nil") ErrReqClusterComponentDefObj = errors.New("required arg *appsv1alpha1.ClusterComponentDefinition is nil") ErrReqClusterComponentSpecObj = errors.New("required arg *appsv1alpha1.ClusterComponentSpec is nil") )
Functions ¶
func AvailableReplicasAreConsistent ¶
func AvailableReplicasAreConsistent(componentReplicas, podCount, workloadAvailableReplicas int32) bool
AvailableReplicasAreConsistent checks if expected replicas number of component is consistent with the number of available workload replicas.
func ComponentRuntimeReqArgsCheck ¶
func ComponentRuntimeReqArgsCheck(cli client.Client, cluster *appsv1alpha1.Cluster, component *appsv1alpha1.ClusterComponentSpec) error
func ConvertToStatefulSet ¶
func ConvertToStatefulSet(obj client.Object) *appsv1.StatefulSet
func DeleteStsPods ¶
DeleteStsPods deletes pods of the StatefulSet manually
func GetClusterByObject ¶
func GetClusterByObject(ctx context.Context, cli client.Client, obj client.Object) (*appsv1alpha1.Cluster, error)
GetClusterByObject gets cluster by related k8s workloads.
func GetClusterComponentSpecByName ¶
func GetClusterComponentSpecByName(cluster appsv1alpha1.Cluster, compSpecName string) *appsv1alpha1.ClusterComponentSpec
GetClusterComponentSpecByName gets componentSpec from cluster with compSpecName.
func GetCompPhaseByConditions ¶
func GetCompPhaseByConditions(existLatestRevisionFailedPod bool, primaryReplicasAvailable bool, compReplicas, podCount, availableReplicas int32) appsv1alpha1.ClusterComponentPhase
GetCompPhaseByConditions gets the component phase according to the following conditions: 1. if the failed pod is not controlled by the latest revision, ignore it. 2. if the primary replicas are not available, the component is failed. 3. finally if expected replicas number of component is inconsistent with the number of available workload replicas, the component is abnormal.
func GetCompRelatedObjectList ¶
func GetCompRelatedObjectList(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, compName string, relatedWorkloads client.ObjectList) (*corev1.PodList, error)
GetCompRelatedObjectList gets the related pods and workloads of the component
func GetComponentDefByCluster ¶
func GetComponentDefByCluster(ctx context.Context, cli client2.ReadonlyClient, cluster appsv1alpha1.Cluster, compDefName string) (*appsv1alpha1.ClusterComponentDefinition, error)
GetComponentDefByCluster gets component from ClusterDefinition with compDefName
func GetComponentDeployMinReadySeconds ¶
func GetComponentDeployMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, componentName string) (minReadySeconds int32, err error)
GetComponentDeployMinReadySeconds gets the deployment minReadySeconds of the component.
func GetComponentInfoByPod ¶
func GetComponentInfoByPod(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, pod *corev1.Pod) (componentName string, componentDef *appsv1alpha1.ClusterComponentDefinition, err error)
GetComponentInfoByPod gets componentName and componentDefinition info by Pod.
func GetComponentMatchLabels ¶
GetComponentMatchLabels gets the labels for matching the cluster component
func GetComponentPhase ¶
func GetComponentPhase(isFailed, isAbnormal bool) appsv1alpha1.ClusterComponentPhase
func GetComponentPhaseWhenPodsNotReady ¶
func GetComponentPhaseWhenPodsNotReady(podList *corev1.PodList, workload metav1.Object, componentReplicas, availableReplicas int32, checkFailedPodRevision func(pod *corev1.Pod, workload metav1.Object) bool) appsv1alpha1.ClusterComponentPhase
GetComponentPhaseWhenPodsNotReady gets the component phase when pods of component are not ready.
func GetComponentPodList ¶
func GetComponentPodList(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, componentName string) (*corev1.PodList, error)
GetComponentPodList gets the pod list by cluster and componentName
func GetComponentStsMinReadySeconds ¶
func GetComponentStsMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, componentName string) (minReadySeconds int32, err error)
GetComponentStsMinReadySeconds gets the statefulSet minReadySeconds of the component.
func GetComponentWorkloadMinReadySeconds ¶
func GetComponentWorkloadMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, workloadType appsv1alpha1.WorkloadType, componentName string) (minReadySeconds int32, err error)
GetComponentWorkloadMinReadySeconds gets the workload minReadySeconds of the component.
func GetCustomLabelWorkloadKind ¶
func GetCustomLabelWorkloadKind() []string
GetCustomLabelWorkloadKind returns the kinds that support custom label.
func GetObjectListByComponentName ¶
func GetObjectListByComponentName(ctx context.Context, cli client2.ReadonlyClient, cluster appsv1alpha1.Cluster, objectList client.ObjectList, componentName string) error
GetObjectListByComponentName gets k8s workload list with component
func GetObjectListByCustomLabels ¶
func GetObjectListByCustomLabels(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, objectList client.ObjectList, matchLabels client.ListOption) error
GetObjectListByCustomLabels gets k8s workload list with custom labels
func GetPhaseWithNoAvailableReplicas ¶
func GetPhaseWithNoAvailableReplicas(componentReplicas int32) appsv1alpha1.ClusterComponentPhase
GetPhaseWithNoAvailableReplicas gets the component phase when the workload of component has no available replicas.
func GetPodListByStatefulSet ¶
func GetPodListByStatefulSet(ctx context.Context, cli client.Client, stsObj *appsv1.StatefulSet) ([]corev1.Pod, error)
GetPodListByStatefulSet gets statefulSet pod list.
func GetPodOwnerReferencesSts ¶
func GetPodOwnerReferencesSts(ctx context.Context, cli client.Client, podObj *corev1.Pod) (*appsv1.StatefulSet, error)
GetPodOwnerReferencesSts gets the owner reference statefulSet of the pod.
func InitClusterComponentStatusIfNeed ¶
func InitClusterComponentStatusIfNeed( cluster *appsv1alpha1.Cluster, componentName string, componentDef appsv1alpha1.ClusterComponentDefinition) error
InitClusterComponentStatusIfNeed Initialize the state of the corresponding component in cluster.status.components
func IsFailedOrAbnormal ¶
func IsFailedOrAbnormal(phase appsv1alpha1.ClusterComponentPhase) bool
func IsMemberOf ¶
func IsMemberOf(set *appsv1.StatefulSet, pod *corev1.Pod) bool
IsMemberOf tests if pod is a member of set.
func IsProbeTimeout ¶
func IsProbeTimeout(componentDef *appsv1alpha1.ClusterComponentDefinition, podsReadyTime *metav1.Time) bool
IsProbeTimeout checks if the application of the pod is probe timed out.
func IsStsAndPodsRevisionConsistent ¶
func IsStsAndPodsRevisionConsistent(ctx context.Context, cli client.Client, sts *appsv1.StatefulSet) (bool, error)
IsStsAndPodsRevisionConsistent checks if StatefulSet and pods of the StatefulSet have the same revision.
func MarkPrimaryStsToReconcile ¶
func MarkPrimaryStsToReconcile(ctx context.Context, cli client.Client, sts *appsv1.StatefulSet) error
MarkPrimaryStsToReconcile marks the primary statefulSet annotation to be reconciled.
func ParseCustomLabelPattern ¶
func ParseCustomLabelPattern(pattern string) (schema.GroupVersionKind, error)
ParseCustomLabelPattern parses the custom label pattern to GroupVersionKind.
func ParseParentNameAndOrdinal ¶
ParseParentNameAndOrdinal gets the name of cluster-component and StatefulSet's ordinal as extracted from its Name. If the StatefulSet's Name was not match a statefulSetRegex, its parent is considered to be empty string, and its ordinal is considered to be -1.
func PatchGVRCustomLabels ¶
func PatchGVRCustomLabels(ctx context.Context, cli client.Client, cluster *appsv1alpha1.Cluster, resource appsv1alpha1.GVKResource, componentName, labelKey, labelValue string) error
PatchGVRCustomLabels patches the custom labels to the object list of the specified GVK.
func StatefulSetOfComponentIsReady ¶
func StatefulSetOfComponentIsReady(sts *appsv1.StatefulSet, statefulStatusRevisionIsEquals bool, targetReplicas *int32) bool
StatefulSetOfComponentIsReady checks if statefulSet of component is ready.
func StatefulSetPodsAreReady ¶
func StatefulSetPodsAreReady(sts *appsv1.StatefulSet, targetReplicas int32) bool
StatefulSetPodsAreReady checks if all pods of statefulSet are ready.
Types ¶
type DescendingOrdinalSts ¶
type DescendingOrdinalSts []*appsv1.StatefulSet
DescendingOrdinalSts is a sort.Interface that Sorts a list of StatefulSet based on the ordinals extracted from the statefulSet.
type Plan ¶
func (*Plan) WalkOneStep ¶
WalkOneStep process plan stepping @return isCompleted @return err