Skip to content

Commit

Permalink
fix: properly write desired replicas count in scale conditions
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Unix4ever committed Apr 13, 2023
1 parent 4bdb103 commit b10e2e7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions controllers/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import (

func (r *TalosControlPlaneReconciler) scaleUpControlPlane(ctx context.Context, cluster *clusterv1.Cluster, tcp *controlplanev1.TalosControlPlane, controlPlane *ControlPlane) (ctrl.Result, error) {
numMachines := len(controlPlane.Machines)
desiredReplicas := tcp.Spec.Replicas
desiredReplicas := 0

if tcp.Spec.Replicas != nil {
desiredReplicas = int(*tcp.Spec.Replicas)
}

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

numMachines := len(controlPlane.Machines)
desiredReplicas := tcp.Spec.Replicas
desiredReplicas := 0

if tcp.Spec.Replicas != nil {
desiredReplicas = int(*tcp.Spec.Replicas)
}

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

0 comments on commit b10e2e7

Please sign in to comment.