should list real pod nodes when all drivers are kubernetes

Signed-off-by: Wang <morlay.null@gmail.com>
pull/477/head
Wang Jinglei 4 years ago committed by Wang
parent 11057da373
commit dd13e16bc7

@ -403,13 +403,24 @@ func loadNodeGroupData(ctx context.Context, dockerCli command.Cli, ngi *nginfo)
return err return err
} }
// skip when multi drivers kubernetesDriverCount := 0
if len(ngi.drivers) == 1 {
for _, di := range ngi.drivers {
if di.info != nil && len(di.info.DynamicNodes) > 0 {
kubernetesDriverCount++
}
}
isAllKubernetesDrivers := len(ngi.drivers) == kubernetesDriverCount
if isAllKubernetesDrivers {
var drivers []dinfo
var dynamicNodes []store.Node
for _, di := range ngi.drivers { for _, di := range ngi.drivers {
// dynamic nodes are used in Kubernetes driver. // dynamic nodes are used in Kubernetes driver.
// Kubernetes pods are dynamically mapped to BuildKit Nodes. // Kubernetes pods are dynamically mapped to BuildKit Nodes.
if di.info != nil && len(di.info.DynamicNodes) > 0 { if di.info != nil && len(di.info.DynamicNodes) > 0 {
var drivers []dinfo
for i := 0; i < len(di.info.DynamicNodes); i++ { for i := 0; i < len(di.info.DynamicNodes); i++ {
// all []dinfo share *build.DriverInfo and *driver.Info // all []dinfo share *build.DriverInfo and *driver.Info
diClone := di diClone := di
@ -418,14 +429,16 @@ func loadNodeGroupData(ctx context.Context, dockerCli command.Cli, ngi *nginfo)
} }
drivers = append(drivers, di) drivers = append(drivers, di)
} }
// not append (remove the static nodes in the store) dynamicNodes = append(dynamicNodes, di.info.DynamicNodes...)
ngi.ng.Nodes = di.info.DynamicNodes
ngi.ng.Dynamic = true
ngi.drivers = drivers
return nil
} }
} }
// not append (remove the static nodes in the store)
ngi.ng.Nodes = dynamicNodes
ngi.drivers = drivers
ngi.ng.Dynamic = true
} }
return nil return nil
} }

Loading…
Cancel
Save