policy: mark policy progress vertex on DENY build failures#3656
Merged
tonistiigi merged 2 commits intodocker:masterfrom Feb 20, 2026
Merged
policy: mark policy progress vertex on DENY build failures#3656tonistiigi merged 2 commits intodocker:masterfrom
tonistiigi merged 2 commits intodocker:masterfrom
Conversation
Track denied source identifiers during policy evaluation and flag the policy progress vertex as failed when BuildKit returns a matching DENY error pattern. This improves the progress output of policy error and shows last policy logs with the build error. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
crazy-max
reviewed
Feb 19, 2026
policy/policy_error_test.go
Outdated
Comment on lines
13
to
56
| func TestPolicyIsPolicyErrorMatchesRecordedSource(t *testing.T) { | ||
| p := NewPolicy(Opt{}) | ||
| req := &policysession.CheckPolicyRequest{ | ||
| Source: &gwpb.ResolveSourceMetaResponse{ | ||
| Source: &solverpb.SourceOp{ | ||
| Identifier: "docker-image://busybox:latest", | ||
| }, | ||
| }, | ||
| } | ||
| p.recordDenyIdentifier(req) | ||
|
|
||
| err := errors.New("failed to solve: error evaluating the source policy: source \"docker-image://busybox:latest\" not allowed by policy: action DENY") | ||
| require.True(t, p.IsPolicyError(err)) | ||
| } | ||
|
|
||
| func TestPolicyIsPolicyErrorDoesNotMatchWithoutBuildkitPattern(t *testing.T) { | ||
| p := NewPolicy(Opt{}) | ||
| req := &policysession.CheckPolicyRequest{ | ||
| Source: &gwpb.ResolveSourceMetaResponse{ | ||
| Source: &solverpb.SourceOp{ | ||
| Identifier: "docker-image://busybox:latest", | ||
| }, | ||
| }, | ||
| } | ||
| p.recordDenyIdentifier(req) | ||
|
|
||
| err := errors.New("failed to parse dockerfile for docker-image://busybox:latest") | ||
| require.False(t, p.IsPolicyError(err)) | ||
| } | ||
|
|
||
| func TestPolicyIsPolicyErrorDoesNotMatchUnrelatedError(t *testing.T) { | ||
| p := NewPolicy(Opt{}) | ||
| req := &policysession.CheckPolicyRequest{ | ||
| Source: &gwpb.ResolveSourceMetaResponse{ | ||
| Source: &solverpb.SourceOp{ | ||
| Identifier: "docker-image://busybox:latest", | ||
| }, | ||
| }, | ||
| } | ||
| p.recordDenyIdentifier(req) | ||
|
|
||
| err := errors.New("failed to solve: error evaluating the source policy: source \"docker-image://alpine:latest\" not allowed by policy: action DENY") | ||
| require.False(t, p.IsPolicyError(err)) | ||
| } |
Member
There was a problem hiding this comment.
nit: these tests look like a good fit for a single table-driven test ([]struct{name, err, want}) since setup is identical across cases. And could maybe also moved to validate_test.go and named func TestPolicyIsPolicyError?
Member
|
Could we have an integration test around the Line 645 in a0103f4 |
Member
Author
|
Added progress integration test and refactored unit test. |
Refactor policy error unit tests to table-driven subtests with slug names. Add rawjson integration coverage to verify policy vertex captures DENY build errors in progress output. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
645518b to
9f59d5b
Compare
Member
|
Seems there is a deadlock in sourcemeta resolver, opened #3659 |
Member
Author
crazy-max
approved these changes
Feb 20, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fix #3644
Track denied source identifiers during policy evaluation and flag the policy progress vertex as failed when BuildKit returns a matching DENY error pattern.
This improves the progress output of policy error and shows last policy logs with the build error.