openshift/builder

Panic in Build

Closed this issue · 9 comments

Rulox commented

Hi, I am deploying the following BuildConfig:

kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
  name: "test"
  namespace: "test"
spec:
  runPolicy: "Serial"
  source:
    git:
      uri: "<REPO_URI>"
      ref: "master"
    contextDir: "build"
  strategy:
    dockerStrategy:
      from:
        kind: "DockerImage"
        name: "debian:latest"
    type: "Docker"
  output:
    to:
      kind: "ImageStreamTag"
      name: "test:latest"

And when I try to run the build, I got a go panic (image doesn't even start building):

Cloning "<REPO_URI>" ...
	Commit:	<commit> (<commit_msg>)
	Author:	<author> <email>
	Date:	Wed Feb 5 13:43:23 2020 +0000
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(0xc000afe000, 0xc00031d180, 0x1, 0x1, 0x0, 0x2b0e858, 0x0, 0x0, 0xc000ad5080, 0x22, ...)
	/go/src/github.com/openshift/builder/vendor/github.com/openshift/imagebuilder/dispatchers.go:557 +0x179
github.com/openshift/builder/vendor/github.com/openshift/imagebuilder.(*Builder).Run(0xc000afe000, 0xc0009fa080, 0x1ab21a0, 0x2b0e858, 0x0, 0xc000a82c00, 0x10)
	/go/src/github.com/openshift/builder/vendor/github.com/openshift/imagebuilder/builder.go:323 +0x106
github.com/openshift/builder/vendor/github.com/openshift/imagebuilder.(*Builder).extractHeadingArgsFromNode(0xc000afe000, 0xc000cbf3b0, 0xc000d071e0, 0x122d1df)
	/go/src/github.com/openshift/builder/vendor/github.com/openshift/imagebuilder/builder.go:242 +0x32a
github.com/openshift/builder/vendor/github.com/openshift/imagebuilder.NewStages(0xc000cbf3b0, 0xc000afe000, 0x70, 0x70, 0x1799da0, 0x0, 0x0)
	/go/src/github.com/openshift/builder/vendor/github.com/openshift/imagebuilder/builder.go:201 +0x4d
github.com/openshift/builder/pkg/build/builder.replaceImagesFromSource(0xc000cbf3b0, 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(0xc000a545c0, 0x11, 0xc000cb8700, 0xc000cb43c0, 0x0, 0x0)
	/go/src/github.com/openshift/builder/pkg/build/builder/common.go:428 +0x337
github.com/openshift/builder/pkg/build/builder.ManageDockerfile(0xc000a545c0, 0x11, 0xc000cb8700, 0xc0002cd500, 0x0)
	/go/src/github.com/openshift/builder/pkg/build/builder/source.go:123 +0x2c5
github.com/openshift/builder/pkg/build/builder/cmd.RunManageDockerfile(0x1a8ae60, 0xc00000e020, 0x0, 0x0)
	/go/src/github.com/openshift/builder/pkg/build/builder/cmd/builder.go:411 +0xd9
main.NewCommandManageDockerfile.func1(0xc000a8a500, 0xc000cc20b0, 0x0, 0x1)
	/go/src/github.com/openshift/builder/cmd/builder.go:118 +0x43
github.com/openshift/builder/vendor/github.com/spf13/cobra.(*Command).execute(0xc000a8a500, 0xc00000c090, 0x1, 0x1, 0xc000a8a500, 0xc00000c090)
	/go/src/github.com/openshift/builder/vendor/github.com/spf13/cobra/command.go:833 +0x2cc
github.com/openshift/builder/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000a8a500, 0x2b, 0xc000047a6c, 0x30)
	/go/src/github.com/openshift/builder/vendor/github.com/spf13/cobra/command.go:917 +0x2f8
github.com/openshift/builder/vendor/github.com/spf13/cobra.(*Command).Execute(0xc000a8a500, 0x1b, 0xc000a8a500)
	/go/src/github.com/openshift/builder/vendor/github.com/spf13/cobra/command.go:867 +0x2b
main.main()
	/go/src/github.com/openshift/builder/cmd/main.go:58 +0x536

I am using CRC because I am developing an operator and I need this build as part of the process. Maybe Builds do not work in crc and I need a real cluster? (I have had a lot of problems in the past spinning up openshift clusters, so I hope not)

crc version: 1.4.0+d5bb3a3
OpenShift version: 4.2.13 (embedded in binary)
Docker version 19.03.2, build 6a30dfc

Any idea? Thanks in advance.

If we had the contents of the Dockerfile from the git repo in question, or just a pointer to the repo in question, we could see and reproducing this in real cluster to first see if it is CRC specific or not.

The panic being in some of the arcane bowels of imagebuilder is a bit hard to back track (especially without the Dockerfile contents).

Rulox commented

Hi @gabemontero that makes sense.

This is the dockerfile https://github.com/nginxinc/kubernetes-ingress/blob/master/build/Dockerfile

I didn't think about the dockerfile being the issue, I can try with an easier one to check as well. Thanks for all the help.

@Rulox Looks like you were running the build on 3.11. Multi-stage Dockerfile build support was tech preview there - in 4.x we switched to using https://github.com/containers/buildah to drive OpenShift builds. I encourage you to retry your build using okd4 - we do not plan on making any non-critical fixes to imagebuilder at this time.

@Rulox Looks like you were running the build on 3.11. Multi-stage Dockerfile build support was tech preview there

My apologies, I missed that this was running on 4.2 via CodeReady Containers. Reopening.

I'll try to repro with @Rulox 's #129 (comment) info today and if we see it in actual 4.x OCP (which @adambkaplan and I suspect will be the case), we'll transition this to a bugzilla.

I have reproduced this on an 4.x OCP cluster:

gmontero ~/customer-bzs/builder-img-imagebuilder-panic $ oc create -f bc.yaml
buildconfig.build.openshift.io/test created
gmontero ~/customer-bzs/builder-img-imagebuilder-panic $ oc start-build test --follow
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
gmontero ~/customer-bzs/builder-img-imagebuilder-panic $ 

I've transferred this over to https://bugzilla.redhat.com/show_bug.cgi?id=1801388

FYI @Rulox I'm initiating a PR for the fix in our 4.4/master branch via the bugzilla noted above.
TBD at this time as to whether we back port it to earlier 4.x versions.

The workaround is to not use the ARG step in your Dockerfile.

@gabemontero Hello, we would like to see this backported to 4.3. Do you think it will get to there? Or is it possible to use newer builder image with 4.3 ?

@gabemontero Hello, we would like to see this backported to 4.3. Do you think it will get to there? Or is it possible to use newer builder image with 4.3 ?

hey @danielkucera - yeah track https://bugzilla.redhat.com/show_bug.cgi?id=1801388 and subsequent cloned bugs from that to track backporting