Skip to content

Commit 23c8d20

Browse files
committed
update
1 parent 5df6a3a commit 23c8d20

22 files changed

+130
-572
lines changed

controllers/apps/component/transformer_component_workload_ops.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func (r *componentWorkloadOps) handleReconfigure(transCtx *componentTransformCon
453453
action *appsv1.Action
454454
actionName string
455455
)
456-
if tpl.ExternalManaged != nil && *tpl.ExternalManaged {
456+
if ptr.Deref(tpl.ExternalManaged, false) {
457457
if tpl.Reconfigure == nil {
458458
return // disabled by the external system
459459
}

controllers/parameters/combine_upgrade_policy_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ var _ = Describe("Reconfigure CombineSyncPolicy", func() {
5353
Expect(upgradePolicyMap[parametersv1alpha1.DynamicReloadAndRestartPolicy]).ShouldNot(BeNil())
5454

5555
mockParam := newMockReconfigureParams("restartPolicy", k8sMockClient.Client(),
56-
withMockInstanceSet(2, nil),
5756
withConfigSpec("for_test", map[string]string{
5857
"key": "value",
5958
}),
@@ -71,7 +70,6 @@ var _ = Describe("Reconfigure CombineSyncPolicy", func() {
7170
}
7271

7372
mockParam := newMockReconfigureParams("restartPolicy", k8sMockClient.Client(),
74-
withMockInstanceSet(2, nil),
7573
withConfigSpec("for_test", map[string]string{
7674
"key": "value",
7775
}),

controllers/parameters/config_reconcile_wrapper.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ import (
2525

2626
appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
2727
parametersv1alpha1 "github.com/apecloud/kubeblocks/apis/parameters/v1alpha1"
28-
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1"
2928
"github.com/apecloud/kubeblocks/pkg/controller/component"
3029
"github.com/apecloud/kubeblocks/pkg/controller/render"
3130
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
32-
"github.com/apecloud/kubeblocks/pkg/generics"
3331
"github.com/apecloud/kubeblocks/pkg/parameters"
3432
)
3533

@@ -41,8 +39,6 @@ type ReconcileContext struct {
4139
ConfigMap *corev1.ConfigMap
4240
BuiltinComponent *component.SynthesizedComponent
4341

44-
InstanceSetList []workloads.InstanceSet
45-
4642
ConfigRender *parametersv1alpha1.ParamConfigRenderer
4743
ParametersDefs map[string]*parametersv1alpha1.ParametersDefinition
4844
}
@@ -67,26 +63,11 @@ func (c *ReconcileContext) GetRelatedObjects() error {
6763
return c.Cluster().
6864
ComponentAndComponentDef().
6965
ComponentSpec().
70-
Workload().
7166
SynthesizedComponent().
7267
ParametersDefinitions().
7368
Complete()
7469
}
7570

76-
func (c *ReconcileContext) Workload() *ReconcileContext {
77-
instanceSetFn := func() (err error) {
78-
c.InstanceSetList, err = retrieveRelatedComponentsByConfigmap(
79-
c.Client,
80-
c.Context,
81-
generics.InstanceSetSignature,
82-
client.ObjectKeyFromObject(c.ConfigMap),
83-
client.InNamespace(c.Namespace),
84-
c.MatchingLabels)
85-
return
86-
}
87-
return c.Wrap(instanceSetFn)
88-
}
89-
9071
func (c *ReconcileContext) SynthesizedComponent() *ReconcileContext {
9172
return c.Wrap(func() (err error) {
9273
// build synthesized component for the component

controllers/parameters/config_related_helper.go

Lines changed: 0 additions & 89 deletions
This file was deleted.

controllers/parameters/policy_util.go

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,7 @@ import (
3535
"github.com/apecloud/kubeblocks/pkg/parameters/core"
3636
)
3737

38-
// GetComponentPods gets all pods of the component.
39-
func GetComponentPods(params reconfigureContext) ([]corev1.Pod, error) {
40-
componentPods := make([]corev1.Pod, 0)
41-
for i := range params.InstanceSetUnits {
42-
pods, err := intctrlutil.GetPodListByInstanceSet(params.Ctx, params.Client, &params.InstanceSetUnits[i])
43-
if err != nil {
44-
return nil, err
45-
}
46-
componentPods = append(componentPods, pods...)
47-
}
48-
return componentPods, nil
49-
}
50-
51-
// CheckReconfigureUpdateProgress checks pods of the component is ready.
52-
func CheckReconfigureUpdateProgress(pods []corev1.Pod, configKey, version string) int32 {
38+
func checkReconfigureUpdateProgress(pods []corev1.Pod, configKey, version string) int32 {
5339
var (
5440
readyPods int32 = 0
5541
cfgAnnotationKey = core.GenerateUniqKeyWithConfig(constant.UpgradeRestartAnnotationKey, configKey)
@@ -65,27 +51,27 @@ func CheckReconfigureUpdateProgress(pods []corev1.Pod, configKey, version string
6551
}
6652

6753
func getPodsForOnlineUpdate(params reconfigureContext) ([]corev1.Pod, error) {
68-
if len(params.InstanceSetUnits) > 1 {
69-
return nil, core.MakeError("component require only one InstanceSet, actual %d components", len(params.InstanceSetUnits))
70-
}
71-
72-
if len(params.InstanceSetUnits) == 0 {
73-
return nil, nil
74-
}
75-
76-
pods, err := GetComponentPods(params)
77-
if err != nil {
54+
var (
55+
ctx = params.Ctx
56+
cli = params.Client
57+
podList = &corev1.PodList{}
58+
opts = []client.ListOption{
59+
client.InNamespace(params.SynthesizedComponent.Namespace),
60+
client.MatchingLabels(constant.GetCompLabels(params.SynthesizedComponent.ClusterName, params.SynthesizedComponent.Name)),
61+
}
62+
)
63+
if err := cli.List(ctx, podList, opts...); err != nil {
7864
return nil, err
7965
}
8066

8167
if params.SynthesizedComponent != nil {
8268
instanceset.SortPods(
83-
pods,
69+
podList.Items,
8470
instanceset.ComposeRolePriorityMap(params.SynthesizedComponent.Roles),
8571
true,
8672
)
8773
}
88-
return pods, nil
74+
return podList.Items, nil
8975
}
9076

9177
func commonOnlineUpdateWithPod(pod *corev1.Pod, ctx context.Context, configSpec string, configFile string, updatedParams map[string]string) error {
@@ -235,21 +221,21 @@ func genReconfigureActionTasks(templateSpec *appsv1.ComponentFileTemplate, rctx
235221
}
236222

237223
func buildReloadActionTask(reloadPolicy parametersv1alpha1.ReloadPolicy, templateSpec *appsv1.ComponentFileTemplate, rctx *ReconcileContext, pd *parametersv1alpha1.ParametersDefinition, configDescription *parametersv1alpha1.ComponentConfigDescription, patch *core.ConfigPatchInfo) reconfigureTask {
238-
reCtx := reconfigureContext{
239-
RequestCtx: rctx.RequestCtx,
240-
Client: rctx.Client,
241-
ConfigTemplate: *templateSpec,
242-
ConfigMap: rctx.ConfigMap,
243-
ParametersDef: &pd.Spec,
244-
ConfigDescription: configDescription,
245-
Cluster: rctx.ClusterObj,
246-
InstanceSetUnits: rctx.InstanceSetList,
247-
ClusterComponent: rctx.ClusterComObj,
248-
SynthesizedComponent: rctx.BuiltinComponent,
249-
Patch: patch,
224+
return reconfigureTask{
225+
ReloadPolicy: reloadPolicy,
226+
taskCtx: reconfigureContext{
227+
RequestCtx: rctx.RequestCtx,
228+
Client: rctx.Client,
229+
ConfigTemplate: *templateSpec,
230+
ConfigMap: rctx.ConfigMap,
231+
ParametersDef: &pd.Spec,
232+
ConfigDescription: configDescription,
233+
Cluster: rctx.ClusterObj,
234+
ClusterComponent: rctx.ClusterComObj,
235+
SynthesizedComponent: rctx.BuiltinComponent,
236+
Patch: patch,
237+
},
250238
}
251-
252-
return reconfigureTask{ReloadPolicy: reloadPolicy, taskCtx: reCtx}
253239
}
254240

255241
func buildRestartTask(configTemplate *appsv1.ComponentFileTemplate, rctx *ReconcileContext) reconfigureTask {
@@ -262,7 +248,6 @@ func buildRestartTask(configTemplate *appsv1.ComponentFileTemplate, rctx *Reconc
262248
ClusterComponent: rctx.ClusterComObj,
263249
Cluster: rctx.ClusterObj,
264250
SynthesizedComponent: rctx.BuiltinComponent,
265-
InstanceSetUnits: rctx.InstanceSetList,
266251
ConfigMap: rctx.ConfigMap,
267252
},
268253
}

0 commit comments

Comments
 (0)