Skip to content

Conversation

@ktock
Copy link
Collaborator

@ktock ktock commented Mar 9, 2023

This PR addresses the following:

defer b.buildOnGoing.Store(false)

resp, res, err := cbuild.RunBuild(ctx, b.dockerCli, options, in, progressMode, nil)
resp, res, err := cbuild.RunBuild(ctx, b.dockerCli, options, in, "quiet", statusChan)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I think this also needs fixing, it's weird how we pass both the progressMode and a statusChan down into this build function, ideally we'd just pass the statusChan in.

The implementation seems not quite right in cbuild.RunBuild as well - it uses the progress mode to open a printer on os.Stderr, which we probably don't want to do (it doesn't work the same at all across local/remote).

The other confusing part here is the warnings, which are directly printed out onto os.Stderr - this isn't great, since we lose those warnings on the remote controller - but those should already be transmitted as part of the solve status? We should collect those from outside the controller (so printWarnings should probably go in controller.Build).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed to print progress/warnings on the client side. Now (controller/build).RunBuild is configurable about the method to print the progress/warnings.

$ BUILDX_EXPERIMENTAL=1 /tmp/out/buildx build /tmp/ctx3
INFO: connecting to buildx server
[+] Building 0.9s (6/6) FINISHED                  docker-container:testbuilder
 => [internal] load .dockerignore                                         0.0s
 => => transferring context: 2B                                           0.0s
 => [internal] load build definition from Dockerfile                      0.0s
 => => transferring dockerfile: 107B                                      0.0s
 => WARN: Empty continuation line found in: RUN echo hi > /hi     echo "  0.0s
 => [internal] load metadata for docker.io/library/busybox:latest         0.6s
 => [1/3] FROM docker.io/library/busybox@sha256:c118f538365369207c12e579  0.0s
 => => resolve docker.io/library/busybox@sha256:c118f538365369207c12e579  0.0s
 => CACHED [2/3] RUN echo hi > /hi     echo "hello"                       0.0s
 => CACHED [3/3] RUN echo aaaa > /a                                       0.0s

 1 warning found (use --debug to expand):
 - Empty continuation line found in: RUN echo hi > /hi     echo "hello"

@jedevc
Copy link
Collaborator

jedevc commented Mar 13, 2023

Thanks @ktock 🙏 sorry for the delays in reviews, things are a bit busy atm 🎉

@ktock ktock force-pushed the monitor-buildapi branch from 397b7ad to ccc9966 Compare March 14, 2023 08:44
@ktock
Copy link
Collaborator Author

ktock commented Mar 14, 2023

@jedevc Thank you for your time for reviewing 🙏 Fixed the patch based on the comments.

@ktock ktock requested a review from jedevc March 17, 2023 00:10
printOnly bool
sbom string
provenance string
controllerapi.CommonOptions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be possible to split the changes to the common options out into a separate PR so we can merge those in asap? Those changes look good to me, and then we can unblock some other stuff.

I'm not 100% sure about the progress changes here, the progress config doesn't seem like it'll catch everything on the remote side.

I think what we want is a way of exposing a progress.Writer over the network, so that the client can pass a progress.Writer through controller.Build. Then we don't also have to pass a statusChan, since we can use progress.Tee if we need the individual solve status events. Then everything that gets written to that progress.Writer, either on the client, the local controller, or the remote controller will end up printed (even if it's contents written directly to the progress writer by e.g. the driver loader).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Essentially, something like: master...jedevc:buildx:ktock-progress-printer (the remote side isn't properly implemented, and just creates a dummy printer, and then Tees out the channel to transmit over the connection).

We should create the progress printer outside of each controller call, and pass it into the interface. Then we can lift printWarnings out of the controller entirely 🎉 (should make things a bit neater).

Only thing I'm not sure about is how to handle the description: https://github.com/jedevc/buildx/blob/ktock-progress-printer/controller/build/build.go#L185-L193 - we need to have this info ready when we create the progress writer, so we need to load the drivers client before calling RunBuild (so maybe this is blocked on doing that?).

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also supplement progress.Printer with a new Println method or similar, that just prints out the content after progress has completed - we can then use this to handle the PrintFunc case.

@jedevc jedevc added this to the v0.11.0 milestone Apr 4, 2023
@ktock ktock marked this pull request as draft April 12, 2023 09:36
@jedevc
Copy link
Collaborator

jedevc commented Apr 26, 2023

Closing this in preference of #1737 and #1755.

@jedevc jedevc closed this Apr 26, 2023
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

Successfully merging this pull request may close these issues.

2 participants