Skip to content

Commit b10e2e7

Browse files
committed
fix: properly write desired replicas count in scale conditions
Fixes: #155 We were reading it from `*int` pointer without dereferencing it, so it was writing pointer address to the status instead of the actual value. Signed-off-by: Artem Chernyshev <[email protected]>
1 parent 4bdb103 commit b10e2e7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

controllers/scale.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ import (
2424

2525
func (r *TalosControlPlaneReconciler) scaleUpControlPlane(ctx context.Context, cluster *clusterv1.Cluster, tcp *controlplanev1.TalosControlPlane, controlPlane *ControlPlane) (ctrl.Result, error) {
2626
numMachines := len(controlPlane.Machines)
27-
desiredReplicas := tcp.Spec.Replicas
27+
desiredReplicas := 0
28+
29+
if tcp.Spec.Replicas != nil {
30+
desiredReplicas = int(*tcp.Spec.Replicas)
31+
}
2832

2933
conditions.MarkFalse(tcp, controlplanev1.ResizedCondition, controlplanev1.ScalingUpReason, clusterv1.ConditionSeverityWarning,
3034
"Scaling up control plane to %d replicas (actual %d)",
@@ -44,7 +48,11 @@ func (r *TalosControlPlaneReconciler) scaleDownControlPlane(
4448
machinesRequireUpgrade collections.Machines) (ctrl.Result, error) {
4549

4650
numMachines := len(controlPlane.Machines)
47-
desiredReplicas := tcp.Spec.Replicas
51+
desiredReplicas := 0
52+
53+
if tcp.Spec.Replicas != nil {
54+
desiredReplicas = int(*tcp.Spec.Replicas)
55+
}
4856

4957
conditions.MarkFalse(tcp, controlplanev1.ResizedCondition, controlplanev1.ScalingDownReason, clusterv1.ConditionSeverityWarning,
5058
"Scaling down control plane to %d replicas (actual %d)",

0 commit comments

Comments
 (0)