From 7a2d6cbb28214dfbd8ab8e4749a29d166f84dc17 Mon Sep 17 00:00:00 2001 From: Himanshu Sharma Date: Tue, 10 Jan 2023 18:44:35 +0530 Subject: [PATCH] reverting changes to isScalingEvent fn --- pkg/controller/deployment.go | 2 +- pkg/controller/deployment_sync.go | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/pkg/controller/deployment.go b/pkg/controller/deployment.go index 9bab8a839..b31bad1d0 100644 --- a/pkg/controller/deployment.go +++ b/pkg/controller/deployment.go @@ -539,7 +539,7 @@ func (dc *controller) reconcileClusterMachineDeployment(key string) error { return dc.rollback(ctx, d, machineSets, machineMap) } - scalingEvent, _, err := dc.isScalingEvent(ctx, d, machineSets, machineMap) + scalingEvent, err := dc.isScalingEvent(ctx, d, machineSets, machineMap) if err != nil { return err diff --git a/pkg/controller/deployment_sync.go b/pkg/controller/deployment_sync.go index 6bf662b7a..6e29232a5 100644 --- a/pkg/controller/deployment_sync.go +++ b/pkg/controller/deployment_sync.go @@ -670,28 +670,20 @@ func calculateDeploymentStatus(allISs []*v1alpha1.MachineSet, newIS *v1alpha1.Ma // // rsList should come from getReplicaSetsForDeployment(d). // machineMap should come from getmachineMapForDeployment(d, rsList). -func (dc *controller) isScalingEvent(ctx context.Context, d *v1alpha1.MachineDeployment, isList []*v1alpha1.MachineSet, machineMap map[types.UID]*v1alpha1.MachineList) (bool, bool, error) { +func (dc *controller) isScalingEvent(ctx context.Context, d *v1alpha1.MachineDeployment, isList []*v1alpha1.MachineSet, machineMap map[types.UID]*v1alpha1.MachineList) (bool, error) { newIS, oldISs, err := dc.getAllMachineSetsAndSyncRevision(ctx, d, isList, machineMap, false) - scaled := false - isScaleUp := false if err != nil { - return scaled, isScaleUp, err + return false, err } allISs := append(oldISs, newIS) for _, is := range FilterActiveMachineSets(allISs) { - prevDesired, ok := GetDesiredReplicasAnnotation(is) + desired, ok := GetDesiredReplicasAnnotation(is) if !ok { continue } - if prevDesired != (d.Spec.Replicas) { - if prevDesired < d.Spec.Replicas { - isScaleUp = true - } - scaled = true - klog.V(4).Infof("(isScalingEvent) Scaling detected for machineDeployment %s. scaled=%s, isScaledUp=%s ", d.Name, scaled, isScaleUp) - break + if desired != (d.Spec.Replicas) { + return true, nil } } - - return scaled, isScaleUp, nil + return false, nil }