mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
build: fix incorrect solve opt platform from being set
This regression was introduced in 616fb3e55c
,
with the node resolution refactor.
The core issue here is just that we would unconditionally set the
solve opt's platform to the default current platform, which was
incorrect. We can prevent this easily by having a special case for the
default case, like we had before, and then not setting the platforms
field on this (which keeping the resolution behavior which was
introduced).
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
aa0aeac297
commit
aac7a47469
@ -164,28 +164,36 @@ func (r *nodeResolver) resolve(ctx context.Context, ps []specs.Platform, pw prog
|
||||
return nil, true, nil
|
||||
}
|
||||
|
||||
if len(ps) == 0 {
|
||||
ps = []specs.Platform{platforms.DefaultSpec()}
|
||||
}
|
||||
|
||||
perfect := true
|
||||
nodeIdxs := make([]int, 0)
|
||||
for _, p := range ps {
|
||||
idx := r.get(p, matcher, additional)
|
||||
if len(ps) == 0 {
|
||||
idx := r.get(platforms.DefaultSpec(), matcher, additional)
|
||||
if idx == -1 {
|
||||
idx = 0
|
||||
perfect = false
|
||||
}
|
||||
nodeIdxs = append(nodeIdxs, idx)
|
||||
} else {
|
||||
for _, p := range ps {
|
||||
idx := r.get(p, matcher, additional)
|
||||
if idx == -1 {
|
||||
idx = 0
|
||||
perfect = false
|
||||
}
|
||||
nodeIdxs = append(nodeIdxs, idx)
|
||||
}
|
||||
}
|
||||
|
||||
var nodes []*resolvedNode
|
||||
for i, idx := range nodeIdxs {
|
||||
nodes = append(nodes, &resolvedNode{
|
||||
node := &resolvedNode{
|
||||
resolver: r,
|
||||
driverIndex: idx,
|
||||
platforms: []specs.Platform{ps[i]},
|
||||
})
|
||||
}
|
||||
if len(ps) > 0 {
|
||||
node.platforms = []specs.Platform{ps[i]}
|
||||
}
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
nodes = recombineNodes(nodes)
|
||||
if _, err := r.boot(ctx, nodeIdxs, pw); err != nil {
|
||||
|
@ -22,6 +22,7 @@ func TestFindDriverSanity(t *testing.T) {
|
||||
require.Len(t, res, 1)
|
||||
require.Equal(t, 0, res[0].driverIndex)
|
||||
require.Equal(t, "aaa", res[0].Node().Builder)
|
||||
require.Equal(t, []specs.Platform{platforms.DefaultSpec()}, res[0].platforms)
|
||||
}
|
||||
|
||||
func TestFindDriverEmpty(t *testing.T) {
|
||||
@ -227,6 +228,7 @@ func TestSelectNodeCurrentPlatform(t *testing.T) {
|
||||
require.True(t, perfect)
|
||||
require.Len(t, res, 1)
|
||||
require.Equal(t, "bbb", res[0].Node().Builder)
|
||||
require.Empty(t, res[0].platforms)
|
||||
}
|
||||
|
||||
func TestSelectNodeAdditionalPlatforms(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user