Horizontal Pod Autoscaler (HPA) fails getting CPU consumption and reports unknown for current cpu usage : "the HPA was unable to compute the replica count" in OCP 4 with apiVersion autoscaling/v1

Solution Verified - Updated -

Issue

  • The Horizontal Pod Autoscaler (HPA) metrics shows <unknown> in the summary view under TARGETS:

    $ oc get hpa
    NAME         REFERENCE                      TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
    <hpa_name>   Deployment/<deployment_name>   <unknown>/40%   1         10        1          3m23s
    
  • The Horizontal Pod Autoscaler (HPA) metrics shows <unknown> for the current usage and error messages in the conditions:

    $ oc describe hpa <hpa_name>
    [...]
    Metrics:                                               ( current / target )
      resource cpu on pods  (as a percentage of request):  <unknown> / 50%
    [...]
    Conditions:
      Type           Status  Reason                   Message
      ----           ------  ------                   -------
      AbleToScale    True    SucceededGetScale        the HPA controller was able to get the target's current scale
      ScalingActive  False   FailedGetResourceMetric  the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API
    [...]
    
    $ oc get hpa <hpa_name> -o yaml
    [...]
    conditions:
    - type: AbleToScale
      status: 'True'
      lastTransitionTime: '2020-06-30T15:05:26Z'
      reason: SucceededGetScale
      message: the HPA controller was able to get the target's current scale
    - type: ScalingActive
      status: 'False'
      lastTransitionTime: '2020-06-30T15:05:26Z'
      reason: FailedGetResourceMetric
      message: 'the HPA was unable to compute the replica count: missing request for cpu'
    [...]
    
  • The HorizontalPodAutoscaler was defined with apiVersion: autoscaling/v1 and targetCPUUtilizationPercentage

Environment

  • Red Hat OpenShift Container Platform 4 (RHOCP, OCP)
  • HorizontalPodAutoscaler with apiVersion: autoscaling/v1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content