Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Fix pilot selection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kragniz committed May 8, 2018
1 parent b81c229 commit fa9a183
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions pkg/controllers/cassandra/actions/scalein.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,17 @@ func (a *ScaleIn) Execute(s *controllers.State) error {
return err
}

if len(pilots) <= 1 {
return fmt.Errorf(
"Not enough pilots to scale down: %d",
len(pilots),
)
}

allDecommissioned := true

nPilotsToRemove := int(*ss.Spec.Replicas - a.NodePool.Replicas)
for i := 0; i < nPilotsToRemove; i++ {
for i := 1; i <= nPilotsToRemove; i++ {
p := pilots[len(pilots)-i].DeepCopy()
if p.Spec.Cassandra == nil {
p.Spec.Cassandra = &v1alpha1.PilotCassandraSpec{}
Expand All @@ -51,14 +58,16 @@ func (a *ScaleIn) Execute(s *controllers.State) error {
if !p.Spec.Cassandra.Decommissioned {
p.Spec.Cassandra.Decommissioned = true
_, err := s.NavigatorClientset.NavigatorV1alpha1().Pilots(p.Namespace).Update(p)
if err == nil {
s.Recorder.Eventf(
p,
corev1.EventTypeNormal,
a.Name(),
"Marked cassandra pilot %s for decommission", p.Name,
)
if err != nil {
return err
}

s.Recorder.Eventf(
p,
corev1.EventTypeNormal,
a.Name(),
"Marked cassandra pilot %s for decommission", p.Name,
)
}

if p.Status.Cassandra == nil {
Expand Down

0 comments on commit fa9a183

Please sign in to comment.