• Joseph Burnett's avatar
    There are various reasons that the HPA will decide not the change the · d881d48b
    Joseph Burnett authored
    current scale. Two important ones are when missing metrics might
    change the direction of scaling, and when the recommended scale is
    within tolerance of the current scale.
    
    The way that ReplicaCalculator signals it's desire to not change the
    current scale is by returning the current scale. However the current
    scale is from scale.Status.Replicas and can be larger than
    scale.Spec.Replicas (e.g. during Deployment rollout with configured
    surge). This causes a positive feedback loop because
    scale.Status.Replicas is written back into scale.Spec.Replicas,
    further increasing the current scale.
    
    This PR fixes the feedback loop by plumbing the replica count from
    spec through horizontal.go and replica_calculator.go so the calculator
    can punt with the right value.
    d881d48b