Skip to content

Surface buildkit policy errors more clearly - #627

Merged
joshspicer merged 1 commit into
mainfrom
joshspicer/buildkit-policy-error
Aug 31, 2023
Merged

joshspicer merged 1 commit into
mainfrom
joshspicer/buildkit-policy-error

Conversation

@joshspicer

@joshspicer joshspicer commented Aug 29, 2023 •

Copy link
Copy Markdown
Contributor

ref: https://github.com/github/codespaces/issues/15008

If a buildx build error occurs, detects if the root cause was due to a buildx source policy. If so, report a less generic error via the description.

Example with this change:


ERROR: failed to solve: mcr.microsoft.com/devcontainers/ruby: could not resolve image due to policy: source "docker-image://mcr.microsoft.com/devcontainers/ruby:latest" denied by policy: source denied by policy
2023-08-29 21:55:02.751Z: Stop: Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-root/container-features/0.51.1-jospicer01-1693346094254/Dockerfile-with-features -t vsc-rejected-image-ac758e141f596cab21ee70d2129d2b19fd366618d66e324971f146f6f4c05b4f --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /var/lib/docker/codespacemount/workspace/rejected-image/.devcontainer
2023-08-29 21:55:02.753Z: Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-root/container-features/0.51.1-jospicer01-1693346094254/Dockerfile-with-features -t vsc-rejected-image-ac758e141f596cab21ee70d2129d2b19fd366618d66e324971f146f6f4c05b4f --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /var/lib/docker/codespacemount/workspace/rejected-image/.devcontainer
2023-08-29 21:55:02.754Z:     at BAA (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:463:1758)
2023-08-29 21:55:02.754Z:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-08-29 21:55:02.754Z:     at async Ww (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:462:1691)
2023-08-29 21:55:02.754Z:     at async SK (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:462:610)
2023-08-29 21:55:02.754Z:     at async SAA (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:479:3660)
2023-08-29 21:55:02.755Z:     at async GC (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:479:4775)
2023-08-29 21:55:02.756Z:     at async ZeA (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:611:12240)
2023-08-29 21:55:02.756Z:     at async VeA (/usr/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:611:11981)
2023-08-29 21:55:02.758Z: {
    "outcome": "error",
    "message": "Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-root/container-features/0.51.1-jospicer01-1693346094254/Dockerfile-with-features -t vsc-rejected-image-ac758e141f596cab21ee70d2129d2b19fd366618d66e324971f146f6f4c05b4f --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /var/lib/docker/codespacemount/workspace/rejected-image/.devcontainer",
    "description": "Could not resolve image due to policy."
}
2023-08-29 21:55:02.767Z: devcontainer process exited with exit code 1
@joshspicer
joshspicer requested a review from a team as a code owner August 29, 2023 22:03
@joshspicer
joshspicer merged commit 9da6357 into main Aug 31, 2023
@joshspicer
joshspicer deleted the joshspicer/buildkit-policy-error branch August 31, 2023 17:14
@joshspicer joshspicer mentioned this pull request Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants