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: docker containerd blob error #2593

Merged
merged 9 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 8 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
25 changes: 25 additions & 0 deletions src/internal/packager/images/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,31 @@ func Pull(ctx context.Context, cfg PullConfig) (map[transform.Image]v1.Image, er
doneSaving <- nil
<-doneSaving

// Needed because when pulling form the local docker daemon, while using the docker containerd runtime
lucasrod16 marked this conversation as resolved.
Show resolved Hide resolved
// Crane incorrectly names the blob of the docker image config to a sha that does not match the contents
// https://github.com/defenseunicorns/zarf/issues/2584
// This is a band aid fix while we wait for crane and or docker to create the permanent fix
blobDir := filepath.Join(cfg.DestinationDirectory, "blobs", "sha256")
err = filepath.Walk(blobDir, func(path string, fi os.FileInfo, err error) error {
if err != nil {
return err
}

if fi.IsDir() {
return nil
}

hash, err := helpers.GetSHA256OfFile(path)
if err != nil {
return err
}
newFile := filepath.Join(blobDir, hash)
return os.Rename(path, newFile)
AustinAbro321 marked this conversation as resolved.
Show resolved Hide resolved
})
if err != nil {
return nil, err
}

return fetched, nil
}

Expand Down
6 changes: 4 additions & 2 deletions src/pkg/layout/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ func (i *Images) AddV1Image(img v1.Image) error {
}
i.AddBlob(digest.Hex)
}
imgCfgSha, err := img.ConfigName()
manifest, err := img.Manifest()
if err != nil {
return err
}
i.AddBlob(imgCfgSha.Hex)
// Cannot use img.ConfigName to get this value because of an upstream bug in crane / docker using the containerd runtime
// https://github.com/defenseunicorns/zarf/issues/2584
i.AddBlob(manifest.Config.Digest.Hex)
manifestSha, err := img.Digest()
if err != nil {
return err
Expand Down
Loading