internal

package
v0.6.0-alpha.rbac Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPodFailedAndTimedOut

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

IsPodFailedAndTimedOut checks if the pod is failed and timed out.

Types

type ComponentBase

type ComponentBase struct {
	Client         client.Client
	Recorder       record.EventRecorder
	Cluster        *appsv1alpha1.Cluster
	ClusterVersion *appsv1alpha1.ClusterVersion    // building config needs the cluster version
	Component      *component.SynthesizedComponent // built synthesized component, replace it with component workload proto
	ComponentSet   ComponentSet
	Dag            *graph.DAG
	WorkloadVertex *ictrltypes.LifecycleVertex // DAG vertex of main workload object
}

func (*ComponentBase) AddResource

func (*ComponentBase) CreateResource

func (*ComponentBase) DeleteResource

func (*ComponentBase) GetCluster

func (c *ComponentBase) GetCluster() *appsv1alpha1.Cluster

func (*ComponentBase) GetClusterName

func (c *ComponentBase) GetClusterName() string

func (*ComponentBase) GetClusterVersion

func (c *ComponentBase) GetClusterVersion() *appsv1alpha1.ClusterVersion

func (*ComponentBase) GetConsensusSpec

func (c *ComponentBase) GetConsensusSpec() *appsv1alpha1.ConsensusSetSpec

func (*ComponentBase) GetDefinitionName

func (c *ComponentBase) GetDefinitionName() string

func (*ComponentBase) GetMatchingLabels

func (c *ComponentBase) GetMatchingLabels() client.MatchingLabels

func (*ComponentBase) GetName

func (c *ComponentBase) GetName() string

func (*ComponentBase) GetNamespace

func (c *ComponentBase) GetNamespace() string

func (*ComponentBase) GetPhase

func (*ComponentBase) GetSynthesizedComponent

func (c *ComponentBase) GetSynthesizedComponent() *component.SynthesizedComponent

func (*ComponentBase) NoopResource

func (*ComponentBase) PatchResource

func (c *ComponentBase) PatchResource(obj client.Object, objCopy client.Object, parent *ictrltypes.LifecycleVertex) *ictrltypes.LifecycleVertex

func (*ComponentBase) ResolveObjectsAction

func (c *ComponentBase) ResolveObjectsAction(reqCtx intctrlutil.RequestCtx, cli client.Client) error

ResolveObjectsAction resolves the action of objects in dag to guarantee that all object actions will be determined.

func (*ComponentBase) SetStatusPhase

func (c *ComponentBase) SetStatusPhase(phase appsv1alpha1.ClusterComponentPhase,
	statusMessage appsv1alpha1.ComponentMessageMap, phaseTransitionMsg string)

SetStatusPhase sets the cluster component phase and messages conditionally.

func (*ComponentBase) SetWorkload

func (c *ComponentBase) SetWorkload(obj client.Object, action *ictrltypes.LifecycleAction, parent *ictrltypes.LifecycleVertex)

func (*ComponentBase) StatusWorkload

func (c *ComponentBase) StatusWorkload(reqCtx intctrlutil.RequestCtx, cli client.Client, obj client.Object, txn *statusReconciliationTxn) error

func (*ComponentBase) UpdatePDB

func (c *ComponentBase) UpdatePDB(reqCtx intctrlutil.RequestCtx, cli client.Client) error

func (*ComponentBase) UpdateResource

func (*ComponentBase) UpdateService

func (c *ComponentBase) UpdateService(reqCtx intctrlutil.RequestCtx, cli client.Client) error

func (*ComponentBase) ValidateObjectsAction

func (c *ComponentBase) ValidateObjectsAction() error

ValidateObjectsAction validates the action of objects in dag has been determined.

type ComponentSet

type ComponentSet interface {
	// IsRunning when relevant k8s workloads changes, it checks whether the component is running.
	// you can also reconcile the pods of component till the component is Running here.
	IsRunning(ctx context.Context, obj client.Object) (bool, error)

	// PodsReady checks whether all pods of the component are ready.
	// it means the pods are available in StatefulSet or Deployment.
	PodsReady(ctx context.Context, obj client.Object) (bool, error)

	// PodIsAvailable checks whether a pod of the component is available.
	// if the component is Stateless/StatefulSet, the available conditions follows as:
	// 1. the pod is ready.
	// 2. readyTime reached minReadySeconds.
	// if the component is ConsensusSet,it will be available when the pod is ready and labeled with its role.
	PodIsAvailable(pod *corev1.Pod, minReadySeconds int32) bool

	// GetPhaseWhenPodsReadyAndProbeTimeout when the pods of component are ready but the probe timed-out,
	//  calculate the component phase is Failed or Abnormal.
	GetPhaseWhenPodsReadyAndProbeTimeout(pods []*corev1.Pod) (v1alpha1.ClusterComponentPhase, v1alpha1.ComponentMessageMap)

	// GetPhaseWhenPodsNotReady when the pods of component are not ready, calculate the component phase is Failed or Abnormal.
	// if return an empty phase, means the pods of component are ready and skips it.
	GetPhaseWhenPodsNotReady(ctx context.Context, componentName string, originPhaseIsUpRunning bool) (v1alpha1.ClusterComponentPhase, v1alpha1.ComponentMessageMap, error)

	HandleRestart(ctx context.Context, obj client.Object) ([]graph.Vertex, error)

	HandleRoleChange(ctx context.Context, obj client.Object) ([]graph.Vertex, error)
}

