Skip to content

Commit 78d7c67

Browse files
author
lamai93
committed
Revisited scale up and scale down.
1 parent 0b606b0 commit 78d7c67

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

pkg/apis/deployment/v1alpha/member_status_list.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ func (l MemberStatusList) SelectMemberToRemove() (MemberStatus, error) {
142142
if len(l) > 0 {
143143
// Try to find a not ready member
144144
for _, m := range l {
145-
if m.Phase == MemberPhaseNone || !m.Conditions.IsTrue(ConditionTypeReady) {
145+
if m.Phase == MemberPhaseNone {
146+
return m, nil
147+
}
148+
}
149+
for _, m := range l {
150+
if !m.Conditions.IsTrue(ConditionTypeReady) {
146151
return m, nil
147152
}
148153
}

pkg/deployment/reconcile/action_cleanout_member.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ func (a *actionCleanoutMember) CheckProgress(ctx context.Context) (bool, bool, e
9595
// We wanted to remove and it is already gone. All ok
9696
return true, false, nil
9797
}
98+
// do not try to clean out a pod that is not ready
99+
if !m.Conditions.IsTrue(api.ConditionTypeReady) {
100+
return false, true, nil
101+
}
98102
c, err := a.actionCtx.GetDatabaseClient(ctx)
99103
if err != nil {
100104
log.Debug().Err(err).Msg("Failed to create database client")

pkg/deployment/reconcile/action_shutdown_member.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ func (a *actionShutdownMember) Start(ctx context.Context) (bool, error) {
6363
return true, nil
6464
}
6565
if group.IsArangod() {
66+
// do not try to shut down a pod that is not ready
67+
if !m.Conditions.IsTrue(api.ConditionTypeReady) {
68+
return true, nil
69+
}
6670
// Invoke shutdown endpoint
6771
c, err := a.actionCtx.GetServerClient(ctx, group, a.action.MemberID)
6872
if err != nil {

pkg/deployment/reconcile/plan_builder.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,13 @@ func createScalePlan(log zerolog.Logger, members api.MemberStatusList, group api
371371
Str("member-id", m.ID).
372372
Str("phase", string(m.Phase)).
373373
Msg("Found member to remove")
374-
if m.Conditions.IsTrue(api.ConditionTypeReady) {
375-
if group == api.ServerGroupDBServers {
376-
plan = append(plan,
377-
api.NewAction(api.ActionTypeCleanOutMember, group, m.ID),
378-
)
379-
}
374+
if group == api.ServerGroupDBServers {
380375
plan = append(plan,
381-
api.NewAction(api.ActionTypeShutdownMember, group, m.ID),
376+
api.NewAction(api.ActionTypeCleanOutMember, group, m.ID),
382377
)
383378
}
384379
plan = append(plan,
380+
api.NewAction(api.ActionTypeShutdownMember, group, m.ID),
385381
api.NewAction(api.ActionTypeRemoveMember, group, m.ID),
386382
)
387383
log.Debug().

0 commit comments

Comments
 (0)