builder-next: make sure worker platforms normalized for containerd

These platforms are filled by default from containerd
introspection API and may not be normalized. Initializing
wrong platform in here results in incorrect platform
for BUILDPLATFORM and TARGETPLATFORM build-args for
Dockerfile frontend (and probably other side effects).

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi 2023-10-30 23:14:30 -07:00
parent e9efc0a361
commit a99bb24ea8
No known key found for this signature in database
GPG key ID: AFA9DE5F8AB7AF39

View file

@ -10,6 +10,7 @@ import (
ctd "github.com/containerd/containerd"
"github.com/containerd/containerd/content/local"
ctdmetadata "github.com/containerd/containerd/metadata"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/snapshots"
"github.com/containerd/log"
"github.com/docker/docker/api/types"
@ -105,6 +106,11 @@ func newSnapshotterController(ctx context.Context, rt http.RoundTripper, opt Opt
return nil, err
}
// make sure platforms are normalized moby/buildkit#4391
for i, p := range wo.Platforms {
wo.Platforms[i] = platforms.Normalize(p)
}
wo.GCPolicy = policy
wo.RegistryHosts = opt.RegistryHosts
wo.Labels = getLabels(opt, wo.Labels)