Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log is not enabled if Dockerfile present. #1291

Closed
dpwrussell opened this issue Nov 14, 2019 · 3 comments
Closed

Log is not enabled if Dockerfile present. #1291

dpwrussell opened this issue Nov 14, 2019 · 3 comments

Comments

@dpwrussell
Copy link

Description

Under certain conditions, logging does not get correctly enabled. This is not a definitive list!

Basically if I run the following docker command, it logs to stdout as I would expect. It prints the npm version.

docker run \
  --rm \
  -it \
  --entrypoint npm \
  node:12-alpine \
  --version

When I try the equivalent using the plugin, it does not get output with the rest of the Maven output despite logging being explicitly set to true.

<execution>
    <id>npm version</id>
    <goals>
        <goal>start</goal>
        <goal>stop</goal>
        <goal>remove</goal>
    </goals>
    <phase>test</phase>
    <configuration>
        <images>
            <image>
                <name>node:12-alpine</name>
                <run>
                    <entrypoint>
                        <arg>npm</arg>
                    </entrypoint>
                    <cmd>
                        <arg>--version</arg>
                    </cmd>
                    <wait>
                        <exit>0</exit>
                        <time>18000</time>
                    </wait>
                    <log>
                        <enabled>true</enabled>
                    </log>
                </run>
            </image>
        </images>
    </configuration>
</execution>

If I add a color tag, it starts to correctly log:

                    <log>
                        <enabled>true</enabled>
                        <color>cyan</color>
                    </log>

If I build a docker image instead then simply start/stop it, it also starts to log correctly (even without the colour.

# test.Dockerfile
FROM node:12-alpine
CMD ["npm", "--version"]
<execution>
    <id>npm version</id>
    <goals>
        <goal>build</goal>
        <goal>start</goal>
        <goal>stop</goal>
        <goal>remove</goal>
    </goals>
    <phase>test</phase>
    <configuration>
        <images>
            <image>
                <name>dmp-test</name>
                <build>
                    <dockerFile>${project.basedir}/test.Dockerfile</dockerFile>
                </build>
                <run>
                    <wait>
                        <exit>0</exit>
                        <time>18000</time>
                    </wait>
                    <log>
                        <enabled>true</enabled>
                    </log>
                </run>
            </image>
        </images>
    </configuration>
</execution>

This seems very strange and I can only imagine that somehow logging is deactivated under certain conditions when it should not be.

Info

  • d-m-p version : 0.31.0
  • Maven version (mvn -v) : Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T20:00:29+01:00)
  • Docker version : 19.03.2, build 6a30dfc
@rhuss
Copy link
Collaborator

rhuss commented Nov 21, 2019

Thanks a for the report, it indeed looks strange. I can assure that there is no special treatment for logging within dmp.

However, to reproduce the issue, could you please craft a full working pom.xml so that I can try and debug it locally ? Thanks !

@dpwrussell
Copy link
Author

dpwrussell commented Dec 23, 2019

@rhuss Apologies for the delay.

https://gist.github.com/dpwrussell/229479428fd0907913fb088a030c0697

Essentially it comes down to the presence of a Dockerfile. If you delete that, it will behave as expected. Perhaps there is some configuration done upon detecting a Dockerfile, even if that Dockerfile is not used in any executions of the plugin?

It will also behave as expected if you comment in the <prefix>%a></prefix> section.

@dpwrussell dpwrussell changed the title Log is not enabled under certain conditions Log is not enabled if Dockerfile present. Dec 23, 2019
rhuss added a commit to rhuss/docker-maven-plugin that referenced this issue Jan 8, 2020
I.e. when enabled is a Boolean but not identical to Boolean.TRUE

Fixes fabric8io#1291
@rhuss rhuss closed this as completed in b5bf2a7 Jan 8, 2020
@rhuss
Copy link
Collaborator

rhuss commented Jan 8, 2020

Thanks a lot for your investigation. I could track the bug down to an erronous boolean check. The fix should be available in the next release which should be published very soon (probably still this week).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants