@@ -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
6753func 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
9177func 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
237223func 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
255241func 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