Bug 1821858 - Build incorrectly substitutes "=" for spaces in Dockerfiles
Summary: Build incorrectly substitutes "=" for spaces in Dockerfiles
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 4.2.z
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.5.0
Assignee: Nalin Dahyabhai
QA Contact: wewang
URL:
Whiteboard:
Depends On:
Blocks: 1821860
TreeView+ depends on / blocked
 
Reported: 2020-04-07 18:12 UTC by Adam Kaplan
Modified: 2020-07-13 17:26 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: Before starting a build, the OpenShift builder would parse the supplied Dockerfile and reconstruct a modified version of it to use for the build, to add labels and handle substitutions of the images named in FROM instructions. The generated Dockerfile did not always correctly reconstruct ENV and LABEL instructions. Consequence: The generated Dockerfile would sometimes include "=" characters where the original did not, and the build would fail with a syntax error. Fix: When generating the modified Dockerfile, the original text for ENV and LABEL instructions is now used verbatim. Result: The build process should no longer introduce syntax errors in ENV and LABEL instructions.
Clone Of:
: 1821860 (view as bug list)
Environment:
Last Closed: 2020-07-13 17:26:04 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Github openshift builder pull 134 None closed manage-dockerfile: use the original form of ENV/LABEL 2020-09-01 19:21:47 UTC
Red Hat Product Errata RHBA-2020:2409 None None None 2020-07-13 17:26:31 UTC

Internal Links: 1858779

Description Adam Kaplan 2020-04-07 18:12:35 UTC
Description of problem:

When rewriting the Dockerfile with our substitutions, we unconditionally insert = characters, even in cases where the original file didn't use them. They're syntactically important, though, so such changes can cause builds to fail. For ENV and LABEL instructions, just emit the original text.

Reported in openshift/origin#24151 [1]. Fixed by openshift/builder#134 [2]


Version-Release number of selected component (if applicable): 4.2.z


How reproducible: Always


Steps to Reproduce:

1. Create Docker fbuild from e.g.
   git url: https://github.com/sonatype/docker-nexus.git
   context dir: /oss
2. Start build

Actual results:

```
Cloning "https://github.com/sonatype/docker-nexus.git" ...
Commit: b892177cfb8b03d1d37a369b47ec57512051d67b (Update Repository Manager to 2.14.15-01.)
Author: Sonatype sonatype-ci@sonatype.com
Date: Tue Oct 15 13:50:45 2019 +0000
Caching blobs under "/var/cache/blobs".
error: build error: Syntax error - can't find = in "./conf/jetty-requestlog.xml". Must be of the form: name=value
```


Expected results:

Build succeeds


Additional info:

[1] https://github.com/openshift/origin/issues/24151
[2] https://github.com/openshift/builder/pull/134

Comment 4 wewang 2020-04-09 06:00:19 UTC
Verified in version:
4.5.0-0.nightly-2020-04-08-194554

Here's logs:
STEP 17: ENV JAVA_OPTS -server -Djava.net.preferIPv4Stack=true
time="2020-04-09T03:02:23Z" level=info msg="Image operating system mismatch: image uses \"\", expecting \"linux\""
time="2020-04-09T03:02:23Z" level=info msg="Image architecture mismatch: image uses \"\", expecting \"amd64\""
--> 0557c4252ad
STEP 18: ENV LAUNCHER_CONF ./conf/jetty.xml ./conf/jetty-requestlog.xml
time="2020-04-09T03:02:23Z" level=info msg="Image operating system mismatch: image uses \"\", expecting \"linux\""
time="2020-04-09T03:02:23Z" level=info msg="Image architecture mismatch: image uses \"\", expecting \"amd64\""
--> a31bca72f05
STEP 19: CMD java   -Dnexus-work=${SONATYPE_WORK} -Dnexus-webapp-context-path=${CONTEXT_PATH}   -Xms${MIN_HEAP} -Xmx${MAX_HEAP}   -cp 'conf/:lib/*'   ${JAVA_OPTS}   org.sonatype.nexus.bootstrap.Launcher ${LAUNCHER_CONF}
time="2020-04-09T03:02:23Z" level=info msg="Image operating system mismatch: image uses \"\", expecting \"linux\""
time="2020-04-09T03:02:23Z" level=info msg="Image architecture mismatch: image uses \"\", expecting \"amd64\""
--> adc69d2ecb2
STEP 20: ENV "OPENSHIFT_BUILD_NAME"="docker-nexus-1" "OPENSHIFT_BUILD_NAMESPACE"="wewang" "OPENSHIFT_BUILD_SOURCE"="https://github.com/sonatype/docker-nexus" "OPENSHIFT_BUILD_COMMIT"="78d9bdefeb4b1428ef18d2184544a827c9a1a1d2"
time="2020-04-09T03:02:23Z" level=info msg="Image operating system mismatch: image uses \"\", expecting \"linux\""
time="2020-04-09T03:02:23Z" level=info msg="Image architecture mismatch: image uses \"\", expecting \"amd64\""
--> a8ae63e855a
STEP 21: LABEL "io.openshift.build.commit.author"="Sonatype \u003csonatype-ci@sonatype.com\u003e" "io.openshift.build.commit.date"="Fri Jan 17 14:44:31 2020 +0000" "io.openshift.build.commit.id"="78d9bdefeb4b1428ef18d2184544a827c9a1a1d2" "io.openshift.build.commit.message"="Update Repository Manager to 2.14.16-01." "io.openshift.build.commit.ref"="master" "io.openshift.build.name"="docker-nexus-1" "io.openshift.build.namespace"="wewang" "io.openshift.build.source-context-dir"="/oss" "io.openshift.build.source-location"="https://github.com/sonatype/docker-nexus"
STEP 22: COMMIT temp.builder.openshift.io/wewang/docker-nexus-1:8e05830d
time="2020-04-09T03:02:23Z" level=info msg="Image operating system mismatch: image uses \"\", expecting \"linux\""
time="2020-04-09T03:02:23Z" level=info msg="Image architecture mismatch: image uses \"\", expecting \"amd64\""
--> c01ad9e9201
c01ad9e9201a90ac2baa264db7f4a6ce42ec70c17355de47b0174bd3512457fa

Pushing image image-registry.openshift-image-registry.svc:5000/wewang/docker-nexus:latest ...
Getting image source signatures
Copying blob sha256:23302e52b49d49a0a25da8ea870bc1973e7d51c9b306f3539cd397318bd8b0a5
Copying blob sha256:0087bd62e0e6e62a7467cb4f1712c61d93de64db7ee3e5a8a8a546ee376e8c00
Copying blob sha256:cf5693de4d3cdd6f352978b87c8f89ead294eff44938598f57a91cf7a02417d2
Copying blob sha256:87c2d23f31e6405dcadb8cea2465560a2b487051fdc339b5527ca5524e56461d
Copying blob sha256:ea84c9db28abf2ba266f8e3df65f363d5de138f8abe9e037f9c5fe3db933f840
Copying config sha256:c01ad9e9201a90ac2baa264db7f4a6ce42ec70c17355de47b0174bd3512457fa
Writing manifest to image destination
Storing signatures
Successfully pushed image-registry.openshift-image-registry.svc:5000/wewang/docker-nexus@sha256:529e9dddae992a6eef6f5329f79cc9d69cc2c3740b9f344617f15a0fcb80f7ab
Push successful

Comment 5 errata-xmlrpc 2020-07-13 17:26:04 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:2409


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