mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-29 17:05:46 +08:00
build: fix incorrect solve opt platform from being set
This regression was introduced in 616fb3e55cbc85647026f6e409af17e1011a85c4, 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,12 +164,16 @@ 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)
|
||||
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 {
|
||||
@ -178,14 +182,18 @@ func (r *nodeResolver) resolve(ctx context.Context, ps []specs.Platform, pw prog
|
||||
}
|
||||
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…
x
Reference in New Issue
Block a user