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

bring back and expose BuildKitEnabled func #3435

Merged
merged 2 commits into from
Feb 25, 2022

Conversation

crazy-max
Copy link
Member

Bring back BuildKitEnabled that is used by compose: https://github.com/docker/compose/blob/598b59f8bf0a86f3ba2a135c0489b63bb4285973/pkg/compose/build.go#L216-L219. @ndeloof Signature has changed, let me know if it sounds good to you.

Second commit fixes an issue where legacy builder was not used if wcow was reported server-side (see #3314).

@ndeloof
Copy link
Contributor

ndeloof commented Feb 23, 2022

we can manage the signature change on docker/compose, thanks for this

}
// otherwise, assume BuildKit is enabled but
// not if wcow reported from server side
return cli.ServerInfo().OSType != "windows", nil
Copy link
Member

Choose a reason for hiding this comment

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

Probably for a follow-up, but I just realise we don't take older daemons into account. (Should we default to "false" on, daemons that do not yet have BuildKit, or before BuildKit left experimental (BuildKit no longer required experimental since 18.09.0; https://docs.docker.com/engine/release-notes/18.09/#new-features)

@@ -73,6 +73,12 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
return args, osargs, nil
}

// wcow build command must use the legacy builder
// if not opt-in through a builder component
if !useBuilder && dockerCli.ServerInfo().OSType == "windows" {
Copy link
Member

Choose a reason for hiding this comment

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

I'm slightly concerned that there's now 2 implementations to do the BuildKit check (one in BuildKitEnabled()); I don't want to necessarily block this PR on that, but wondering if we can use the same code for both (so that we're sure the logic won't diverge)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was thinking of moving some logic to BuildKitEnabled but in processBuilder we need to know if DOCKER_BUILDKIT is being used/enforced.

Copy link
Member

Choose a reason for hiding this comment

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

could we extract the common bits to a non-exported function perhaps? (haven't checked), so something like;

func (cli *DockerCli) BuildKitEnabled() (bool, error) {
    foo, _, err := doTheBuildKitCheck(cli)
    return foo, err
}

Copy link
Member Author

@crazy-max crazy-max Feb 23, 2022

Choose a reason for hiding this comment

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

hum yeah we could do that, let me see.

@codecov-commenter
Copy link

codecov-commenter commented Feb 23, 2022

Codecov Report

Merging #3435 (e7a8748) into master (60283c6) will decrease coverage by 0.04%.
The diff coverage is 5.88%.

@@            Coverage Diff             @@
##           master    #3435      +/-   ##
==========================================
- Coverage   58.29%   58.25%   -0.05%     
==========================================
  Files         287      287              
  Lines       24137    24152      +15     
==========================================
- Hits        14071    14070       -1     
- Misses       9207     9222      +15     
- Partials      859      860       +1     

@crazy-max crazy-max force-pushed the buildkit-enabled-check branch 2 times, most recently from 1d2c309 to 311772e Compare February 23, 2022 15:24
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.

LGTM

for those following along; @crazy-max did an implementation with the "common bits" extracted to a function, but because things are in separate packages, that meant the function had to be exported (so we couldn't put it in a non-exported / internal function).

Because of that, we decided that duplicating the code/logic for handling the DOCKER_BUILDKIT env-var (and other options) would be the better alternative for now.

@thaJeztah thaJeztah added this to the 21.xx milestone Feb 25, 2022
@thaJeztah thaJeztah merged commit ec8a316 into docker:master Feb 25, 2022
@crazy-max crazy-max deleted the buildkit-enabled-check branch February 25, 2022 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants