sub_controller

package
v0.0.0-...-1db0c69 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FEMetaPathKey        = "meta_dir"
	FELogStoreName       = "fe-log"
	FEMetaStoreName      = "fe-meta"
	BELogStoreName       = "be-log"
	BECacheStorePreName  = "be-storage"
	MSLogStoreName       = "ms-log"
	DefaultCacheRootPath = "/opt/apache-doris/be/file_cache"
	//default cache storage size: unit=B
	DefaultCacheSize               int64 = 107374182400
	FileCachePathKey                     = "file_cache_path"
	FileCacheSubConfigPathKey            = "path"
	FileCacheSubConfigTotalSizeKey       = "total_size"
)
View Source
const (
	StatefulSetNotExist     = "StatefulSetNotExist"
	AutoScalerDeleteFailed  = "AutoScalerDeleteFailed"
	ComponentImageUpdate    = "ComponentImageUpdate"
	PVCExplainFailed        = "PVCExplainFailed"
	PVCListFailed           = "PVCListFailed"
	PVCUpdate               = "PVCUpdated"
	PVCUpdateFailed         = "PVCUpdateFailed"
	PVCDeleteFailed         = "PVCDeleteFailed"
	PVCCreate               = "PVCCreate"
	PVCCreateFailed         = "PVCCreateFailed"
	FollowerScaleDownFailed = "FollowerScaleDownFailed"
)

'reason' should be short and unique; it should be in UpperCamelCase format (starting with a capital letter).

Variables

This section is empty.

Functions

func EventString

func EventString(event *Event) string

func GetDisaggregatedCommand

func GetDisaggregatedCommand(componentType dv1.DisaggregatedComponentType) (commands []string, args []string)

func GetDisaggregatedPreStopScript

func GetDisaggregatedPreStopScript(componentType dv1.DisaggregatedComponentType) string

get the script path of prestop, this will be called before stop container.

Types

type DisaggregatedSubController

type DisaggregatedSubController interface {
	//Sync reconcile for sub controller. bool represent the component have updated.
	Sync(ctx context.Context, obj client.Object) error
	//clear all resource about sub-component.
	ClearResources(ctx context.Context, obj client.Object) (bool, error)

	//return the controller name, beController, feController,cnController for log.
	GetControllerName() string

	//UpdateStatus update the component status on src.
	UpdateComponentStatus(obj client.Object) error
}

type DisaggregatedSubDefaultController

type DisaggregatedSubDefaultController struct {
	K8sclient      client.Client
	K8srecorder    record.EventRecorder
	ControllerName string
}

func (*DisaggregatedSubDefaultController) AddClusterSpecForPodTemplate

func (d *DisaggregatedSubDefaultController) AddClusterSpecForPodTemplate(componentType v1.DisaggregatedComponentType, configMap map[string]interface{}, spec *v1.DorisDisaggregatedClusterSpec, pts *corev1.PodTemplateSpec)

add cluster specification on container spec. this is useful to add common spec on different type pods, example: kerberos volume for fe and be.

func (*DisaggregatedSubDefaultController) AddDownwardAPI

func (d *DisaggregatedSubDefaultController) AddDownwardAPI(st *appv1.StatefulSet)

this function is a compensation, because the DownwardAPI annotations and labels are not mount in pod, so this function amends。

func (*DisaggregatedSubDefaultController) BuildDefaultConfigMapVolumesVolumeMounts

func (d *DisaggregatedSubDefaultController) BuildDefaultConfigMapVolumesVolumeMounts(cms []v1.ConfigMap) ([]corev1.Volume, []corev1.VolumeMount)

func (*DisaggregatedSubDefaultController) BuildVolumesVolumeMountsAndPVCs

func (d *DisaggregatedSubDefaultController) BuildVolumesVolumeMountsAndPVCs(confMap map[string]interface{}, componentType v1.DisaggregatedComponentType, commonSpec *v1.CommonSpec) ([]corev1.Volume, []corev1.VolumeMount, []corev1.PersistentVolumeClaim)

func (*DisaggregatedSubDefaultController) CheckSecretExist

func (d *DisaggregatedSubDefaultController) CheckSecretExist(ctx context.Context, ddc *v1.DorisDisaggregatedCluster, secrets []v1.Secret)

