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

fix taskrun failing with duplicate unique image found #6260

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/pod/entrypoint_lookup_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ func buildCommandMap(idx v1.ImageIndex, hasArgs bool) (map[string][]string, erro
}
for _, desc := range mf.Manifests {
plat := desc.Platform.String()
// skip unknown platforms.
jerop marked this conversation as resolved.
Show resolved Hide resolved
// Docker uses these to store attestation data: https://docs.docker.com/build/attestations/attestation-storage/#examples
if plat == "unknown/unknown" {
jerop marked this conversation as resolved.
Show resolved Hide resolved
continue
}
if got, found := platToDigest[plat]; found && got != desc.Digest {
return nil, fmt.Errorf("duplicate unique image found for platform: %s: found %s and %s", plat, got, desc.Digest)
}
Expand Down
41 changes: 40 additions & 1 deletion pkg/pod/entrypoint_lookup_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func TestBuildCommandMap(t *testing.T) {
desc string
idx v1.ImageIndex
wantErr bool
want map[string][]string
}{{
// Valid multi-platform image even though some platforms only differ by variant or osversion.
desc: "valid index",
Expand Down Expand Up @@ -226,6 +227,13 @@ func TestBuildCommandMap(t *testing.T) {
Platform: &v1.Platform{OS: "windows", Architecture: "amd64", OSVersion: "4.5.6"},
},
}),
want: map[string][]string{
"linux/amd64": nil,
"linux/arm64/7": nil,
"linux/arm64/8": nil,
"windows/amd64:1.2.3": nil,
"windows/amd64:4.5.6": nil,
},
}, {
desc: "valid index, with dupes",
idx: mutate.AppendManifests(empty.Index, mutate.IndexAddendum{
Expand All @@ -239,6 +247,9 @@ func TestBuildCommandMap(t *testing.T) {
Platform: &v1.Platform{OS: "linux", Architecture: "amd64"},
},
}),
want: map[string][]string{
"linux/amd64": nil,
},
}, {
desc: "invalid index, dupes with different digests",
idx: mutate.AppendManifests(empty.Index, mutate.IndexAddendum{
Expand All @@ -253,13 +264,41 @@ func TestBuildCommandMap(t *testing.T) {
},
}),
wantErr: true,
}, {
desc: "valid index, with unknown platform",
idx: mutate.AppendManifests(empty.Index, mutate.IndexAddendum{
Add: img,
Descriptor: v1.Descriptor{
Platform: &v1.Platform{OS: "linux", Architecture: "amd64"},
},
}, mutate.IndexAddendum{
Add: img,
Descriptor: v1.Descriptor{
Platform: &v1.Platform{OS: "unknown", Architecture: "unknown"},
},
}),
want: map[string][]string{
"linux/amd64": nil,
},
jerop marked this conversation as resolved.
Show resolved Hide resolved
}, {
desc: "valid index, only unknown platform",
idx: mutate.AppendManifests(empty.Index, mutate.IndexAddendum{
Add: img,
Descriptor: v1.Descriptor{
Platform: &v1.Platform{OS: "unknown", Architecture: "unknown"},
},
}),
want: map[string][]string{},
}} {
t.Run(c.desc, func(t *testing.T) {
_, err := buildCommandMap(c.idx, true)
got, err := buildCommandMap(c.idx, true)
gotErr := (err != nil)
if gotErr != c.wantErr {
t.Fatalf("got err: %v, want err: %t", err, c.wantErr)
}
if d := cmp.Diff(c.want, got); d != "" && !c.wantErr {
t.Errorf("Diff %s", diff.PrintWantGot(d))
}
})
}
}
Expand Down