Skip to content

Commit

Permalink
Merge pull request #321 from catpineapple/enable-skip-system-init
Browse files Browse the repository at this point in the history
[improve](dcr) enable skip default SystemInit for be
  • Loading branch information
intelligentfu8 authored Jan 9, 2025
2 parents 45d53b8 + 6061691 commit 16d250a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
8 changes: 8 additions & 0 deletions api/doris/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ type BeSpec struct {
// Please confirm whether the host machine and k8s cluster allow it.
// Doris workloadgroup reference document: https://doris.apache.org/docs/admin-manual/resource-admin/workload-group
EnableWorkloadGroup bool `json:"enableWorkloadGroup,omitempty"`

// SkipDefaultSystemInit is a switch that skips the default initialization and is used to set the default environment configuration required by the doris BE node.
// Default value is 'false'.
// Default System Init means that the container must be started in privileged mode.
// Default System Init configuration is implemented through the initContainers of the pod, so changes to this configuration may be ignored by k8s when it is not the first deployment.
SkipDefaultSystemInit bool `json:"skipDefaultSystemInit,omitempty"`
}

// FeAddress specify the fe address, please set it when you deploy fe outside k8s or deploy components use crd except fe, if not set .
Expand All @@ -120,6 +126,8 @@ type CnSpec struct {
//the foundation spec for creating cn software services.
BaseSpec `json:",inline"`

SkipDefaultSystemInit bool `json:"skipDefaultSystemInit,omitempty"`

//AutoScalingPolicy auto scaling strategy
AutoScalingPolicy *AutoScalingPolicy `json:"autoScalingPolicy,omitempty"`
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/common/utils/resource/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func NewPodTemplateSpec(dcr *v1.DorisCluster, componentType v1.ComponentType) co
var dcrAffinity *corev1.Affinity
var defaultInitContainers []corev1.Container
var SecurityContext *corev1.PodSecurityContext
var skipInit bool
switch componentType {
case v1.Component_FE:
volumes = newVolumesFromBaseSpec(dcr.Spec.FeSpec.BaseSpec)
Expand All @@ -97,10 +98,12 @@ func NewPodTemplateSpec(dcr *v1.DorisCluster, componentType v1.ComponentType) co
si = dcr.Spec.BeSpec.BaseSpec.SystemInitialization
dcrAffinity = dcr.Spec.BeSpec.BaseSpec.Affinity
SecurityContext = dcr.Spec.BeSpec.BaseSpec.SecurityContext
skipInit = dcr.Spec.BeSpec.SkipDefaultSystemInit
case v1.Component_CN:
si = dcr.Spec.CnSpec.BaseSpec.SystemInitialization
dcrAffinity = dcr.Spec.CnSpec.BaseSpec.Affinity
SecurityContext = dcr.Spec.CnSpec.BaseSpec.SecurityContext
skipInit = dcr.Spec.CnSpec.SkipDefaultSystemInit
case v1.Component_Broker:
si = dcr.Spec.BrokerSpec.BaseSpec.SystemInitialization
dcrAffinity = dcr.Spec.BrokerSpec.BaseSpec.Affinity
Expand Down Expand Up @@ -155,7 +158,7 @@ func NewPodTemplateSpec(dcr *v1.DorisCluster, componentType v1.ComponentType) co
},
}

constructInitContainers(componentType, &pts.Spec, si)
constructInitContainers(skipInit, componentType, &pts.Spec, si)
pts.Spec.Affinity = constructAffinity(dcrAffinity, componentType)

return pts
Expand Down Expand Up @@ -220,7 +223,7 @@ func ApplySecurityContext(containers []corev1.Container, securityContext *corev1
return containers
}

func constructInitContainers(componentType v1.ComponentType, podSpec *corev1.PodSpec, si *v1.SystemInitialization) {
func constructInitContainers(skipInit bool, componentType v1.ComponentType, podSpec *corev1.PodSpec, si *v1.SystemInitialization) {
defaultImage := ""
var defaultInitContains []corev1.Container
if si != nil {
Expand All @@ -230,7 +233,7 @@ func constructInitContainers(componentType v1.ComponentType, podSpec *corev1.Pod
}

// the init containers have sequence,should confirm use initial is always in the first priority.
if componentType == v1.Component_BE || componentType == v1.Component_CN {
if !skipInit && (componentType == v1.Component_BE || componentType == v1.Component_CN) {
podSpec.InitContainers = append(podSpec.InitContainers, constructBeDefaultInitContainer(defaultImage))
}
podSpec.InitContainers = append(podSpec.InitContainers, defaultInitContains...)
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/sub_controller/be/prepare_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
package be

import (
"context"
v1 "github.com/apache/doris-operator/api/doris/v1"
)

// prepareStatefulsetApply means Pre-operation and status control on the client side
func (be *Controller) prepareStatefulsetApply(ctx context.Context, dcr *v1.DorisCluster, oldStatus v1.ComponentStatus) error {
func (be *Controller) prepareStatefulsetApply(dcr *v1.DorisCluster, oldStatus v1.ComponentStatus) error {

// be rolling restart
// check 1: be Phase is Available
Expand Down

0 comments on commit 16d250a

Please sign in to comment.