CheckSecretExist, check the secret exist or not in specify namespace.

func (*DisaggregatedSubDefaultController) CheckSecretMountPath

func (d *DisaggregatedSubDefaultController) CheckSecretMountPath(ddc *v1.DorisDisaggregatedCluster, secrets []v1.Secret)

generate map for mountpath:secret

func (*DisaggregatedSubDefaultController) ConstructDefaultAffinity

func (d *DisaggregatedSubDefaultController) ConstructDefaultAffinity(matchKey, value string, ddcAffinity *corev1.Affinity) *corev1.Affinity

func (*DisaggregatedSubDefaultController) DefaultReconcileService

func (d *DisaggregatedSubDefaultController) DefaultReconcileService(ctx context.Context, svc *corev1.Service) (*Event, error)

the common logic to apply service, will used by fe,be,ms.

func (*DisaggregatedSubDefaultController) FindSecretTLSConfig

func (d *DisaggregatedSubDefaultController) FindSecretTLSConfig(feConfMap map[string]interface{}, ddc *v1.DorisDisaggregatedCluster) (*mysql.TLSConfig, string)

func (*DisaggregatedSubDefaultController) GetConfigValuesFromConfigMaps

func (d *DisaggregatedSubDefaultController) GetConfigValuesFromConfigMaps(namespace string, resolveKey string, cms []v1.ConfigMap) map[string]interface{}

func (*DisaggregatedSubDefaultController) GetManagementAdminUserAndPWD

func (d *DisaggregatedSubDefaultController) GetManagementAdminUserAndPWD(ctx context.Context, ddc *v1.DorisDisaggregatedCluster) (string, string)

func (*DisaggregatedSubDefaultController) NewDefaultService

func (d *DisaggregatedSubDefaultController) NewDefaultService(ddc *v1.DorisDisaggregatedCluster) *corev1.Service

for config default values.

func (*DisaggregatedSubDefaultController) NewDefaultStatefulset

func (d *DisaggregatedSubDefaultController) NewDefaultStatefulset(ddc *v1.DorisDisaggregatedCluster) *appv1.StatefulSet

func (*DisaggregatedSubDefaultController) PersistentVolumeArrayBuildVolumesVolumeMountsAndPVCs

func (d *DisaggregatedSubDefaultController) PersistentVolumeArrayBuildVolumesVolumeMountsAndPVCs(commonSpec *v1.CommonSpec, confMap map[string]interface{}, componentType v1.DisaggregatedComponentType) ([]corev1.Volume, []corev1.VolumeMount, []corev1.PersistentVolumeClaim)

PersistentVolumeArrayBuildVolumesVolumeMountsAndPVCs use array of PersistentVolume, the new config from 25.2.x

func (*DisaggregatedSubDefaultController) PersistentVolumeBuildVolumesVolumeMountsAndPVCs

func (d *DisaggregatedSubDefaultController) PersistentVolumeBuildVolumesVolumeMountsAndPVCs(commonSpec *v1.CommonSpec, confMap map[string]interface{}, componentType v1.DisaggregatedComponentType) ([]corev1.Volume, []corev1.VolumeMount, []corev1.PersistentVolumeClaim)

PersistentVolumeBuildVolumesVolumeMountsAndPVCs the old config before 25.2.1, the requiredPaths should filter log path before call this function.

func (*DisaggregatedSubDefaultController) ReconcilePVC

func (d *DisaggregatedSubDefaultController) ReconcilePVC(
	ctx context.Context,
	ddc *v1.DorisDisaggregatedCluster,
	cm map[string]interface{},
	componentType v1.DisaggregatedComponentType,
	sts *appv1.StatefulSet,
	cg *v1.ComputeGroup,
) (*Event, error)

func (*DisaggregatedSubDefaultController) RestrictConditionsEqual

func (d *DisaggregatedSubDefaultController) RestrictConditionsEqual(new *appv1.StatefulSet, old *appv1.StatefulSet)

RestrictConditionsEqual adds two StatefulSet, It is used to control the conditions for comparing.

func (*DisaggregatedSubDefaultController) ReturnStatefulsetUpdatedGeneration

func (d *DisaggregatedSubDefaultController) ReturnStatefulsetUpdatedGeneration(sts *appv1.StatefulSet, annoGenerationKey string) int64

