Skip to content

bring back and expose BuildKitEnabled func - #3435

Merged
thaJeztah merged 2 commits into
docker:masterfrom
crazy-max:buildkit-enabled-check
Feb 25, 2022
Merged

bring back and expose BuildKitEnabled func#3435
thaJeztah merged 2 commits into
docker:masterfrom
crazy-max:buildkit-enabled-check

Conversation

@crazy-max

Copy link
Copy Markdown
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).

Comment threadcmd/docker/builder.go
@ndeloof

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown
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)

Comment threadcmd/docker/builder.go

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

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
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)
returnfoo, err
}

@crazy-maxcrazy-maxFeb 23, 2022

Copy link
Copy Markdown
MemberAuthor

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.

@crazy-max
crazy-maxforce-pushed the buildkit-enabled-check branch from 7fd33b9 to b24f9c5CompareFebruary 23, 2022 14:18
@codecov-commenter

codecov-commenter commented Feb 23, 2022

Copy link
Copy Markdown

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-maxforce-pushed the buildkit-enabled-check branch 2 times, most recently from 1d2c309 to 311772eCompareFebruary 23, 2022 15:24
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
…nent
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
@crazy-max
crazy-maxforce-pushed the buildkit-enabled-check branch from 311772e to e7a8748CompareFebruary 24, 2022 16:58

@thaJeztahthaJeztah left a comment

Copy link
Copy Markdown
Member

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.

@thaJeztahthaJeztah added this to the 21.xx milestone Feb 25, 2022
@thaJeztah
thaJeztah merged commit ec8a316 into docker:masterFeb 25, 2022
@crazy-max
crazy-max deleted the buildkit-enabled-check branch February 25, 2022 10:15
Sign up for freeto 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

@crazy-max@ndeloof@codecov-commenter@thaJeztah