From dd13e16bc773f2d741ca679547d50bd34c15587d Mon Sep 17 00:00:00 2001 From: Wang Jinglei Date: Tue, 15 Dec 2020 16:02:04 +0800 Subject: [PATCH] should list real pod nodes when all drivers are kubernetes Signed-off-by: Wang --- commands/util.go | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/commands/util.go b/commands/util.go index d6e230eb..f43a282b 100644 --- a/commands/util.go +++ b/commands/util.go @@ -403,13 +403,24 @@ func loadNodeGroupData(ctx context.Context, dockerCli command.Cli, ngi *nginfo) return err } - // skip when multi drivers - if len(ngi.drivers) == 1 { + kubernetesDriverCount := 0 + + 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 { // dynamic nodes are used in Kubernetes driver. // Kubernetes pods are dynamically mapped to BuildKit Nodes. if di.info != nil && len(di.info.DynamicNodes) > 0 { - var drivers []dinfo for i := 0; i < len(di.info.DynamicNodes); i++ { // all []dinfo share *build.DriverInfo and *driver.Info diClone := di @@ -418,14 +429,16 @@ func loadNodeGroupData(ctx context.Context, dockerCli command.Cli, ngi *nginfo) } drivers = append(drivers, di) } - // not append (remove the static nodes in the store) - ngi.ng.Nodes = di.info.DynamicNodes - ngi.ng.Dynamic = true - ngi.drivers = drivers - return nil + dynamicNodes = append(dynamicNodes, di.info.DynamicNodes...) } } + + // not append (remove the static nodes in the store) + ngi.ng.Nodes = dynamicNodes + ngi.drivers = drivers + ngi.ng.Dynamic = true } + return nil }