return which generation had updated the statefulset.

func (*DisaggregatedSubDefaultController) StatefulsetControlledPodsAllUseNewUpdateRevision

func (d *DisaggregatedSubDefaultController) StatefulsetControlledPodsAllUseNewUpdateRevision(stsUpdateRevision string, pods []corev1.Pod) bool

use statefulset.status.updateRevision and pod `controller-revision-hash` annotation to check pods updated to new revision. if all pods used new updateRevision return true, else return false.

type Event

type Event struct {
	Type    EventType
	Reason  EventReason
	Message string
}

type EventReason

type EventReason string
var (
	ImageFormatError          EventReason = "ImageFormatError"
	FDBSpecEmpty              EventReason = "SpecEmpty"
	FDBAvailableButUnhealth   EventReason = "FDBAvailableButUnhealth"
	FESpecSetError            EventReason = "FESpecSetError"
	FECreateResourceFailed    EventReason = "FECreateResourceFailed"
	FEApplyResourceFailed     EventReason = "FEApplyResourceFailed"
	FEStatefulsetDeleteFailed EventReason = "FEStatefulsetDeleteFailed"
	FEHTTPFailed              EventReason = "FEHTTPResponseFailed"
	FEServiceDeleteFailed     EventReason = "FEServiceDeleteFailed"
	ComputeGroupsEmpty        EventReason = "CGsEmpty"
	CGSqlExecFailed           EventReason = "CGSqlExecFailed"
	//CGSuspendStatusRequestFailed    EventReason = "CGSuspendStatusRequestFailed"
	//CGResumeReplicasInconsistency   EventReason = "CGSuspendReplicasInconsistency"
	//CGResumeStatusRequestFailed     EventReason = "CGResumeStatusRequestFailed"
	CGUniqueIdentifierDuplicate     EventReason = "CGUniqueIdentifierDuplicate"
	CGUniqueIdentifierNotMatchRegex EventReason = "CGUniqueIdentifierNotMatchRegex"
	CGCreateResourceFailed          EventReason = "CGCreateResourceFailed"
	CGApplyResourceFailed           EventReason = "CGApplyResourceFailed"
	CGStatefulsetDeleteFailed       EventReason = "CGStatefulsetDeleteFailed"
	CGServiceDeleteFailed           EventReason = "CGServiceDeleteFailed"
	ConfigMapPathRepeated           EventReason = "ConfigMapPathRepeated"
	SecretPathRepeated              EventReason = "SecretPathRepeated"
	SecretNotExist                  EventReason = "SecretNotExist"
	CheckSharePVC                   EventReason = "CheckSharePVC"
	WaitMetaServiceAvailable        EventReason = "WaitMetaServiceAvailable"
	WaitFEAvailable                 EventReason = "WaitFEAvailable"
	ServiceApplyedFailed            EventReason = "ServiceApplyedFailed"
	MSServiceDeletedFailed          EventReason = "MSServiceDeletedFailed"
	MSStatefulsetDeleteFailed       EventReason = "MSStatefulsetDeleteFailed"
	FDBAddressNotConfiged           EventReason = "FDBAddressNotConfiged"
	RestartTimeInvalid              EventReason = "RestartTimeInvalid"
	ConfigMapGetFailed              EventReason = "ConfigMapGetFailed"
)

type EventType

type EventType string

define event type for sub controller, Type can be one of Normal, Warning.

var (
	EventNormal  EventType = "Normal"
	EventWarning EventType = "Warning"
)

only Normal Warning, not add new type.

type SubController

type SubController interface {
	//Sync reconcile for sub controller. bool represent the component have updated.
	Sync(ctx context.Context, cluster *dorisv1.DorisCluster) error
	//clear all resource about sub-component.
	ClearResources(ctx context.Context, cluster *dorisv1.DorisCluster) (bool, error)

	//return the controller name, beController, feController,cnController for log.
	GetControllerName() string

	//UpdateStatus update the component status on src.
	UpdateComponentStatus(cluster *dorisv1.DorisCluster) error
}

type SubDefaultController

type SubDefaultController struct {
	K8sclient   client.Client
	K8srecorder record.EventRecorder
}

SubDefaultController define common function for all component about doris.

