Bug 1832975

Summary: Panic in openshift/builder imagebuilder processing dockerfile ARG step
Product: OpenShift Container Platform Reporter: OpenShift BugZilla Robot <openshift-bugzilla-robot>
Component: BuildAssignee: Gabe Montero <gmontero>
Status: CLOSED ERRATA QA Contact: wewang <wewang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.4CC: adam.kaplan, ansverma, aos-bugs, maupadhy, wzheng
Target Milestone: ---   
Target Release: 4.3.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Dockerfile parsing in openshift/builder was not initializing a map need for processing any ARG steps Consequence: OpenShift Docker Strategy Builds where the Dockerfile had an ARG step would panic and fail prior to invoking buildah. Fix: Initialized the map related to ARG step processing so golang would not panic on a nil reference. Result: OpenShift Docker Strategy Builds where the Dockerfile has an ARG step will not panic prior to invoking buildah.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-27 17:00:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1801388    
Bug Blocks:    

Description OpenShift BugZilla Robot 2020-05-07 14:48:02 UTC
This is a clone of Bug #1801388. This is the description of that bug:
See https://github.com/openshift/builder/issues/129

Also produced on ocp install in addition to crc

build.build.openshift.io/test-1 started
Cloning "https://github.com/nginxinc/kubernetes-ingress" ...
	Commit:	65c0fefd20f88aa3832a56e17c4c4e263f54e1c1 (Ensure clean up in fixtures and fix condition)
	Author:	tellet <tellet.tat>
	Date:	Fri Feb 7 14:35:22 2020 +0100
Replaced Dockerfile FROM image base
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/openshift/builder/vendor/github.com/openshift/imagebuilder.arg(0xc000152580, 0xc000828670, 0x1, 0x1, 0x0, 0x3375c98, 0x0, 0x0, 0xc0005a0750, 0x22, ...)
	/go/src/github.com/openshift/builder/vendor/github.com/openshift/imagebuilder/dispatchers.go:557 +0x234
github.com/openshift/builder/vendor/github.com/openshift/imagebuilder.(*Builder).Run(0xc000152580, 0xc000804d00, 0x1f6f3a0, 0x3375c98, 0x0, 0xc00068ee00, 0x10)
	/go/src/github.com/openshift/builder/vendor/github.com/openshift/imagebuilder/builder.go:324 +0xe5
github.com/openshift/builder/vendor/github.com/openshift/imagebuilder.(*Builder).extractHeadingArgsFromNode(0xc000152580, 0xc000705110, 0xc000781388, 0x14a3ccf)
	/go/src/github.com/openshift/builder/vendor/github.com/openshift/imagebuilder/builder.go:243 +0x341
github.com/openshift/builder/vendor/github.com/openshift/imagebuilder.NewStages(0xc000705110, 0xc000152580, 0xc0006c01c0, 0x1be4fe0, 0x1, 0x0, 0x1)
	/go/src/github.com/openshift/builder/vendor/github.com/openshift/imagebuilder/builder.go:201 +0x4d
github.com/openshift/builder/pkg/build/builder.replaceImagesFromSource(0xc000705110, 0x0, 0x0, 0x0, 0x0, 0x0)
	/go/src/github.com/openshift/builder/pkg/build/builder/common.go:451 +0x1a6
github.com/openshift/builder/pkg/build/builder.addBuildParameters(0xc00051dc60, 0x11, 0xc000430000, 0xc000303040, 0x0, 0x0)
	/go/src/github.com/openshift/builder/pkg/build/builder/common.go:428 +0x35c
github.com/openshift/builder/pkg/build/builder.ManageDockerfile(0xc00051dc60, 0x11, 0xc000430000, 0xc000474e80, 0x0)
	/go/src/github.com/openshift/builder/pkg/build/builder/source.go:123 +0x324
github.com/openshift/builder/pkg/build/builder/cmd.RunManageDockerfile(0x1f21280, 0xc000010020, 0x0, 0x0)
	/go/src/github.com/openshift/builder/pkg/build/builder/cmd/builder.go:411 +0xd6
main.NewCommandManageDockerfile.func1(0xc000708280, 0xc0007fbcb0, 0x0, 0x1)
	/go/src/github.com/openshift/builder/cmd/builder.go:118 +0x5c
github.com/openshift/builder/vendor/github.com/spf13/cobra.(*Command).execute(0xc000708280, 0xc00000e090, 0x1, 0x1, 0xc000708280, 0xc00000e090)
	/go/src/github.com/openshift/builder/vendor/github.com/spf13/cobra/command.go:830 +0x2ae
github.com/openshift/builder/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000708280, 0x1b, 0xc000708280, 0x1b)
	/go/src/github.com/openshift/builder/vendor/github.com/spf13/cobra/command.go:914 +0x2fc
github.com/openshift/builder/vendor/github.com/spf13/cobra.(*Command).Execute(...)
	/go/src/github.com/openshift/builder/vendor/github.com/spf13/cobra/command.go:864
main.main()
	/go/src/github.com/openshift/builder/cmd/main.go:68 +0x668

Comment 3 wewang 2020-05-15 06:45:05 UTC
Verified in version:
4.3.0-0.nightly-2020-05-14-202241

Steps:
 1. Use bc to create build
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  name: sample-build-docker-args-preset
spec:
  source:
    dockerfile: |-
      ARG foo=ab
      FROM centos
    type: Dockerfile
  strategy:
    dockerStrategy: {}
    type: Docker
2. Check the build
[wewang@wangwen ~]$ oc get builds
NAME                                TYPE     FROM         STATUS     STARTED          DURATION
sample-build-docker-args-preset-1   Docker   Dockerfile   Complete   45 seconds ago   35s

Comment 5 errata-xmlrpc 2020-05-27 17:00:46 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:2184