Description of problem: When `oc get -f emptylist.yaml -o=name` is provided an empty k8s List object, it panics. panic: runtime error: index out of range goroutine 1 [running]: github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/get.(*GetOptions).printGeneric(0xc4205575e0, 0xc42098ab80, 0x1, 0x1) /builddir/build/BUILD/openshift-git-0.509916c/_output/local/go/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/get/get.go:795 +0xf3b github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/get.(*GetOptions).Run(0xc4205575e0, 0x2d21240, 0xc42082a930, 0xc420962500, 0xc42150f9e0, 0x0, 0x3, 0x0, 0x0) /builddir/build/BUILD/openshift-git-0.509916c/_output/local/go/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/get/get.go:454 +0x1453 github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/get.NewCmdGet.func1(0xc420962500, 0xc42150f9e0, 0x0, 0x3) /builddir/build/BUILD/openshift-git-0.509916c/_output/local/go/src/github.com/openshift/origin/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/get/get.go:161 +0x115 github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).execute(0xc420962500, 0xc42150f9b0, 0x3, 0x3, 0xc420962500, 0xc42150f9b0) /builddir/build/BUILD/openshift-git-0.509916c/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:760 +0x2c1 github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc420643b80, 0xc421337df0, 0x13d57b9, 0xc420473e30) /builddir/build/BUILD/openshift-git-0.509916c/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:846 +0x30a github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).Execute(0xc420643b80, 0x2, 0xc420643b80) /builddir/build/BUILD/openshift-git-0.509916c/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:794 +0x2b main.main() /builddir/build/BUILD/openshift-git-0.509916c/_output/local/go/src/github.com/openshift/origin/cmd/oc/oc.go:68 +0x554 -o=yaml and -o=json also panic. Version-Release number of selected component (if applicable): 4.1.0-rc.0 How reproducible: 100% Steps to Reproduce: 1. oc get pods -l doesnotexist=true -o=yaml > emptylist.yaml 2. oc get -f emptylist.yaml -o=name # panic 3. oc get -f emptylist.yaml -o=json # panic 4. oc get -f emptylist.yaml -o=yaml # panic 5. cat emptylist.yaml | oc get -f - -o=name # NO panic 6. oc get -f emptylist.yaml # NO panic Actual results: The command line interface panics Expected results: A get on an empty list file should be consistent with input from stdin. No error / no results (or an empty list). Additional info: Preventing a panic here aids in programmatic use of the client binary. Several other variation behave as expected. Only a combination of -f <file> and -o seem to cause the problem.
Fix in https://github.com/openshift/origin/pull/22808
This is now addressed in: - https://github.com/kubernetes/kubernetes/pull/77681 - https://github.com/openshift/kubernetes/pull/75 I'll open oc bump once the latter PR merges.
Merged in https://github.com/openshift/oc/pull/63 moving to qa.
Verified in oc extracted from: oc adm release extract --command=oc registry.svc.ci.openshift.org/ocp/release:4.2.0-0.nightly-2019-08-21-040043 No panic now.
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-2019:2922