Skip to content

Commit 53fa54b

Browse files
authored
Add extra logging and event detail when attempting to scale down cluster (#828)
* Add extra logging and event detail when attempting to scale down cluster * Fix integration tests
1 parent 367e858 commit 53fa54b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

controllers/reconcile_scale_down.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package controllers
33
import (
44
"context"
55
"errors"
6+
"fmt"
7+
68
"github.com/go-logr/logr"
79
"github.com/rabbitmq/cluster-operator/api/v1beta1"
810
"github.com/rabbitmq/cluster-operator/internal/status"
@@ -18,7 +20,7 @@ func (r *RabbitmqClusterReconciler) scaleDown(ctx context.Context, cluster *v1be
1820
currentReplicas := *current.Spec.Replicas
1921
desiredReplicas := *sts.Spec.Replicas
2022
if currentReplicas > desiredReplicas {
21-
msg := "Cluster Scale down not supported"
23+
msg := fmt.Sprintf("Cluster Scale down not supported; tried to scale cluster from %d nodes to %d nodes", currentReplicas, desiredReplicas)
2224
reason := "UnsupportedOperation"
2325
logger.Error(errors.New(reason), msg)
2426
r.Recorder.Event(cluster, corev1.EventTypeWarning, reason, msg)

controllers/reconcile_scale_down_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package controllers_test
33
import (
44
"context"
55
"fmt"
6+
67
. "github.com/onsi/ginkgo"
78
. "github.com/onsi/gomega"
89
rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
@@ -79,7 +80,7 @@ var _ = Describe("Cluster scale down", func() {
7980
return "ReconcileSuccess status: condition not present"
8081
}, 5).Should(Equal("ReconcileSuccess status: False, " +
8182
"with reason: UnsupportedOperation " +
82-
"and message: Cluster Scale down not supported"))
83+
"and message: Cluster Scale down not supported; tried to scale cluster from 5 nodes to 3 nodes"))
8384
})
8485
})
8586
})

0 commit comments

Comments
 (0)