-
Notifications
You must be signed in to change notification settings - Fork 685
driver: propagate feature detection errors #4085
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
tonistiigi
merged 1 commit into
docker:master
from
crazy-max:fix-driver-feature-detection
Sep 30, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package docker | ||
|
|
||
| import ( | ||
| "context" | ||
| "net" | ||
| "sync/atomic" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/docker/buildx/driver" | ||
| control "github.com/moby/buildkit/api/services/control" | ||
| types "github.com/moby/buildkit/api/types" | ||
| dockerclient "github.com/moby/moby/client" | ||
| "github.com/stretchr/testify/require" | ||
| "google.golang.org/grpc" | ||
| "google.golang.org/grpc/codes" | ||
| "google.golang.org/grpc/status" | ||
| ) | ||
|
|
||
| type featureTestAPI struct { | ||
| dockerclient.APIClient | ||
| addr string | ||
| } | ||
|
|
||
| func (a featureTestAPI) DialHijack(ctx context.Context, _, _ string, _ map[string][]string) (net.Conn, error) { | ||
| var dialer net.Dialer | ||
| return dialer.DialContext(ctx, "tcp", a.addr) | ||
| } | ||
|
|
||
| type featureTestControl struct { | ||
| control.UnimplementedControlServer | ||
| calls atomic.Int32 | ||
| supported bool | ||
| } | ||
|
|
||
| func (c *featureTestControl) ListWorkers(context.Context, *control.ListWorkersRequest) (*control.ListWorkersResponse, error) { | ||
| if c.calls.Add(1) == 1 { | ||
| return nil, status.Error(codes.Unavailable, "worker is starting") | ||
| } | ||
| w := &types.WorkerRecord{} | ||
| if c.supported { | ||
| w.Labels = map[string]string{"org.mobyproject.buildkit.worker.snapshotter": "overlayfs"} | ||
| } | ||
| return &control.ListWorkersResponse{Record: []*types.WorkerRecord{w}}, nil | ||
| } | ||
|
|
||
| func TestFeaturesRetry(t *testing.T) { | ||
| for _, supported := range []bool{false, true} { | ||
| t.Run(map[bool]string{false: "unsupported", true: "supported"}[supported], func(t *testing.T) { | ||
| ctx, cancel := context.WithTimeoutCause(t.Context(), 10*time.Second, context.DeadlineExceeded) | ||
| defer cancel() | ||
| var lc net.ListenConfig | ||
| listener, err := lc.Listen(ctx, "tcp", "127.0.0.1:0") | ||
| require.NoError(t, err) | ||
| defer listener.Close() | ||
| server := grpc.NewServer() | ||
| defer server.Stop() | ||
| ctl := &featureTestControl{supported: supported} | ||
| control.RegisterControlServer(server, ctl) | ||
| go server.Serve(listener) | ||
| d := &Driver{InitConfig: driver.InitConfig{DockerAPI: featureTestAPI{addr: listener.Addr().String()}}} | ||
| features, err := d.Features(ctx) | ||
| require.ErrorContains(t, err, "listing workers") | ||
| require.Equal(t, codes.Unavailable, status.Code(err)) | ||
| require.Nil(t, features) | ||
| for range 2 { | ||
| features, err = d.Features(ctx) | ||
| require.NoError(t, err) | ||
| require.True(t, features[driver.DefaultLoad]) | ||
| for _, f := range []driver.Feature{driver.OCIExporter, driver.DockerExporter, driver.CacheExport, driver.MultiPlatform, driver.DirectPush, driver.PreferImageDigest} { | ||
| require.Equal(t, supported, features[f], f) | ||
| } | ||
| } | ||
| require.EqualValues(t, 2, ctl.calls.Load()) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the main thing here is changing this specific driver to make a new request each time the method is called rather than using once to only call it once and then changing the places that call this to avoid treating this as a "free" call because it no longer caches the result.
I think this is fine I just wanted to confirm that I was understanding the intent correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes almost 😅 Features still caches a successful
ListWorkersresult, so later calls don't make another request. The change is that a failed probe returns an error without caching "unsupported"; a subsequent call can retry. Build option setup uses one successful result for its capability checks, including provenance, so those decisions stay consistent.