From 8aeb946dfc4d89926977d0f25ce0e78961fe1ef2 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Thu, 7 Nov 2024 18:59:42 +0000 Subject: [PATCH] fix: allow empty run layers to be pushed without force build meta Images of type application/vnd.docker.image.rootfs.diff.tar.gzip seem to break when you try to push metadata-only layers and the layers all share the same hash. This doesn't seem to be a problem with OCI images. Ref: coder/envbuilder#385 --- pkg/executor/build.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/executor/build.go b/pkg/executor/build.go index 70fc4ab842..73c85bf2b3 100644 --- a/pkg/executor/build.go +++ b/pkg/executor/build.go @@ -564,7 +564,11 @@ func (s *stageBuilder) takeSnapshot(files []string, shdDelete bool) (string, err } else { // Volumes are very weird. They get snapshotted in the next command. files = append(files, util.Volumes()...) - snapshot, err = s.snapshotter.TakeSnapshot(files, shdDelete, s.opts.ForceBuildMetadata) + forceBuildMetadata := s.opts.ForceBuildMetadata + if s.opts.Cache && len(s.opts.Destinations) > 0 && !s.opts.NoPush { + forceBuildMetadata = true + } + snapshot, err = s.snapshotter.TakeSnapshot(files, shdDelete, forceBuildMetadata) } timing.DefaultRun.Stop(t) return snapshot, err