Bug 1612023

Summary: Met panic when set build hook with a empty file
Product: OpenShift Container Platform Reporter: XiuJuan Wang <xiuwang>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: Xingxing Xia <xxia>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.11.0CC: aos-bugs, jokerman, mmccomas
Target Milestone: ---Keywords: Regression
Target Release: 3.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: When processing resources empty files were not omitted. Consequence: oc set build might cause a panic when encountered empty file. Fix: Properly handle situation with empty file. Result: oc set buildhook works as expected.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-03-14 02:17:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description XiuJuan Wang 2018-08-03 09:36:28 UTC
Description of problem:

Met panic when set build hook with a empty file

Version-Release number of selected component (if applicable):
oc v3.11.0-0.10.0
kubernetes v1.11.0+d4cacc0


How reproducible:
always

Steps to Reproduce:
1.Set build hook with a empty file
oc set build-hook -f emptyfile.json --post-commit=true --script=bundle\ exec\ rake\ test
2.
3.

Actual results:

$ oc set build-hook -f emptyfile.json --post-commit=true --script=bundle\ exec\ rake\ test 
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/openshift/origin/pkg/oc/cli/set.(*BuildHookOptions).Run(0xc420612480, 0x0, 0x0)
	/builddir/build/BUILD/atomic-openshift-git-0.c5fa1e4/_output/local/go/src/github.com/openshift/origin/pkg/oc/cli/set/buildhook.go:220 +0xcaa
github.com/openshift/origin/pkg/oc/cli/set.NewCmdBuildHook.func1(0xc4209c8000, 0xc4211f3680, 0x0, 0x4)
	/builddir/build/BUILD/atomic-openshift-git-0.c5fa1e4/_output/local/go/src/github.com/openshift/origin/pkg/oc/cli/set/buildhook.go:97 +0xb9
github.com/openshift/origin/vendor/github.com/spf13/cobra.(*Command).execute(0xc4209c8000, 0xc4211f3600, 0x4, 0x4, 0xc4209c8000, 0xc4211f3600)
	/builddir/build/BUILD/atomic-openshift-git-0.c5fa1e4/_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(0xc421054780, 0xc42000e010, 0xc42000e020, 0xc421054780)
	/builddir/build/BUILD/atomic-openshift-git-0.c5fa1e4/_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(0xc421054780, 0x2, 0xc421054780)
	/builddir/build/BUILD/atomic-openshift-git-0.c5fa1e4/_output/local/go/src/github.com/openshift/origin/vendor/github.com/spf13/cobra/command.go:794 +0x2b
main.main()
	/builddir/build/BUILD/atomic-openshift-git-0.c5fa1e4/_output/local/go/src/github.com/openshift/origin/cmd/oc/oc.go:49 +0x365


Expected results:
Shouldn't throw out panic

Additional info:

Comment 1 Juan Vallejo 2018-08-03 18:29:22 UTC
Origin PR: https://github.com/openshift/origin/pull/20535

Comment 2 XiuJuan Wang 2018-08-08 07:56:43 UTC
Waiting for puddle newer than v3.11.0-0.11.0.

Comment 3 XiuJuan Wang 2018-08-10 09:37:10 UTC
Verified with oc v3.11.0-0.13.0 client

$ oc set build-hook -f /tmp/emptyfile.json --post-commit=true --script=bundle\ exec\ rake\ test -n d54w3 
error: no resources found

Comment 6 errata-xmlrpc 2019-03-14 02:17:59 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-2019:0407