Skip to content

Commit

Permalink
fix: docker containerd blob error (#2593)
Browse files Browse the repository at this point in the history
## Description

Fixes #2584 

## Checklist before merging

- [ ] Test, docs, adr added or updated as needed
- [ ] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/.github/CONTRIBUTING.md#developer-workflow)
followed
  • Loading branch information
AustinAbro321 authored Jun 6, 2024
1 parent 3256cf8 commit 2707a61
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
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 from the local docker daemon, while using the docker containerd runtime
// 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)
})
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

0 comments on commit 2707a61

Please sign in to comment.