This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
pkg/controllers/cassandra/actions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,10 +39,17 @@ func (a *ScaleIn) Execute(s *controllers.State) error {
3939 return err
4040 }
4141
42+ if len (pilots ) <= 1 {
43+ return fmt .Errorf (
44+ "Not enough pilots to scale down: %d" ,
45+ len (pilots ),
46+ )
47+ }
48+
4249 allDecommissioned := true
4350
4451 nPilotsToRemove := int (* ss .Spec .Replicas - a .NodePool .Replicas )
45- for i := 0 ; i < nPilotsToRemove ; i ++ {
52+ for i := 1 ; i <= nPilotsToRemove ; i ++ {
4653 p := pilots [len (pilots )- i ].DeepCopy ()
4754 if p .Spec .Cassandra == nil {
4855 p .Spec .Cassandra = & v1alpha1.PilotCassandraSpec {}
@@ -51,14 +58,16 @@ func (a *ScaleIn) Execute(s *controllers.State) error {
5158 if ! p .Spec .Cassandra .Decommissioned {
5259 p .Spec .Cassandra .Decommissioned = true
5360 _ , err := s .NavigatorClientset .NavigatorV1alpha1 ().Pilots (p .Namespace ).Update (p )
54- if err == nil {
55- s .Recorder .Eventf (
56- p ,
57- corev1 .EventTypeNormal ,
58- a .Name (),
59- "Marked cassandra pilot %s for decommission" , p .Name ,
60- )
61+ if err != nil {
62+ return err
6163 }
64+
65+ s .Recorder .Eventf (
66+ p ,
67+ corev1 .EventTypeNormal ,
68+ a .Name (),
69+ "Marked cassandra pilot %s for decommission" , p .Name ,
70+ )
6271 }
6372
6473 if p .Status .Cassandra == nil {
You can’t perform that action at this time.
0 commit comments