Skip to content

Commit

Permalink
fix missing cid tag in cache-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
canercidam committed Jan 3, 2024
1 parent c1a9e9f commit 9598b8d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ var (
expectedImageCid = "bafybeihfub2ktzp6a77zrihiwf6c2hex3nwxd7zl7u6tj3ueu5kstqk4ii"
expectedImageCidCacheOnly = "bafybeibv76jl7r7ielvls37d24jbmt3lkr6dvt74q2i3qbji2m2cqocjvm"

unexpectedImageCid = "bafybeielvnt5apaxbk6chthc4dc3p6vscpx3ai4uvti7gwh253j7facsxu"
unexpectedPullImageRef = fmt.Sprintf("localhost:1970/%s", unexpectedImageCid)
unexpectedImageCid = "bafybeielvnt5apaxbk6chthc4dc3p6vscpx3ai4uvti7gwh253j7facsxu"
unexpectedPullImageRef = fmt.Sprintf("localhost:1970/%s", unexpectedImageCid)
expectedPullImageRefCacheOnly = fmt.Sprintf("localhost:1970/%s", expectedImageSha)

reposPath = "/docker/registry/v2/repositories/"

Expand All @@ -37,6 +38,8 @@ var (
expectedLayerBlob1 = "/docker/registry/v2/blobs/sha256/04/04479ea8ab2597ba1679773da48df06a9e646e3e7b67b0eb2c8c0bc6c51eb598/data"
expectedLayerBlob2 = "/docker/registry/v2/blobs/sha256/d9/d96e79a5881296813985815a1fa73e2441e72769541b1fb32a0e14f2acf4d659/data"

expectedCidTagCacheOnly = path.Join(reposPath, expectedImageSha, "_manifests", "tags", expectedImageCidCacheOnly)

cidImageRef = path.Join("localhost:1970", expectedImageCid)
)

Expand Down Expand Up @@ -259,6 +262,12 @@ func (s *E2ETestSuite) TestCacheOnly() {

s.r.NoError(exec.Command("docker", "push", pushImageRef).Run())

pullCmd := exec.Command("docker", "pull", "-a", expectedPullImageRefCacheOnly)
out := bytes.NewBufferString("")
pullCmd.Stdout = out
s.r.NoError(pullCmd.Run())
s.r.Contains(out.String(), expectedImageCidCacheOnly)

// verify that file exists in the cache storage
for _, contentPath := range []string{
expectedSha256Repo,
Expand All @@ -268,6 +277,8 @@ func (s *E2ETestSuite) TestCacheOnly() {
expectedConfigBlob,
expectedLayerBlob1,
expectedLayerBlob2,

expectedCidTagCacheOnly,
} {
fsInfo, err := os.Stat(path.Join("testdir/cache", contentPath))
s.r.NoError(err, contentPath)
Expand Down
3 changes: 3 additions & 0 deletions proxy/services/disco.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func (disco *Disco) MakeGlobalRepo(ctx context.Context, repoName string) error {
if _, err = drivers.Copy(ctx, driver, uploadRepoPath, makeRepoPath(cacheCid)); err != nil {
return fmt.Errorf("failed to create cache-only cid repo: %v", err)
}
if _, err = drivers.Copy(ctx, driver, makeTagPathFor(manifestDigest, "latest"), makeTagPathFor(manifestDigest, cacheCid)); err != nil {
return fmt.Errorf("failed to create manifest digest tag in cid repo: %v", err)
}
return err
}

Expand Down

0 comments on commit 9598b8d

Please sign in to comment.