harbor: Using buildkit exporting cache reporting status: 404 Not Found

finding : buildkit cache and image export compatibility with harbor

Work : export both output and cache layer together

https://github.com/moby/buildkit#inline-push-image-and-cache-together

buildctl --addr docker-container://buildkitd build \
  --frontend dockerfile.v0 --local context=.  --local dockerfile=docker/test --progress=plain \
  --output type=image,name=harbor-test.mysite.com/buildkit-cache/my-operator,push=true \
  --export-cache type=inline \
  --import-cache type=registry,ref=harbor-test.mysite.com/buildkit-cache/my-operator

...
#15 [base  8/16] RUN --mount=type=cache,target=/root/go/pkg/mod     --mount=...
#15 CACHED

#14 [base  7/16] COPY go.sum .
#14 CACHED

#23 [base 16/16] RUN --mount=type=cache,target=/root/go/pkg/mod     --mount=...
#23 CACHED
#24 exporting to image
#24 exporting layers done
#24 exporting manifest sha256:4cfd02e1abeb95dd038222ac9eefa36683cbd137881ac2439c02f6a5365f340c done
#24 exporting config sha256:3a39d7f051b9c2e0d392d29a205bed9607193201fe79ad38636e000cb78b510d
#24 exporting config sha256:3a39d7f051b9c2e0d392d29a205bed9607193201fe79ad38636e000cb78b510d done
#24 pushing layers
#24 pushing layers 1.1s done
#24 pushing manifest for harbor-test.mysite.com/buildkit-cache/my-operator:latest
#24 pushing manifest for harbor-test.mysite.com/buildkit-cache/my-operator:latest 0.1s done
#24 DONE 1.3s

#25 exporting cache
#25 preparing build cache for export done
#25 DONE 0.0s

Doesn’t work : export output and cache layer separately

buildctl --addr docker-container://buildkitd build \
  --frontend dockerfile.v0 --local context=. --local dockerfile=docker/test --progress=plain \
  --export-cache type=registry,ref=harbor-test.mysite.com/buildkit-cache/my-operator \
  --import-cache type=registry,ref=harbor-test.mysite.com/buildkit-cache/my-operator

24 exporting cache
#24 preparing build cache for export
#24 preparing build cache for export 15.8s done
...
#24 writing config sha256:19ac525ecabdc96ffbe803eef74acf809b082c37af057873137388121f491dcd
#24 writing config sha256:19ac525ecabdc96ffbe803eef74acf809b082c37af057873137388121f491dcd 0.1s done
#24 writing manifest sha256:878798161048504bee835f947ff94fdd915232bd8b277aacd6a511e5e77bd475
#24 writing manifest sha256:878798161048504bee835f947ff94fdd915232bd8b277aacd6a511e5e77bd475 0.1s done
#24 ERROR: error writing manifest blob: failed commit on ref "sha256:878798161048504bee835f947ff94fdd915232bd8b277aacd6a511e5e77bd475": unexpected status: 404 Not Found
------
 > exporting cache:
------
error: failed to solve: rpc error: code = Unknown desc = error writing manifest blob: failed commit on ref "sha256:878798161048504bee835f947ff94fdd915232bd8b277aacd6a511e5e77bd475": unexpected status: 404 Not Found

Versions: Please specify the versions of following systems.

harbor version: 2.2.1 docker engine version: 20.10.5 docker-compose version 1.18.0, build 8dd22a9

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 35
  • Comments: 43

Commits related to this issue

Most upvoted comments

This is still very relevant. Would there be any news about this?

Uping this one.

Any update on this? How could I help ?

If any one want to fix:

diff --git a/src/controller/artifact/abstractor.go b/src/controller/artifact/abstractor.go
index 233008157..5df41b2cd 100644
--- a/src/controller/artifact/abstractor.go
+++ b/src/controller/artifact/abstractor.go
@@ -160,6 +160,15 @@ func (a *abstractor) abstractIndexMetadata(ctx context.Context, art *artifact.Ar
 	// populate the referenced artifacts
 	for _, mani := range index.Manifests {
 		digest := mani.Digest.String()
+
+		// Buildx can reference layer in manifest
+		// see: https://github.com/docker/buildx/issues/173#issuecomment-873152302
+		switch mani.MediaType {
+		case v1.MediaTypeImageLayer, v1.MediaTypeImageLayerGzip, v1.MediaTypeImageLayerNonDistributable, v1.MediaTypeImageLayerNonDistributableGzip, "application/vnd.buildkit.cacheconfig.v0":
+			art.Size += mani.Size
+			continue
+		}
+
 		// make sure the child artifact exist
 		ar, err := a.artMgr.GetByDigest(ctx, art.RepositoryName, digest)
 		if err != nil {

Then you can rebuild the images with make compile build

I don’t know the side effect on garbage collection tho.

Hi, we would be interested by news about this as well, this is crucial for Production grade build capability with Harbor and buildkit. Alternately, has anyone used a separate generic repo exclusively for caching as a workaround? (when not using Github actions)

Any updates here?

Any news on this one? It’s still an issue on v2.5.

+1 Same issue to me.

#18 ERROR: error writing manifest blob: failed commit on ref “sha256:b0b8b156437e48583181a25ad6fecc5cfa45152005d47e215e824202e6cb579c”: unexpected status: 404 Not Found

Here is what I found on my gateway:

“PUT /v2/project/repo/manifests/buildcache HTTP/1.1” 404

harbor version: 2.3.2 docker engine version: 20.10.8+azure buildkit: github.com/moby/buildkit v0.9.0

@prosnekov as mentioned in https://github.com/goharbor/harbor/pull/18105, you can provide image-manifest=true: --export-cache type=registry,mode=max,image-manifest=true,ref=$CACHE_IMAGE

However, the option is only available for buildkit:master (which afaik is not stable), and not yet for buildkit:latest.

Having the same issue here. Is there any update on this?

Uping this one.

Any update on this? How could I help ?

still an issue for harbor 2.6.1

Running into this issue as well, is this fixed in a recent version, or is it still in the backlog?

we are still there. i’m wondering if it’s not less work to fix it than do some triage every week on the issue since 2 years …

@XciD i also took the time that artifacts are well cleaned up upon GC, and seems everything is OK.

I did some investigation around this issue, if you use --cache-to "type=registry,mode=max,ref=registry.... it will end up trying to uploaf manufest of type application/vnd.buildkit.cacheconfig.v0 which is not supported by all registry implementation, I think harbor does not support it?

I found this in logs of buildx docker instance:

time="2022-08-25T23:49:30Z" level=warning msg="reference for unknown type: application/vnd.buildkit.cacheconfig.v0"
time="2022-08-25T23:49:31Z" level=error msg="/moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = error writing manifest blob: failed commit on ref \"sha256:bd239a08c4b36bbc2397ea00826c1dd34c53ffbdf751685c4ae2955e631e1b81\": unexpected status: 404 Not Found\n"
time="2022-08-25T23:57:44Z" level=warning msg="reference for unknown type: application/vnd.buildkit.cacheconfig.v0"
time="2022-08-25T23:57:45Z" level=error msg="/moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = error writing manifest blob: failed commit on ref \"sha256:bd239a08c4b36bbc2397ea00826c1dd34c53ffbdf751685c4ae2955e631e1b81\": unexpected status: 404 Not Found\n"
time="2022-08-26T01:00:35Z" level=warning msg="reference for unknown type: application/vnd.buildkit.cacheconfig.v0"
time="2022-08-26T01:00:36Z" level=error msg="/moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = error writing manifest blob: failed commit on ref \"sha256:bd239a08c4b36bbc2397ea00826c1dd34c53ffbdf751685c4ae2955e631e1b81\": unexpected status: 404 Not Found\n"
time="2022-08-26T01:03:00Z" level=info msg="stopping server"
buildkitd: context canceled

can someone with knowledge confirm the support for application/vnd.buildkit.cacheconfig.v0 media type?

inline cache is probably good workaround: https://github.com/moby/buildkit#inline-push-image-and-cache-together