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

BUILDKIT output is logged as error #1371

Closed
LeonardMeyer opened this issue Oct 9, 2020 · 5 comments · Fixed by #1373
Closed

BUILDKIT output is logged as error #1371

LeonardMeyer opened this issue Oct 9, 2020 · 5 comments · Fixed by #1373

Comments

@LeonardMeyer
Copy link

LeonardMeyer commented Oct 9, 2020

Expected behaviour

When BuildKit is used to build the docker images, lines are output to the proper log level.

Actual behaviour

When BuildKit is used to build the docker images, everything is logged using log.error(...). The problem does not come from sbt-native-packager but from BuildKit itself, which outputs most of its stuff to stderr. See this issue.

[error] #2 [internal] load .dockerignore
[error] #2 transferring context: 2B done
[error] #2 DONE 0.0s
[error] #1 [internal] load build definition from Dockerfile
[error] #1 transferring dockerfile: 8.94kB done
[error] #1 DONE 0.0s
[error] #3 [internal] load metadata for docker.io/library/openjdk:8-jre
[error] #3 DONE 0.0s
[error] #4 [internal] load metadata for docker.io/library/ubuntu:focal
[error] #4 DONE 1.1s
[error] #12 [internal] load build context
[error] #12 DONE 0.0s
[error] #5 [mainstage 1/52] FROM docker.io/library/openjdk:8-jre

Maybe we could make the publishLocalLogger used in the publishLocal task a setting ? Or Just make the DockerPlugin supports DOCKER_BUILDKIT env var ?

Information

  • What sbt-native-packager are you using : 1.7.5
  • What sbt version : 1.3.10
  • What is your build system (e.g. Ubuntu, MacOS, Windows, Debian): Tested Linux Mint, MacOS.
  • What package are you building (e.g. docker, rpm, ...) : Docker
  • What version has your build tool (find out with e.g. rpm --version) : 19.03.13 local and 18.03 on CI
@LeonardMeyer LeonardMeyer changed the title Do not log BUILDKIT output as errors BUILDKIT output is logged as error Oct 9, 2020
@muuki88
Copy link
Contributor

muuki88 commented Oct 11, 2020

Hi @LeonardMeyer
Thanks for your detailed report 😍

The output of cli tools to the wrong logger is also an issue on RPM. My understanding at the time was that rpm wrote to stderr, which causes this and there wasn't much to do, other than just sending everything to stdout, which felt wrong as stderr is supposed for errors (I guess 😅 ).

Making the logger a setting could be an option, but usually folks don't like to dig down into sbt 😂 So I would go for a "fix if DOCKER_BUILDKIT" is set. I have a feeling that this going to cause a lot of trouble either way in the future and the option to check if it's enabled or not is helpful.

What would you suggest for a fix? The simplest solution would be to "if DOCKER_BUILDKIT == 1 then log everything in stderr as info"

@LeonardMeyer
Copy link
Author

LeonardMeyer commented Oct 11, 2020

Yes I was thinking of something similar. Just detect if the env var is set and change logger accordingly. I know sbt-release is using a custom logger for Git too, which exhibits the same behavior. I can put together a PR if you want, when I can find the time.

@kovacshuni
Copy link

Sorry I don't understand. Is there a fix for this? It's still happening to me on sbt-native-packager 1.9.11

@LeonardMeyer
Copy link
Author

@kovacshuni If you've set the DOCKER_BUILDKIT to 1 it should work. Either that or something changed ?

@kovacshuni
Copy link

works. In my GitHub Actions I put:

    - name: Push docker image to Google Artifact Registry
      env:
        DOCKER_BUILDKIT: 1
      run: sbt Docker/publish

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

Successfully merging a pull request may close this issue.

3 participants