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

build: improve error messages for docker driver #1998

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

dvdksn
Copy link
Contributor

@dvdksn dvdksn commented Aug 10, 2023

Signed-off-by: David Karlsson 35727626+dvdksn@users.noreply.github.com

Improve error messages, and add documentation links, for errors related to the limited capabilities of the docker driver

Closes #1996

@crazy-max
Copy link
Member

crazy-max commented Aug 10, 2023

If you're willing to add integration tests like you have done for build progress that would be nice. We can do that in follow-up as well.

@dvdksn dvdksn force-pushed the build/docker-driver-errmsgs branch from 0055cd2 to 6ed6e77 Compare August 10, 2023 18:42
@dvdksn
Copy link
Contributor Author

dvdksn commented Aug 10, 2023

@crazy-max I wanted to add that actually! But I wasn't sure how to make an integration test for a specific driver. Is it just checking integration.Sandbox.Name(), and skip if name != "docker"?

@crazy-max
Copy link
Member

@crazy-max I wanted to add that actually! But I wasn't sure how to make an integration test for a specific driver. Is it just checking integration.Sandbox.Name(), and skip if name != "docker"?

Like

buildx/tests/build.go

Lines 185 to 187 in 86ae8ea

if !isDockerWorker(sb) {
t.Skip("skipping test for non-docker workers")
}

@dvdksn dvdksn force-pushed the build/docker-driver-errmsgs branch from 6ed6e77 to 7f4721b Compare August 15, 2023 08:56
@dvdksn dvdksn requested a review from crazy-max August 15, 2023 09:00
@dvdksn dvdksn force-pushed the build/docker-driver-errmsgs branch 2 times, most recently from 021bd5d to 58036c5 Compare August 18, 2023 15:30
@crazy-max
Copy link
Member

@dvdksn Pushed extra commit to split tests in dedicated funcs. We need to also skip tests for docker+containerd case. Feel free to squash.

@tonistiigi tonistiigi added this to the v0.12.0 milestone Aug 21, 2023
@tonistiigi tonistiigi self-requested a review August 21, 2023 16:26
@dvdksn dvdksn force-pushed the build/docker-driver-errmsgs branch from 01d3245 to 754cfbb Compare August 23, 2023 09:27
build/build.go Outdated
}

func multiPlatformBuildNotSupported(d driver.Driver) error {
return errors.Errorf(`Multi-platform build is not supported for the %s driver without the containerd image store.
Copy link
Member

Choose a reason for hiding this comment

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

The other cases should also work with containerd image store if we want to mention that.

@dvdksn
Copy link
Contributor Author

dvdksn commented Sep 11, 2023

Didn't realize the c8d restriction applied to all cases, so I made some refactoring

build/build.go Outdated
@@ -627,7 +627,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
pp[i] = platforms.Format(p)
}
if len(pp) > 1 && !nodeDriver.Features(ctx)[driver.MultiPlatform] {
return nil, nil, notSupported(nodeDriver, driver.MultiPlatform)
return nil, nil, notSupported(driver.MultiPlatform, nodeDriver, "https://docs.docker.com/go/build-multi-platform")
Copy link
Member

Choose a reason for hiding this comment

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

Do the go-redirect URLs need a trailing slash?

Copy link
Contributor Author

@dvdksn dvdksn Sep 12, 2023

Choose a reason for hiding this comment

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

Not strictly needed; the redirect handles both cases: docker/docs@bf4a605

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes, I was aware we were able to handle both, but I think we use URLs with a trailing / as the "canonical" one for all our links, so thought I'd be better to be consistent and use URLs ending with a /. (For the non-/go/ URLs this prevents an extra redirect).

@crazy-max
Copy link
Member

@dvdksn needs rebase 🙏

@dvdksn dvdksn force-pushed the build/docker-driver-errmsgs branch 3 times, most recently from 7c9b2e1 to 6f31958 Compare September 12, 2023 07:36
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
Comment on lines +382 to +393

func testBuildCacheExportNotSupported(t *testing.T, sb integration.Sandbox) {
if sb.Name() != "docker" {
t.Skip("skipping test for non-docker workers")
}

dir := createTestProject(t)
cmd := buildxCmd(sb, withArgs("build", "--cache-to=type=registry", dir))
out, err := cmd.CombinedOutput()
require.Error(t, err, string(out))
require.Contains(t, string(out), "Cache export is not supported")
}
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if we should start using a test-table for these tests; did a quick try what it'd look like; dvdksn#2

WDYT @crazy-max ?

Copy link
Member

Choose a reason for hiding this comment

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

Yes sounds good but I think we should split ones about empty key from other tests

Copy link
Member

Choose a reason for hiding this comment

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

Opened as #2041

but I think we should split ones about empty key from other tests

Any specific reason for that? (just wondering)

@crazy-max crazy-max merged commit 7b049b9 into docker:master Sep 12, 2023
59 checks passed
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.

Docker driver multiplatform error message can confuse users
4 participants