Skip to content

Conversation

@dnephin
Copy link
Member

@dnephin dnephin commented Jun 16, 2017

Carry #29161
Related issues #29005 and #24693

Add a warning that support for empty continuation lines will be removed in a future release.

@dnephin dnephin requested review from tonistiigi and yongtang June 16, 2017 22:09
@dnephin dnephin changed the title Warn on empty continuation carry [Builder] Warn on empty continuation lines Jun 16, 2017
@cpuguy83
Copy link
Member

Needs a rebase.

@dnephin dnephin force-pushed the warn-on-empty-continuation-carry branch from 853d191 to 739076f Compare June 22, 2017 15:32
@dnephin
Copy link
Member Author

dnephin commented Jun 22, 2017

rebased

@cpuguy83
Copy link
Member

08:32:34 Please reformat the above files using "gofmt -s -w" and commit the result.

@dnephin dnephin force-pushed the warn-on-empty-continuation-carry branch from 739076f to 738d28c Compare June 22, 2017 16:06
@thaJeztah
Copy link
Member

Should we print the warnings at the end? They're currently before with the output of the build itself, possibly resulting in them being overlooked (thinking out loud here);

docker build --no-cache -<<'EOF'
> FROM busybox
> RUN echo "hello" \
>
>     echo "world" \
>
>     echo "more"
>
> RUN echo "another" \
>
>     echo "thing"
> EOF
Sending build context to Docker daemon  2.048kB
[WARNING]: Empty continuation line found in:
    RUN echo "hello"     echo "world"     echo "more"
[WARNING]: Empty continuation line found in:
    RUN echo "another"     echo "thing"
[WARNING]: Empty continuation lines will become errors in a future release.Step 1/3 : FROM busybox
latest: Pulling from library/busybox
27144aa8f1b9: Pull complete
Digest: sha256:be3c11fdba7cfe299214e46edc642e09514dbb9bbefcd0d3836c05a1e0cd0642
Status: Downloaded newer image for busybox:latest
 ---> c30178c5239f
Step 2/3 : RUN echo "hello"     echo "world"     echo "more"
 ---> Running in d6b32caa72b0
hello echo world echo more
 ---> 427b597ff574
Removing intermediate container d6b32caa72b0
Step 3/3 : RUN echo "another"     echo "thing"
 ---> Running in fce314282e52
another echo thing
 ---> ea484a04ae35
Removing intermediate container fce314282e52
Successfully built ea484a04ae35

Also the last warning seems to be missing a newline (causing the Step 1/3 : to appear on the same line)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a newline after

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed in PrintWarnings()

This fix is related to 29005 and 24693. Currently in `Dockerfile`
empty lines will continue as long as there is line escape before.
This may cause some issues. The issue in 24693 is an example.
A non-empty line after an empty line might be considered to be a
separate instruction by many users. However, it is actually part
of the last instruction under the current `Dockerfile` parsing
rule.

This fix is an effort to reduce the confusion around the parsing
of `Dockerfile`. Even though this fix does not change the behavior
of the `Dockerfile` parsing, it tries to deprecate the empty line
continuation and present a warning for the user. In this case,
at least it prompt users to check for the Dockerfile and avoid
the confusion if possible.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@dnephin dnephin force-pushed the warn-on-empty-continuation-carry branch from 738d28c to f12b183 Compare June 23, 2017 17:12
Signed-off-by: Daniel Nephin <dnephin@docker.com>
@dnephin dnephin force-pushed the warn-on-empty-continuation-carry branch from f12b183 to b47b375 Compare June 23, 2017 17:15
@dnephin
Copy link
Member Author

dnephin commented Jun 23, 2017

Should we print the warnings at the end?

Ya, I guess so. I've moved it to right before we warn about unused build args, so warnings should be together now.

It means that if the build fails they wont see the warnings, but that's probably fine.

@tonistiigi
Copy link
Member

LGTM

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @yongtang @dnephin !

@thaJeztah
Copy link
Member

All green

@thaJeztah thaJeztah merged commit 8d1ae76 into moby:master Jun 24, 2017
@dnephin dnephin deleted the warn-on-empty-continuation-carry branch June 24, 2017 05:59
@JayH5
Copy link

JayH5 commented Sep 4, 2017

Is it intentional that this also warns for comment lines? e.g.

$ docker build --no-cache -<<'EOF'
> FROM busybox
> RUN echo "hello" \
> # Earth
>     echo "world"
> EOF
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM busybox
 ---> d20ae45477cb
Step 2/2 : RUN echo "hello"     echo "world"
 ---> Running in 54ffa81586b9
hello echo world
 ---> 70e0a0659834
Removing intermediate container 54ffa81586b9
[WARNING]: Empty continuation line found in:
    RUN echo "hello"     echo "world"
[WARNING]: Empty continuation lines will become errors in a future release.
Successfully built 70e0a0659834

This makes it so that it is not possible to add comments inside long RUN commands.

weiji14 added a commit to weiji14/dat-docker that referenced this pull request Sep 8, 2017
Moved apt-get install ca-certificates, curl and gnupg2 (previously gnupg) to the top a la buildpack-deps style. Only reason not using buildpack-deps directly is because they currently rely on the non-slim variant of debian, and there is additional wget dependency.

Also migrated nodejs/npm installation near to the top of the dockerfile so as to better sync with my beakerbrowser dockerfile.

Lastly, fixed an annoying issue with "[WARNING]: Empty continuation lines will become errors in a future release." This messes with my previously neat inline comments!!! See moby/moby#33719
weiji14 added a commit to weiji14/beaker-browser that referenced this pull request Sep 8, 2017
Moved apt-get install ca-certificates, curl and gnupg2 (previously gnupg) to the top a la buildpack-deps style. Only reason not using buildpack-deps directly is because they currently rely on the non-slim variant of debian, and there is additional wget dependency.

Also migrated nodejs/npm installation near to the top of the dockerfile so as to better sync with my dat dockerfile. Note that NODE_VERSION has changed from 6 to 8. Placed npm install && npm run burnthemall together to save an additional couple of hundred MBs worth of disk space.

Lastly, fixed the annoying issue with "[WARNING]: Empty continuation lines will become errors in a future release." This messes with my previously neat inline comments!!! See moby/moby#33719
voobscout pushed a commit to voobscout/dockerfiles that referenced this pull request Sep 13, 2017
@tianon
Copy link
Member

tianon commented Sep 15, 2017

Indeed, @JayH5 is correct -- this appears to have the same bug as the previous implementation of this (although in that case it was an error instead of a warning, so that's progress of a sort).

I've also verified that this incorrect comment-line-handling behavior has persisted into the most recent 17.09 release candidate.

cc @thaJeztah

@JayH5
Copy link

JayH5 commented Sep 27, 2017

@tianon FWIW, my colleague found some discussion about fixing this in #34333

mrled added a commit to mrled/psyops that referenced this pull request Jan 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants