@@ -102,40 +102,37 @@ func createReplaceMemberPlan(ctx context.Context,
102102
103103 var plan api.Plan
104104
105- // Replace is only allowed for DBServers
106- switch spec .GetMode () {
107- case api .DeploymentModeCluster :
108- status .Members .ForeachServerInGroups (func (group api.ServerGroup , list api.MemberStatusList ) error {
109- for _ , member := range list {
110- if ! plan .IsEmpty () {
105+ // Replace is only allowed for DBServers & Agents
106+ status .Members .ForeachServerInGroups (func (group api.ServerGroup , list api.MemberStatusList ) error {
107+ for _ , member := range list {
108+ if ! plan .IsEmpty () {
109+ return nil
110+ }
111+ if member .Conditions .IsTrue (api .ConditionTypeMarkedToRemove ) {
112+ switch group {
113+ case api .ServerGroupDBServers :
114+ plan = append (plan , api .NewAction (api .ActionTypeAddMember , group , "" ).
115+ AddParam (api .ActionTypeWaitForMemberInSync .String (), "" ).
116+ AddParam (api .ActionTypeWaitForMemberUp .String (), "" ))
117+ log .Debug ().
118+ Str ("role" , group .AsRole ()).
119+ Msg ("Creating replacement plan" )
111120 return nil
112- }
113- if member .Conditions .IsTrue (api .ConditionTypeMarkedToRemove ) {
114- switch group {
115- case api .ServerGroupDBServers :
116- plan = append (plan , api .NewAction (api .ActionTypeAddMember , group , "" ).
121+ case api .ServerGroupAgents :
122+ plan = append (plan , api .NewAction (api .ActionTypeRemoveMember , group , member .ID ),
123+ api .NewAction (api .ActionTypeAddMember , group , "" ).
117124 AddParam (api .ActionTypeWaitForMemberInSync .String (), "" ).
118125 AddParam (api .ActionTypeWaitForMemberUp .String (), "" ))
119- log .Debug ().
120- Str ("role" , group .AsRole ()).
121- Msg ("Creating replacement plan" )
122- return nil
123- case api .ServerGroupAgents :
124- plan = append (plan , api .NewAction (api .ActionTypeRemoveMember , group , member .ID ),
125- api .NewAction (api .ActionTypeAddMember , group , "" ).
126- AddParam (api .ActionTypeWaitForMemberInSync .String (), "" ).
127- AddParam (api .ActionTypeWaitForMemberUp .String (), "" ))
128- log .Debug ().
129- Str ("role" , group .AsRole ()).
130- Msg ("Creating replacement plan" )
131- return nil
132- }
126+ log .Debug ().
127+ Str ("role" , group .AsRole ()).
128+ Msg ("Creating replacement plan" )
129+ return nil
133130 }
134131 }
132+ }
135133
136- return nil
137- }, api .ServerGroupAgents , api .ServerGroupDBServers )
138- }
134+ return nil
135+ }, api .ServerGroupAgents , api .ServerGroupDBServers )
139136
140137 return plan
141138}
0 commit comments