func (*SubDefaultController) BuildCoreConfigmapStatusHash

func (d *SubDefaultController) BuildCoreConfigmapStatusHash(ctx context.Context, dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType) string

BuildCoreConfigmapStatusHash resolve configmap for doris core configuration file (fe.conf/be.conf), After parsing the configuration file, it is converted into a configured map, And return the map's hash

func (*SubDefaultController) CheckConfigMountPath

func (d *SubDefaultController) CheckConfigMountPath(dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType)

generate map for mountpath:configmap

func (*SubDefaultController) CheckRestartTimeAndInject

func (d *SubDefaultController) CheckRestartTimeAndInject(dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType) bool

func (*SubDefaultController) CheckSecretExist

func (d *SubDefaultController) CheckSecretExist(ctx context.Context, dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType)

CheckSecretExist, check the secret exist or not in specify namespace.

func (*SubDefaultController) CheckSecretMountPath

func (d *SubDefaultController) CheckSecretMountPath(dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType)

generate map for mountpath:secret

func (*SubDefaultController) CheckSharedPVC

func (d *SubDefaultController) CheckSharedPVC(ctx context.Context, dcr *dorisv1.DorisCluster)

CheckSharedPVC verifies two points:

  1. Whether the SharePVC exists
  2. Whether the AccessMode of the SharePVC is ReadWriteMany

func (*SubDefaultController) ClassifyPodsByStatus

func (d *SubDefaultController) ClassifyPodsByStatus(namespace string, status *dorisv1.ComponentStatus, labels map[string]string, replicas int32, componentType dorisv1.ComponentType) error

func (*SubDefaultController) ClearCommonResources

func (d *SubDefaultController) ClearCommonResources(ctx context.Context, dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType) (bool, error)

ClearCommonResources clear common resources all component have, as statefulset, service. response `bool` represents all resource have deleted, if not and delete resource failed return false for next reconcile retry.

func (*SubDefaultController) CompareConfigmapAndTriggerRestart

func (d *SubDefaultController) CompareConfigmapAndTriggerRestart(dcr *dorisv1.DorisCluster, oldStatus dorisv1.ComponentStatus, componentType dorisv1.ComponentType)

CompareConfigmapAndTriggerRestart 1. Compared by configmap Resolve file to map`s hash 2. Add restart trigger DCR

func (*SubDefaultController) FeAvailable

func (d *SubDefaultController) FeAvailable(dcr *dorisv1.DorisCluster) bool

func (*SubDefaultController) GetConfig

func (d *SubDefaultController) GetConfig(ctx context.Context, configMapInfo *dorisv1.ConfigMapInfo, namespace string, componentType dorisv1.ComponentType) (map[string]interface{}, error)

func (*SubDefaultController) GetFinalPersistentVolumes

func (d *SubDefaultController) GetFinalPersistentVolumes(ctx context.Context, dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType) ([]dorisv1.PersistentVolume, error)

func (*SubDefaultController) InitStatus

func (d *SubDefaultController) InitStatus(dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType)

func (*SubDefaultController) PrepareReconcileResources

func (d *SubDefaultController) PrepareReconcileResources(ctx context.Context, dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType) bool

PrepareReconcileResources prepare resource for reconcile response: bool, if true presents resource have ready for reconciling, if false presents resource is preparing.

func (*SubDefaultController) RecycleResources

func (d *SubDefaultController) RecycleResources(ctx context.Context, dcr *dorisv1.DorisCluster, componentType dorisv1.ComponentType) error

RecycleResources pvc resource for recycle

func (*SubDefaultController) RestrictConditionsEqual

func (d *SubDefaultController) RestrictConditionsEqual(nst *appv1.StatefulSet, est *appv1.StatefulSet)

RestrictConditionsEqual adds two StatefulSet, It is used to control the conditions for comparing. nst StatefulSet - a new StatefulSet est StatefulSet - an old StatefulSet

func (*SubDefaultController) UpdateStatus

func (d *SubDefaultController) UpdateStatus(namespace string, status *dorisv1.ComponentStatus, labels map[string]string, replicas int32, componentType dorisv1.ComponentType) error

UpdateStatus update the component status on src.

Directories

Path Synopsis
disaggregated_cluster

Jump to

Keyboard shortcuts

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