Skip to content

Commit

Permalink
reverting changes to isScalingEvent fn
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-kun committed Jan 10, 2023
1 parent dd28746 commit 7a2d6cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 6 additions & 14 deletions pkg/controller/deployment_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 7a2d6cb

Please sign in to comment.