Feature detection caches features as not available if a builder is polled before it is fully initialized
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 682
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 29
Description
Contributing guidelines
- I've read the contributing guidelines and wholeheartedly agree
I've found a bug and checked that ...
- ... the documentation does not mention anything about my problem
- ... there are no open or closed issues that are related to my problem
Description
When running docker buildx build --platform linux/amd64 --platform linux/arm64 --type=docker . against a docker:dind container, I sometimes get:
ERROR: failed to build: docker exporter does not currently support exporting manifest lists
But this happens intermittently, and only under load, which seems to imply that the error message is incorrect. Maybe the builder isn't fully initialized or something, but it's returning an error message implying that the driver is incompatible. This can't be given that most of the time the same test passes just fine and I am using the default builder driver every time.
Per @thaJeztah:
Looks like it does feature detection here;
https://github.com/docker/buildx/blob/1d7cda1232b38146345c8d5d73d6ee88de03eda1/build/opt.go#L224-L233
Looking at that code, it uses a sync.Once, and discards errors (if ... err == nil), so if it has a failure when trying to detect features the first time, it will discard the error, and considers it “not supported” for the duration of the buildx instance ;
https://github.com/docker/buildx/blob/461bd9e5d134057c42a099977f27af9bd47a1080/util/dockerutil/client.go#L76-L93
If the only way to check whether a builder is ready for use is a retry-loop then this will result in the builder's feature getting stripped away for the lifetime of the builder which is bad.
Expected behaviour
The result of features detection should only be cached if the builder is fully initialized
Actual behaviour
If an error occurs while communicating with a builder, a feature is marked as "not available" forever
Buildx version
github.com/docker/buildx v0.25.0 faaea65da4ba0e58a13cd9cadcb950c51cf3b3c9
Docker info
Builders list
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
default docker
\_ default \_ default running v0.22.0 linux/amd64 (+3), linux/arm64, linux/arm (+2), linux/ppc64le, (2 more)
desktop-linux* docker
\_ desktop-linux \_ desktop-linux running v0.22.0 linux/amd64 (+3), linux/arm64, linux/arm (+2), linux/ppc64le, (2 more)
Configuration
N/A
Build logs
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the feature-detection logic in build/opt.go around the linked lines and the builder client handling in util/dockerutil/client.go. Reproduce the docker buildx build command under load, then verify that a transient initialization error no longer permanently marks the feature unavailable and that normal feature detection still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100