Bug 1612023 - Met panic when set build hook with a empty file
Summary: Met panic when set build hook with a empty file
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 3.11.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 3.11.0
Assignee: Maciej Szulik
QA Contact: Xingxing Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-08-03 09:36 UTC by XiuJuan Wang
Modified: 2019-03-14 02:18 UTC (History)
3 users (show)

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.
Clone Of:
Environment:
Last Closed: 2019-03-14 02:17:59 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:0407 0 None None None 2019-03-14 02:18:07 UTC

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


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