recombining the condition for shouldScale function
Signed-off-by: PingWang <wang.ping5@zte.com.cn>
This commit is contained in:
		@@ -355,19 +355,19 @@ func shouldScale(hpa *autoscaling.HorizontalPodAutoscaler, currentReplicas, desi
 | 
				
			|||||||
		return false
 | 
							return false
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if hpa.Status.LastScaleTime == nil {
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Going down only if the usageRatio dropped significantly below the target
 | 
						// Going down only if the usageRatio dropped significantly below the target
 | 
				
			||||||
	// and there was no rescaling in the last downscaleForbiddenWindow.
 | 
						// and there was no rescaling in the last downscaleForbiddenWindow.
 | 
				
			||||||
	if desiredReplicas < currentReplicas &&
 | 
						if desiredReplicas < currentReplicas && hpa.Status.LastScaleTime.Add(downscaleForbiddenWindow).Before(timestamp) {
 | 
				
			||||||
		(hpa.Status.LastScaleTime == nil ||
 | 
					 | 
				
			||||||
			hpa.Status.LastScaleTime.Add(downscaleForbiddenWindow).Before(timestamp)) {
 | 
					 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Going up only if the usage ratio increased significantly above the target
 | 
						// Going up only if the usage ratio increased significantly above the target
 | 
				
			||||||
	// and there was no rescaling in the last upscaleForbiddenWindow.
 | 
						// and there was no rescaling in the last upscaleForbiddenWindow.
 | 
				
			||||||
	if desiredReplicas > currentReplicas &&
 | 
						if desiredReplicas > currentReplicas && hpa.Status.LastScaleTime.Add(upscaleForbiddenWindow).Before(timestamp) {
 | 
				
			||||||
		(hpa.Status.LastScaleTime == nil ||
 | 
					 | 
				
			||||||
			hpa.Status.LastScaleTime.Add(upscaleForbiddenWindow).Before(timestamp)) {
 | 
					 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return false
 | 
						return false
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user