Skip to content

Commit 8b06624

Browse files
author
smiletan
authored
Merge pull request #292 from catpineapple/add-restart-capability
[feature](dcr) add rolling restart capability
2 parents 7d27da0 + c2cb4eb commit 8b06624

File tree

14 files changed

+181
-13
lines changed

14 files changed

+181
-13
lines changed

api/doris/v1/doriscluster_util.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ import (
2828
const (
2929
//ComponentsResourceHash the component hash
3030
ComponentResourceHash string = "app.doris.components/hash"
31+
32+
FERestartAt string = "apache.doris.fe/restartedAt"
33+
BERestartAt string = "apache.doris.be/restartedAt"
3134
)
3235

3336
// the labels key

config/crd/bases/crds.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,14 @@ spec:
10941094
type: string
10951095
type: object
10961096
type: object
1097+
enableWorkloadGroup:
1098+
description: |-
1099+
EnableWorkloadGroup is a switch that determines whether the doris cluster enables the workload group.
1100+
Default value is 'false'.
1101+
Enabling it means that the container must be started in privileged mode.
1102+
Please confirm whether the host machine and k8s cluster allow it.
1103+
Doris workloadgroup reference document: https://doris.apache.org/docs/admin-manual/resource-admin/workload-group
1104+
type: boolean
10971105
envVars:
10981106
description: cnEnvVars is a slice of environment variables that
10991107
are added to the pods, the default is empty.

config/crd/bases/doris.selectdb.com_dorisclusters.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,14 @@ spec:
10941094
type: string
10951095
type: object
10961096
type: object
1097+
enableWorkloadGroup:
1098+
description: |-
1099+
EnableWorkloadGroup is a switch that determines whether the doris cluster enables the workload group.
1100+
Default value is 'false'.
1101+
Enabling it means that the container must be started in privileged mode.
1102+
Please confirm whether the host machine and k8s cluster allow it.
1103+
Doris workloadgroup reference document: https://doris.apache.org/docs/admin-manual/resource-admin/workload-group
1104+
type: boolean
10971105
envVars:
10981106
description: cnEnvVars is a slice of environment variables that
10991107
are added to the pods, the default is empty.

doc/api.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,21 @@ BaseSpec
617617
<p>the foundation spec for creating be software services.</p>
618618
</td>
619619
</tr>
620+
<tr>
621+
<td>
622+
<code>enableWorkloadGroup</code><br/>
623+
<em>
624+
bool
625+
</em>
626+
</td>
627+
<td>
628+
<p>EnableWorkloadGroup is a switch that determines whether the doris cluster enables the workload group.
629+
Default value is &lsquo;false&rsquo;.
630+
Enabling it means that the container must be started in privileged mode.
631+
Please confirm whether the host machine and k8s cluster allow it.
632+
Doris workloadgroup reference document: <a href="https://doris.apache.org/docs/admin-manual/resource-admin/workload-group">https://doris.apache.org/docs/admin-manual/resource-admin/workload-group</a></p>
633+
</td>
634+
</tr>
620635
</tbody>
621636
</table>
622637
<h3 id="doris.selectdb.com/v1.BrokerSpec">BrokerSpec
@@ -2604,5 +2619,5 @@ string
26042619
<hr/>
26052620
<p><em>
26062621
Generated with <code>gen-crd-api-reference-docs</code>
2607-
on git commit <code>54d1acc</code>.
2622+
on git commit <code>1a70fe9</code>.
26082623
</em></p>

doc/disaggregated_api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,5 +1441,5 @@ string
14411441
<hr/>
14421442
<p><em>
14431443
Generated with <code>gen-crd-api-reference-docs</code>
1444-
on git commit <code>54d1acc</code>.
1444+
on git commit <code>7d27da0</code>.
14451445
</em></p>

helm-charts/doris-operator/crds/doris.selectdb.com_dorisclusters.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,14 @@ spec:
10941094
type: string
10951095
type: object
10961096
type: object
1097+
enableWorkloadGroup:
1098+
description: |-
1099+
EnableWorkloadGroup is a switch that determines whether the doris cluster enables the workload group.
1100+
Default value is 'false'.
1101+
Enabling it means that the container must be started in privileged mode.
1102+
Please confirm whether the host machine and k8s cluster allow it.
1103+
Doris workloadgroup reference document: https://doris.apache.org/docs/admin-manual/resource-admin/workload-group
1104+
type: boolean
10971105
envVars:
10981106
description: cnEnvVars is a slice of environment variables that
10991107
are added to the pods, the default is empty.

pkg/controller/sub_controller/be/controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ func (be *Controller) Sync(ctx context.Context, dcr *v1.DorisCluster) error {
5454
if dcr.Spec.BeSpec == nil {
5555
return nil
5656
}
57+
58+
var oldStatus v1.ComponentStatus
59+
if dcr.Status.BEStatus != nil {
60+
oldStatus = *(dcr.Status.BEStatus.DeepCopy())
61+
}
5762
be.InitStatus(dcr, v1.Component_BE)
5863
if !be.FeAvailable(dcr) {
5964
return nil
@@ -83,6 +88,10 @@ func (be *Controller) Sync(ctx context.Context, dcr *v1.DorisCluster) error {
8388
return err
8489
}
8590

91+
if err = be.prepareStatefulsetApply(ctx, dcr, oldStatus); err != nil {
92+
return err
93+
}
94+
8695
st := be.buildBEStatefulSet(dcr)
8796
if !be.PrepareReconcileResources(ctx, dcr, v1.Component_BE) {
8897
klog.Infof("be controller sync preparing resource for reconciling namespace %s name %s!", dcr.Namespace, dcr.Name)
@@ -109,7 +118,7 @@ func (be *Controller) UpdateComponentStatus(cluster *v1.DorisCluster) error {
109118
return nil
110119
}
111120

112-
return be.ClassifyPodsByStatus(cluster.Namespace, cluster.Status.BEStatus, v1.GenerateStatefulSetSelector(cluster, v1.Component_BE), *cluster.Spec.BeSpec.Replicas)
121+
return be.ClassifyPodsByStatus(cluster.Namespace, cluster.Status.BEStatus, v1.GenerateStatefulSetSelector(cluster, v1.Component_BE), *cluster.Spec.BeSpec.Replicas, v1.Component_BE)
113122
}
114123

115124
func (be *Controller) ClearResources(ctx context.Context, dcr *v1.DorisCluster) (bool, error) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package be
19+
20+
import (
21+
"context"
22+
v1 "github.com/apache/doris-operator/api/doris/v1"
23+
)
24+
25+
// prepareStatefulsetApply means Pre-operation and status control on the client side
26+
func (be *Controller) prepareStatefulsetApply(ctx context.Context, dcr *v1.DorisCluster, oldStatus v1.ComponentStatus) error {
27+
28+
// be rolling restart
29+
// check 1: be Phase is Available
30+
// check 2: be RestartTime is not empty and useful
31+
// check 3: be RestartTime different from old(This condition does not need to be checked here. If it is allowed to pass, it will be processed idempotent when applying sts.)
32+
if oldStatus.ComponentCondition.Phase == v1.Available && be.CheckRestartTimeAndInject(dcr, v1.Component_BE) {
33+
dcr.Status.BEStatus.ComponentCondition.Phase = v1.Restarting
34+
}
35+
36+
//TODO check upgrade
37+
38+
return nil
39+
}

pkg/controller/sub_controller/broker/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (bk *Controller) UpdateComponentStatus(cluster *v1.DorisCluster) error {
113113

114114
cluster.Status.BrokerStatus = bs
115115
bs.AccessService = v1.GenerateExternalServiceName(cluster, v1.Component_Broker)
116-
return bk.ClassifyPodsByStatus(cluster.Namespace, bs, v1.GenerateStatefulSetSelector(cluster, v1.Component_Broker), *cluster.Spec.BrokerSpec.Replicas)
116+
return bk.ClassifyPodsByStatus(cluster.Namespace, bs, v1.GenerateStatefulSetSelector(cluster, v1.Component_Broker), *cluster.Spec.BrokerSpec.Replicas, v1.Component_Broker)
117117

118118
}
119119

pkg/controller/sub_controller/cn/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func (cn *Controller) UpdateComponentStatus(cluster *dorisv1.DorisCluster) error
145145

146146
replicas := *est.Spec.Replicas
147147
cs.AccessService = dorisv1.GenerateExternalServiceName(cluster, dorisv1.Component_CN)
148-
return cn.ClassifyPodsByStatus(cluster.Namespace, &cs.ComponentStatus, dorisv1.GenerateStatefulSetSelector(cluster, dorisv1.Component_CN), replicas)
148+
return cn.ClassifyPodsByStatus(cluster.Namespace, &cs.ComponentStatus, dorisv1.GenerateStatefulSetSelector(cluster, dorisv1.Component_CN), replicas, dorisv1.Component_CN)
149149
}
150150

151151
// autoscaler represents start autoscaler or not.

0 commit comments

Comments
 (0)