type ComponentSetBase

type ComponentSetBase struct {
	Cli                  client.Client
	Cluster              *v1alpha1.Cluster
	SynthesizedComponent *component.SynthesizedComponent
	ComponentSpec        *v1alpha1.ClusterComponentSpec       // for test cases used only
	ComponentDef         *v1alpha1.ClusterComponentDefinition // for test cases used only
}

ComponentSetBase is a common component set base struct.

type ComponentWorkloadBuilder

type ComponentWorkloadBuilder interface {
	//	runtime, config, script, env, volume, service, monitor, probe
	BuildEnv() ComponentWorkloadBuilder
	BuildConfig() ComponentWorkloadBuilder
	BuildWorkload() ComponentWorkloadBuilder
	BuildPDB() ComponentWorkloadBuilder
	BuildVolumeMount() ComponentWorkloadBuilder
	BuildService() ComponentWorkloadBuilder
	BuildHeadlessService() ComponentWorkloadBuilder
	BuildTLSCert() ComponentWorkloadBuilder
	BuildTLSVolume() ComponentWorkloadBuilder

	Complete() error
}

type ComponentWorkloadBuilderBase

type ComponentWorkloadBuilderBase struct {
	ReqCtx          intctrlutil.RequestCtx
	Client          client.Client
	Comp            types.Component
	DefaultAction   *ictrltypes.LifecycleAction
	ConcreteBuilder ComponentWorkloadBuilder
	Error           error
	EnvConfig       *corev1.ConfigMap
	Workload        client.Object
	LocalObjs       []client.Object // cache the objects needed for configuration, should remove this after refactoring the configuration
}

func (*ComponentWorkloadBuilderBase) BuildConfig

func (*ComponentWorkloadBuilderBase) BuildEnv

func (*ComponentWorkloadBuilderBase) BuildHeadlessService

func (b *ComponentWorkloadBuilderBase) BuildHeadlessService() ComponentWorkloadBuilder

func (*ComponentWorkloadBuilderBase) BuildPDB

func (*ComponentWorkloadBuilderBase) BuildService

func (*ComponentWorkloadBuilderBase) BuildTLSCert

func (*ComponentWorkloadBuilderBase) BuildTLSVolume

func (*ComponentWorkloadBuilderBase) BuildVolumeMount

func (*ComponentWorkloadBuilderBase) BuildWorkload4StatefulSet

func (b *ComponentWorkloadBuilderBase) BuildWorkload4StatefulSet(workloadType string) ComponentWorkloadBuilder

func (*ComponentWorkloadBuilderBase) BuildWrapper

func (b *ComponentWorkloadBuilderBase) BuildWrapper(buildfn func() ([]client.Object, error)) ComponentWorkloadBuilder

func (*ComponentWorkloadBuilderBase) Complete

func (b *ComponentWorkloadBuilderBase) Complete() error

type StatefulComponentBase

type StatefulComponentBase struct {
	ComponentBase
	// contains filtered or unexported fields
}

StatefulComponentBase as a base class for single stateful-set based component (stateful & replication & consensus).

func (*StatefulComponentBase) Create

func (*StatefulComponentBase) Delete

func (*StatefulComponentBase) ExpandVolume

func (c *StatefulComponentBase) ExpandVolume(reqCtx intctrlutil.RequestCtx, cli client.Client) error

func (*StatefulComponentBase) GetBuiltObjects

func (c *StatefulComponentBase) GetBuiltObjects(builder ComponentWorkloadBuilder) ([]client.Object, error)

func (*StatefulComponentBase) HorizontalScale

func (c *StatefulComponentBase) HorizontalScale(reqCtx intctrlutil.RequestCtx, cli client.Client) error

func (*StatefulComponentBase) Restart

func (*StatefulComponentBase) Status

func (*StatefulComponentBase) Update

Jump to

Keyboard shortcuts

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