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

fix: make useBuildkit field nullable across all config versions #6612

Merged
merged 3 commits into from
Sep 20, 2021

Conversation

gsquared94
Copy link
Contributor

@gsquared94 gsquared94 commented Sep 16, 2021

fix: setting useBuildkit: false actually turns off buildkit for docker builder

Related: #4936

Description

Currently setting useBuildkit: false in the skaffold.yaml config doesn't actually disable buildkit. This PR fixes that by setting DOCKER_BUILDKIT =0 env variable when useBuildkit: false is set in the config.

In pkg/skaffold/build/docker/docker.go :

-	if b.useBuildKit {
-		cmd.Env = append(cmd.Env, "DOCKER_BUILDKIT=1")
+	if b.useBuildKit != nil {
+		if *b.useBuildKit {
+			cmd.Env = append(cmd.Env, "DOCKER_BUILDKIT=1")
+		} else {
+			cmd.Env = append(cmd.Env, "DOCKER_BUILDKIT=0")
+		}
	}

This change in itself would however break backwards compatibility since for previous versions of the config even if useBuildkit property is not set, it'd default to false and now start disabling buildkit which is not how it worked previously (so that bug essentially became a feature, that if useBuildkit is unspecified it should use the Docker default).

So we additionally make the config change to all config versions, so that a missing useBuildkit field can be identified separately from an explicitly set useBuildkit: false

User facing changes (remove if N/A)
There are no user facing changes other than if users were setting useBuildkit: false in the config, skaffold will now actually disable buildkit.

Follow-up Work (remove if N/A)

Fix #4936 after this is merged.

Changes discussed with @briandealwis

The make checks will be failing since we generally prohibit making changes to already released configs. But this PR only changes a single field from bool to *bool.

setting `useBuildkit: false` actually turns off buildkit
@gsquared94 gsquared94 requested a review from a team as a code owner September 16, 2021 08:26
@google-cla google-cla bot added the cla: yes label Sep 16, 2021
@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #6612 (751617e) into main (290280e) will decrease coverage by 0.49%.
The diff coverage is 87.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6612      +/-   ##
==========================================
- Coverage   70.48%   69.99%   -0.50%     
==========================================
  Files         515      520       +5     
  Lines       23150    23603     +453     
==========================================
+ Hits        16317    16520     +203     
- Misses       5776     6001     +225     
- Partials     1057     1082      +25     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/flags.go 89.00% <ø> (-1.82%) ⬇️
cmd/skaffold/skaffold.go 0.00% <ø> (ø)
pkg/skaffold/build/buildpacks/logger.go 0.00% <ø> (ø)
pkg/skaffold/config/options.go 100.00% <ø> (ø)
pkg/skaffold/debug/apply_transforms.go 22.64% <0.00%> (-0.44%) ⬇️
pkg/skaffold/debug/transform.go 95.91% <ø> (ø)
pkg/skaffold/docker/logger/log.go 22.64% <0.00%> (-0.44%) ⬇️
pkg/skaffold/kubectl/exec.go 100.00% <ø> (ø)
pkg/skaffold/schema/latest/v1/config.go 62.16% <ø> (ø)
pkg/skaffold/schema/latest/v2/config.go 5.40% <ø> (ø)
... and 86 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d306e4...751617e. Read the comment docs.

@@ -54,7 +54,7 @@ func (b *Builder) Build(ctx context.Context, out io.Writer, a *latestV1.Artifact

var imageID string

if b.useCLI || b.useBuildKit {
if b.useCLI || (b.useBuildKit != nil && *b.useBuildKit) {
Copy link
Member

Choose a reason for hiding this comment

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

Worth a comment here to say that we ignore the useCLI setting if buildkit is requested as we currently use the Docker CLI to use buildkit. We could consider a different approach in the future.

@briandealwis
Copy link
Member

@nkubala fyi: this PR changes previously-published config schemas to turn useBuildkit from a boolean into an optional field.

@gsquared94 gsquared94 merged commit 22b0c72 into GoogleContainerTools:main Sep 20, 2021
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.

Enable Docker BuildKit by default
3 participants