question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

color works until halfway through 'start'

See original GitHub issue

Description

Maven colorized output works, until it stops working partway through the ‘start’ of docker-maven-plugin. But when docker-maven-plugin is finished, it remains broke through the rest of the build.

Info

All maven output colorized until the point shown below. But after that point, everything is NON colorized – including the entire maven build that has nothing to do with docker-maven-plugin.

10/06/18 09:44:26 [DEBUG] Configuring mojo 'io.fabric8:docker-maven-plugin:0.27.2:start' with basic configurator -->
10/06/18 09:44:26 [DEBUG]   (f) autoCreateCustomNetworks = false
10/06/18 09:44:26 [DEBUG]   (f) execution = io.fabric8:docker-maven-plugin:0.27.2:start {execution: prepare-flyway-dbserver}
10/06/18 09:44:26 [DEBUG]   (s) name = obfuscated/postgres/postgres:10.3
10/06/18 09:44:26 [DEBUG]   (f) alias = flyway-dbserver
10/06/18 09:44:26 [DEBUG]   (f) ports = [flyway-dbserver.port:5432]
10/06/18 09:44:26 [DEBUG]   (f) bind = [/var/lib/jenkins/workspace/obfuscated]
10/06/18 09:44:26 [DEBUG]   (f) volumes = io.fabric8.maven.docker.config.RunVolumeConfiguration@1c4493c6
10/06/18 09:44:26 [DEBUG]   (f) log = (?s)database system is ready to accept connections.*database system is ready to accept connections
10/06/18 09:44:26 [DEBUG]   (f) time = 20000
10/06/18 09:44:26 [DEBUG]   (f) postStart = /opt/build/flyway_db_setup.sh managementdb
10/06/18 09:44:26 [DEBUG]   (f) exec = io.fabric8.maven.docker.config.WaitConfiguration$ExecConfiguration@41f5e6ee
10/06/18 09:44:26 [DEBUG]   (f) wait = io.fabric8.maven.docker.config.WaitConfiguration@30c9ab3f
10/06/18 09:44:26 [DEBUG]   (f) run = io.fabric8.maven.docker.config.RunImageConfiguration@5f5ab1ad
10/06/18 09:44:26 [DEBUG]   (f) images = [ImageConfiguration {name='obfuscated/postgres/postgres:10.3', alias='flyway-dbserver'}]
10/06/18 09:44:26 [DEBUG]   (f) keepContainer = false
10/06/18 09:44:26 [DEBUG]   (f) logStdout = false
10/06/18 09:44:26 [DEBUG]   (f) maxConnections = 100
10/06/18 09:44:26 [DEBUG]   (f) project = MavenProject: obfuscated @ /var/lib/jenkins/workspace/obfuscated/pom.xml
10/06/18 09:44:26 [DEBUG]   (f) removeVolumes = false
10/06/18 09:44:26 [DEBUG]   (f) session = org.apache.maven.execution.MavenSession@521441d5
10/06/18 09:44:26 [DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@4967d14c
10/06/18 09:44:26 [DEBUG]   (f) skip = false
10/06/18 09:44:26 [DEBUG]   (f) skipExtendedAuth = false
10/06/18 09:44:26 [DEBUG]   (f) skipMachine = false
10/06/18 09:44:26 [DEBUG]   (f) skipRun = false
10/06/18 09:44:26 [DEBUG]   (f) startParallel = false
10/06/18 09:44:26 [DEBUG]   (f) useColor = true
10/06/18 09:44:26 [DEBUG]   (f) verbose = false
10/06/18 09:44:26 [DEBUG] -- end configuration --

all output above is colorized (i.e. the severity level is colorized, etc) all output below (and for the remainder of the entire build!!) is not colorized:

10/06/18 09:44:26 [DEBUG] DOCKER> Container create config: {"Image":"obfuscated/postgres/postgres:10.3","ExposedPorts":{"5432/tcp":{}},"Labels":{"dmp.coordinates":"obfuscated"},"HostConfig":{"PortBindings":{"5432/tcp":[{"HostPort":""}]},"Binds":["/var/lib/jenkins/workspace/obfuscated"],"VolumesFrom":[]},"Volumes":{"/opt/build":{}}}

Note details below – if we stifle debug output for the maven build, the problem does not occur. It’s something during the debug output that breaks coloring. But the break occurs at the point shown above. I have the useColor property set to true in the docker-maven-plugin config, didn’t help.

  • d-m-p version : 0.27.2
  • Maven version (mvn -v) : 3.5.4

  • Docker version :17.06.2-ce
  • If it’s a bug, how to reproduce : Reproduces all the time for me, though I’m not sure what the relevant factor is, I’m a little new to some of this. Potential factors: the entire build starts in a container already, before it gets to this step. I had to play a bit with setting env variables to get maven to generated color output in the first place, re: it not thinking it’s a tty, i.e. MVN_OPTS=-Dstyle.color=always -Djansi.force=true. But that works for the entire maven build up to the point where it breaks in the ‘start’ portion of this plugin.

Also – it looks like it’s something from debug output that breaks it. Specifically – if I run the maven build without the -X debug flag, the entire build remains colorized – before, during, and after the docker-maven-plugin actions. But when -X is enabled, everything is colorized up to the point shown in the output above, and then everything remains not colorized after that point – everything.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
borisivancommented, Jan 15, 2019

really hoping this can be addressed. We have multiple maven projects, with all the output nice and colorized… until this plugin steps on everything and eliminates all colorized output for the remainder of the build, not playing nice with others. 😦

0reactions
brenuartcommented, Apr 1, 2019

Our solution is pretty close - but slightly different. See below:

 private void initializeColor(boolean useColor) {
    	this.useAnsi = useColor && !log.isDebugEnabled() && !isWindows();
    	if (!useAnsi) {
    		Ansi.setEnabled(false);
    	}
}

We let Maven install ANSI support itself it it has color enabled - reason why we don’t call AnsiConsole.systemInstall() ourselves. This way, standard Maven parameters can be used to turn color on/off for the whole Maven build.

The only thing the plugin has to do is to turn off coloring for its own output if it needs to (questionable tho). This is done with Ansi.setEnabled(false). This status is per-thread so the plugin must re-enable it when done otherwise the next plugin invocations won’t get any color anymore (the problem we are all facing)…

We did this by overriding AbstractDockerMojo as follows:

    public void execute() throws MojoExecutionException, MojoFailureException {
    	boolean ansiEnabledState = Ansi.isEnabled();
    	try {
    		originalExecute();
    	}
    	finally {
            Ansi.setEnabled(ansiEnabledState);
    	}
    }

IMHO Maven should care about resetting the ANSI enabled state after each mojo invocation. This would be a good protection against rogue plugins…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I get the color halfway between two colors?
In practice for nearby colors it might not matter. I wouldn't be surprised if this is what is done by ColorBlender.
Read more >
Printer stops halfway through job and then an error message
I'm currently having problems with printing any size job, the printer starts printing fine, then pauses for a while, starts again and then...
Read more >
Color Changing Walking Water Science Experiment
1. Prepare two strips of paper towel between 1 and 2 inches wide. Tip: We used one section of paper towel and folded...
Read more >
thin black lines on the screen started with one now four - iFixit
thin black lines appearing on the screen of my 50" Samsung television...color is great but these keep appearing one by one on the...
Read more >
How to change colors in knitting - 10 easy methods ... - YouTube
A step-by-step tutorial on the best ways to change colors in knitting - no matter if it's in the middle of a row...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found