components

package
v0.6.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: AGPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ComponentPhaseTransition the event reason indicates that the component transits to a new phase.
	ComponentPhaseTransition = "ComponentPhaseTransition"

	// PodContainerFailedTimeout the timeout for container of pod failures, the component phase will be set to Failed/Abnormal after this time.
	PodContainerFailedTimeout = 10 * time.Second

	// PodScheduledFailedTimeout timeout for scheduling failure.
	PodScheduledFailedTimeout = 30 * time.Second
)
View Source
const NewRSAvailableReason = "NewReplicaSetAvailable"

NewRSAvailableReason is added in a deployment when its newest replica set is made available ie. the number of new pods that have passed readiness checks and run for at least minReadySeconds is at least the minimum available pods that need to run for the deployment.

Variables

This section is empty.

Functions

func ComposeRolePriorityMap added in v0.6.0

func ComposeRolePriorityMap(consensusSpec *appsv1alpha1.ConsensusSetSpec) map[string]int

ComposeRolePriorityMap generates a priority map based on roles.

func DefaultRole added in v0.6.0

func DefaultRole(i int32) string

DefaultRole is used to get the default role of the Pod of the Replication workload.

func GetClusterByObject added in v0.6.0

func GetClusterByObject(ctx context.Context,
	cli client.Client,
	obj client.Object) (*appsv1alpha1.Cluster, error)

GetClusterByObject gets cluster by related k8s workloads.

func GetComponentDefByCluster added in v0.6.0

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 added in v0.6.0

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 added in v0.6.0

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 GetComponentPodList added in v0.6.0

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 GetComponentPodListWithRole added in v0.6.0

func GetComponentPodListWithRole(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, compSpecName, role string) (*corev1.PodList, error)

GetComponentPodListWithRole gets the pod list with target role by cluster and componentName

func GetComponentStsMinReadySeconds added in v0.6.0

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 added in v0.6.0

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 GetPodListByStatefulSet added in v0.6.0

func GetPodListByStatefulSet(ctx context.Context, cli client.Client, stsObj *appsv1.StatefulSet) ([]corev1.Pod, error)

GetPodListByStatefulSet gets statefulSet pod list.

func HandleReplicationSetRoleChangeEvent added in v0.6.0

func HandleReplicationSetRoleChangeEvent(cli client.Client,
	reqCtx intctrlutil.RequestCtx,
	cluster *appsv1alpha1.Cluster,
	compName string,
	pod *corev1.Pod,
	newRole string) error

HandleReplicationSetRoleChangeEvent handles the role change event of the replication workload when switchPolicy is Noop.

func IsFailedOrAbnormal added in v0.6.0

func IsFailedOrAbnormal(phase appsv1alpha1.ClusterComponentPhase) bool

func IsMemberOf added in v0.6.0

func IsMemberOf(set *appsv1.StatefulSet, pod *corev1.Pod) bool

IsMemberOf tests if pod is a member of set.

func IsPodFailedAndTimedOut added in v0.6.0

func IsPodFailedAndTimedOut(pod *corev1.Pod) (bool, bool, string)

IsPodFailedAndTimedOut checks if the pod is failed and timed out.

func NewDeploymentReconciler added in v0.6.0

func NewDeploymentReconciler(mgr ctrl.Manager) error

func NewStatefulSetReconciler added in v0.6.0

func NewStatefulSetReconciler(mgr ctrl.Manager) error

func ParseParentNameAndOrdinal added in v0.6.0

func ParseParentNameAndOrdinal(s string) (string, int32)

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 PodIsAvailable added in v0.6.0

func PodIsAvailable(workloadType appsv1alpha1.WorkloadType, pod *corev1.Pod, minReadySeconds int32) bool

PodIsAvailable checks whether a pod is available with respect to the workload type. Deprecated: provide for ops request using, remove this interface later.

func SortPods added in v0.6.0

func SortPods(pods []corev1.Pod, priorityMap map[string]int, idLabelKey string)

SortPods sorts pods by their role priority

func UpdateConsensusSetRoleLabel added in v0.6.0

func UpdateConsensusSetRoleLabel(cli client.Client,
	reqCtx intctrlutil.RequestCtx,
	componentDef *appsv1alpha1.ClusterComponentDefinition,
	pod *corev1.Pod, role string) error

UpdateConsensusSetRoleLabel updates pod role label when internal container role changed

Types

type Component added in v0.6.0

type Component interface {
	GetName() string
	GetNamespace() string
	GetClusterName() string
	GetDefinitionName() string
	GetWorkloadType() appsv1alpha1.WorkloadType

	GetCluster() *appsv1alpha1.Cluster
	GetClusterVersion() *appsv1alpha1.ClusterVersion
	GetSynthesizedComponent() *component.SynthesizedComponent

	GetConsensusSpec() *appsv1alpha1.ConsensusSetSpec

	GetMatchingLabels() client.MatchingLabels

	GetPhase() appsv1alpha1.ClusterComponentPhase

	// GetBuiltObjects returns all objects that will be created by this component
	GetBuiltObjects(reqCtx intctrlutil.RequestCtx, cli client.Client) ([]client.Object, error)

	Create(reqCtx intctrlutil.RequestCtx, cli client.Client) error
	Delete(reqCtx intctrlutil.RequestCtx, cli client.Client) error
	Update(reqCtx intctrlutil.RequestCtx, cli client.Client) error
	Status(reqCtx intctrlutil.RequestCtx, cli client.Client) error

	Restart(reqCtx intctrlutil.RequestCtx, cli client.Client) error

	ExpandVolume(reqCtx intctrlutil.RequestCtx, cli client.Client) error

	HorizontalScale(reqCtx intctrlutil.RequestCtx, cli client.Client) error

	// TODO(impl): impl-related, replace them with component workload
	SetWorkload(obj client.Object, action *ictrltypes.LifecycleAction, parent *ictrltypes.LifecycleVertex)
	AddResource(obj client.Object, action *ictrltypes.LifecycleAction, parent *ictrltypes.LifecycleVertex) *ictrltypes.LifecycleVertex
}

func NewComponent added in v0.6.0

func NewComponent(reqCtx intctrlutil.RequestCtx,
	cli client.Client,
	definition *appsv1alpha1.ClusterDefinition,
	version *appsv1alpha1.ClusterVersion,
	cluster *appsv1alpha1.Cluster,
	clusterTpl *appsv1alpha1.ClusterTemplate,
	compName string,
	dag *graph.DAG) (Component, error)

type ComponentWorkload added in v0.6.0

type ComponentWorkload interface{}

type DescendingOrdinalSts added in v0.6.0

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 added in v0.6.0

type Plan struct {
	Start    *Step
	WalkFunc walkFunc
}

func (*Plan) WalkOneStep added in v0.6.0

func (p *Plan) WalkOneStep() (bool, error)

WalkOneStep process plan stepping @return isCompleted @return err

type Step added in v0.6.0

type Step struct {
	Obj       interface{}
	NextSteps []*Step
}

Jump to

Keyboard shortcuts

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