Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve](dcr) enable skip default SystemInit for be #321

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip as a parameter, and dcr will not be needed. the if logic will be concise.
if !skip && (compoentType==v1.Component_be || component==v1.Componet_CN){

}

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
Loading