Bug 1785513 - 'oc describe' causes panic when describe a DC with HPA
Summary: 'oc describe' causes panic when describe a DC with HPA
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.3.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.4.0
Assignee: Maciej Szulik
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks: 1786062
TreeView+ depends on / blocked
 
Reported: 2019-12-20 05:19 UTC by Yadan Pei
Modified: 2020-05-04 11:21 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
: 1786062 (view as bug list)
Environment:
Last Closed: 2020-05-04 11:20:55 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Github openshift oc pull 227 None closed Bug 1785513: fix describe for HPA 2020-05-07 10:51:59 UTC
Red Hat Product Errata RHBA-2020:0581 None None None 2020-05-04 11:21:35 UTC

Description Yadan Pei 2019-12-20 05:19:27 UTC
Description of problem:
when a DC has HPA created, oc desribe it will cause panic

Version-Release number of selected component (if applicable):
$ oc version
Client Version: v4.3.0
Server Version: 4.3.0-0.nightly-2019-12-19-204222
Kubernetes Version: v1.16.2


How reproducible:
Always

Steps to Reproduce:
1. Create dc
$ oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git
2. Create HPA targeting dc/ruby-ex
$ cat > hpa.yaml << EOF
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: test-hpa
spec:
  scaleTargetRef:
    apiVersion: apps.openshift.io/v1
    kind: DeploymentConfig
    name: ruby-ex
  minReplicas: 1
  maxReplicas: 10
  metrics:   
  - type: Resource
    resource:
      name: cpu
      targetAverageUtilization: 50
  - type: Resource
    resource:
      name: memory
      targetAverageValue: 200Mi
EOF
$ oc create -f hpa.yaml
3. Check dc info using 'oc describe'
oc describe dc ruby-ex


Actual results:
3. it cause panic when run 'oc describe dc ruby-ex'
$ oc describe dc ruby-ex
panic: converting (v1.HorizontalPodAutoscaler).MaxReplicas to (autoscaling.HorizontalPodAutoscaler).MaxReplicas: Metrics not present in src

goroutine 1 [running]:
github.com/openshift/oc/pkg/helpers/describe.printAutoscalingInfo(0xc0015fed90, 0x2, 0x2, 0xc001323400, 0xf, 0xc0013233f0, 0x7, 0x33c6520, 0xc000e6e500, 0xc0015b2790)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/pkg/helpers/describe/deployments.go:346 +0xa42
github.com/openshift/oc/pkg/helpers/describe.printDeploymentConfigSpec(0x33c6520, 0xc000e6e500, 0x0, 0x0, 0x0, 0x0, 0xc0013233f0, 0x7, 0x0, 0x0, ...)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/pkg/helpers/describe/deployments.go:299 +0x314
github.com/openshift/oc/pkg/helpers/describe.(*DeploymentConfigDescriber).Describe.func1(0xc0015b2790, 0x32d7ec0, 0xc00136e480)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/pkg/helpers/describe/deployments.go:101 +0x1ed
github.com/openshift/oc/pkg/helpers/describe.tabbedString(0xc0015ffa20, 0x7ffc7facda1d, 0x7, 0x0, 0x0)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/pkg/helpers/describe/helpers.go:37 +0xb0
github.com/openshift/oc/pkg/helpers/describe.(*DeploymentConfigDescriber).Describe(0xc0014e1860, 0xc0012494f0, 0xf, 0x7ffc7facda1d, 0x7, 0x1, 0x203000, 0x432ef5, 0xc00167c6e0, 0x7fd7b956b6d6)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/pkg/helpers/describe/deployments.go:79 +0xa9
github.com/openshift/oc/vendor/k8s.io/kubectl/pkg/cmd/describe.(*DescribeOptions).Run(0xc000f3b220, 0x0, 0x2ecfe40)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/vendor/k8s.io/kubectl/pkg/cmd/describe/describe.go:190 +0x4ca
github.com/openshift/oc/vendor/k8s.io/kubectl/pkg/cmd/describe.NewCmdDescribe.func1(0xc000c9af00, 0xc0003e1400, 0x2, 0x2)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/vendor/k8s.io/kubectl/pkg/cmd/describe/describe.go:111 +0xa0
github.com/openshift/oc/vendor/github.com/spf13/cobra.(*Command).execute(0xc000c9af00, 0xc0003e13a0, 0x2, 0x2, 0xc000c9af00, 0xc0003e13a0)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:830 +0x2ae
github.com/openshift/oc/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000e7c280, 0x2, 0xc000e7c280, 0x2)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:914 +0x2fc
github.com/openshift/oc/vendor/github.com/spf13/cobra.(*Command).Execute(...)
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/vendor/github.com/spf13/cobra/command.go:864
main.main()
	/builddir/build/BUILD/openshift-clients-git-1.60c4109/__gopath/src/github.com/openshift/oc/cmd/oc/oc.go:107 +0x843


Expected results:
4. the command should work without panic and errors

Additional info:
Also reproduce with openshift-clients-4.3.0-201910250623-88-g6a937dfe, not sure which one is newer
./oc version
Client Version: openshift-clients-4.3.0-201910250623-88-g6a937dfe
Server Version: 4.3.0-0.nightly-2019-12-19-204222
Kubernetes Version: v1.16.2

Comment 2 zhou ying 2020-01-06 08:13:26 UTC
Confirmed with latest oc , can't reproduce the issue now:
[root@dhcp-140-138 ~]# oc version -o yaml
clientVersion:
  buildDate: ""
  compiler: gc
  gitCommit: ""
  gitTreeState: ""
  gitVersion: unknown
  goVersion: go1.13.4
  major: ""
  minor: ""
  platform: linux/amd64


[root@dhcp-140-138 ~]# oc describe dc ruby-ex
Name:		ruby-ex
Namespace:	zytest
Created:	49 seconds ago
Labels:		app=ruby-ex
		app.kubernetes.io/component=ruby-ex
		app.kubernetes.io/instance=ruby-ex
Annotations:	openshift.io/generated-by=OpenShiftNewApp
Latest Version:	Not deployed
Selector:	deploymentconfig=ruby-ex
Replicas:	1
Autoscaling:	between 1 and 10 replicas targeting 50% CPU over all the pods
Triggers:	Config, Image(ruby-ex@latest, auto=true)
Strategy:	Rolling
Template:
....

Events:	<none>

Comment 4 errata-xmlrpc 2020-05-04 11:20:55 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, 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/RHBA-2020:0581


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