Bug 1801388 - Panic in openshift/builder imagebuilder processing dockerfile ARG step
Summary: Panic in openshift/builder imagebuilder processing dockerfile ARG step
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 4.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.4.0
Assignee: Gabe Montero
QA Contact: wewang
URL:
Whiteboard:
Depends On:
Blocks: 1801875 1832975
TreeView+ depends on / blocked
 
Reported: 2020-02-10 18:54 UTC by Gabe Montero
Modified: 2020-05-26 13:04 UTC (History)
6 users (show)

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.
Clone Of:
: 1801875 (view as bug list)
Environment:
Last Closed: 2020-05-04 11:35:28 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Github openshift builder pull 130 None closed Bug 1801388: use of ARG step in Dockerfile causes panic in imagebuilder (openshift… 2020-09-19 16:19:08 UTC
Red Hat Product Errata RHBA-2020:0581 None None None 2020-05-04 11:35:55 UTC

Description Gabe Montero 2020-02-10 18:54:28 UTC
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@gmail.com>
	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 1 Gabe Montero 2020-02-10 22:25:03 UTC
Reproduced with a unit test based on the Dockerfile and build config from https://github.com/openshift/builder/issues/129

Comment 2 Gabe Montero 2020-02-10 22:50:50 UTC
Have fix in hand (one liner) ... just cleaning up / simplifying the unit test

Comment 3 Gabe Montero 2020-02-12 15:41:09 UTC
Note to QE, we have a simplified reproducer:

apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  name: sample-build-docker-args-preset
spec:
  source:
    dockerfile: |-
      FROM centos
      ARG foo=centos
      FROM $foo
    type: Dockerfile
  strategy:
    dockerStrategy: {}
    type: Docker


which results in 

I0211 22:06:43.140914       1 builder.go:318] Starting Docker build from build config sample-build-docker-args-preset-17 ...
F0211 22:06:43.209605       1 helpers.go:114] error: build error: error parsing name "$foo": error parsing image name "$foo": invalid reference format

So at least the panic does not occur.

Bug https://bugzilla.redhat.com/show_bug.cgi?id=1801875 has been opened against buildah so that we do not get 

F0211 22:06:43.209605       1 helpers.go:114] error: build error: error parsing name "$foo": error parsing image name "$foo": invalid reference format

Comment 5 Gabe Montero 2020-02-13 14:28:33 UTC
Sorry one tweak to Ben's reproducer in #Comment 3

To get the panic, the dockerfile contents should just be 

      ARG foo=centos
      FROM $foo


The `FROM centos` was added to work around the panic in constructing a simple reproducer for https://bugzilla.redhat.com/show_bug.cgi?id=1801875

Comment 6 wewang 2020-02-14 07:26:23 UTC
Thanks Gabe, I can reproduce the bug about Arg problem, and verified in 
4.4.0-0.nightly-2020-02-13-192852

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. Using old cluster version,will have error
http://pastebin.test.redhat.com/836101

3. Using the latest version, the error is fixed.
[wewang@wangwen ~]$ oc get builds
NAME                                TYPE     FROM         STATUS                        STARTED         DURATION
sample-build-docker-args-preset-1   Docker   Dockerfile   Complete                      8 minutes ago   20s

Comment 7 wewang 2020-02-14 07:37:16 UTC
FYI, About the following 2 scenarios still failed with "error: build error: error parsing name "$foo": error parsing image name "$foo": invalid reference format" in current latest cluster, will test them when https://bugzilla.redhat.com/show_bug.cgi?id=1801875 is fixed.

Scenario 1:
     source:
      dockerfile: |-
        ARG foo=centos
        FROM $foo
      type: Dockerfile

Scenario 2:
    dockerfile: |-
      FROM centos
      ARG foo=centos
      FROM $foo
    type: Dockerfile

Comment 8 wewang 2020-02-14 07:47:14 UTC
Already had a bug to track about Comment 7: https://bugzilla.redhat.com/show_bug.cgi?id=1802202

Comment 10 errata-xmlrpc 2020-05-04 11:35:28 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.