Bug 2054693 - Error deploying HorizontalPodAutoscaler with oc new-app command in OpenShift 4
Summary: Error deploying HorizontalPodAutoscaler with oc new-app command in OpenShift 4
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.6.z
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.11.0
Assignee: Maciej Szulik
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-02-15 14:08 UTC by JS
Modified: 2022-08-10 10:50 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-08-10 10:49:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift api pull 1123 0 None open Bug 2054693: add missing k8s APIs 2022-02-17 12:08:41 UTC
Red Hat Product Errata RHSA-2022:5069 0 None None None 2022-08-10 10:50:23 UTC

Description JS 2022-02-15 14:08:04 UTC
# Description of problem:

An error will be returned when trying to deploy using `oc new-app` CLI and a `Template` with `HorizontalPodAutoscaler` `autoscaling/v2beta2` on the `Template` object list:

~~~
error: no kind is registered for the type v2beta2.HorizontalPodAutoscaler in scheme "github.com/openshift/oc/pkg/cli/newapp/scheme.go:23"
~~~

Example `Template`:
~~~
kind: Template
apiVersion: template.openshift.io/v1
metadata:
  name: template-ubi
objects:
- kind: DeploymentConfig
  apiVersion: apps.openshift.io/v1
  metadata:
    name: hpa-deploymentconfig
  spec:
    selector:
      app_name: hpa-deploymentconfig
      deploymentconfig: hpa-deploymentconfig
    template:
      metadata:
        labels:
          app_name: hpa-deploymentconfig
          deploymentconfig: hpa-deploymentconfig
        name: hpa-deploymentconfig
      spec:
        containers:
          - image: registry.access.redhat.com/ubi8/ubi:8.5-226
            name: hpa-deploymentconfig
- apiVersion: autoscaling/v2beta2 
  kind: HorizontalPodAutoscaler
  metadata:
    name: hpa-test-hpa-resource-metrics-memory
  spec:
    scaleTargetRef:
      apiVersion: apps.openshift.io/v1
      kind: DeploymentConfig 
      name: hpa-deploymentconfig 
    minReplicas: 1 
    maxReplicas: 10
    metrics: 
    - type: Resource
      resource:
        name: memory 
        target:
          type: Utilization 
          averageUtilization: 70
~~~        

API `autoscaling/v2beta2` it's required to be used for autoscaling based on memory utilization according to [Creating a horizontal pod autoscaler object for memory utilization by using the CLI [1]

[1] https://docs.openshift.com/container-platform/4.6/nodes/pods/nodes-pods-autoscaling.html#nodes-pods-autoscaling-creating-memory_nodes-pods-autoscaling


# Version-Release number of selected component (if applicable):

- Tested with OpenShift 4.6.42 and 4.9.19

# How reproducible:

- Always

# Steps to Reproduce:
1.Create a `Template` with above shared info

2.Try to run with `dry-run` and error will be returned:
~~~
        $ oc new-app -f templatefull.yaml --dry-run           
        --> Deploying template "test02/template-ubi" for "templatefull.yaml" to project test02
        
        --> Creating resources ...
            deploymentconfig.apps.openshift.io "hpa-deploymentconfig" created (dry run)
            error: no kind is registered for the type v2beta2.HorizontalPodAutoscaler in scheme "github.com/openshift/oc/pkg/cli/newapp/scheme.go:23"
        --> Failed (dry run)
~~~

# Expected results:

- `oc new-app` should deploy items with success.

# Additional info:

- The workaround it's to decouple `HorizontalPodAutoscaler` from `Template` object list and apply it after as standalone.
- If `apiVersion: autoscaling/v2beta1` it's used instead of `apiVersion: autoscaling/v2beta2` it will deploy successfully

Comment 2 Maciej Szulik 2022-03-04 15:47:41 UTC
We still need to bump the api in oc.

Comment 3 Maciej Szulik 2022-05-31 11:28:48 UTC
Done recently in https://github.com/openshift/oc/pull/1092

Comment 5 zhou ying 2022-06-01 06:06:26 UTC
can't reproduce the issue now :

oc new-app -f /tmp/templatefull.yaml --dry-run 
--> Deploying template "zhouyt/template-ubi" for "/tmp/templatefull.yaml" to project zhouyt

--> Creating resources ...
    deploymentconfig.apps.openshift.io "hpa-deploymentconfig" created (dry run)
    horizontalpodautoscaler.autoscaling "hpa-test-hpa-resource-metrics-memory" created (dry run)
--> Success (dry run)
[root@localhost ~]# oc version 
Client Version: 4.11.0-0.nightly-2022-05-26-013101
Kustomize Version: v4.5.4

Comment 7 errata-xmlrpc 2022-08-10 10:49:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: OpenShift Container Platform 4.11.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5069


Note You need to log in before you can comment on or make changes to this bug.