Skip to content

bake: do not fail printing definition if instance unavailable #1345

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

Merged
merged 1 commit into from
Oct 18, 2022

Conversation

crazy-max
Copy link
Member

fixes #1344

Since 0.9 we are checking the context builder endpoint to make sure it's reachable before returning the instance: #1129 (comment). By doing so we are not soft-failing as before when loading driversForNodeGroup and therefore bake --print now fails if no instance is available.

This PR will not return an error if we are printing local bake files. An instance is still required when building or loading remote bake files.

Signed-off-by: CrazyMax crazy-max@users.noreply.github.com

@crazy-max
Copy link
Member Author

@tonistiigi With this repro #1344 (comment) I found out that completing the trace span for the bake command on return timed out (10s). Looks to be this defer:

buildx/commands/bake.go

Lines 35 to 37 in 105c214

defer func() {
end(err)
}()
calling:
span.End()

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.

left a question 😅

Also would be good to have an integration test for this (setting a "bogus" / unreachable instance, then verify it works)

@crazy-max
Copy link
Member Author

Also would be good to have an integration test for this (setting a "bogus" / unreachable instance, then verify it works)

That's a broader subject but yeah we need integration tests for the cli and mock some components like the docker/cli.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
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.

thanks for updating

LGTM

@crazy-max crazy-max requested review from jedevc and tonistiigi October 4, 2022 16:01
Comment on lines +93 to +94
// instance only needed for reading remote bake files or building
if url != "" || !in.printOnly {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if a better way to write this would be to fetch the instance "lazily"? So that we only call getInstanceOnDefault to get dis at the point of use?

Copy link
Member

Choose a reason for hiding this comment

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

Doing these things lazily definitely seems nice. Not sure how much would be involved in doing that (and if the current patch fixes the issue, perhaps we should consider the "easy" fix at least as a temporary solution)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah sounds good 🎉

The logic around drivers keeps getting hairier and hairier, we should definitely look into some cleanup soon 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

I have another branch to mutualize the builder/driver logic so we could lazily load an instance. Not yet ready but you can take a look: master...crazy-max:buildx:builder-pkg

@crazy-max crazy-max merged commit 58d3a64 into docker:master Oct 18, 2022
@crazy-max crazy-max deleted the bake-print branch October 25, 2022 17:19
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.

buildx bake with --print now requires a daemon
3 participants