Skip to content
This repository was archived by the owner on Sep 13, 2025. It is now read-only.

Commit a74c174

Browse files
authored
fix: vm creation logic when adding nodes
1 parent cc920d2 commit a74c174

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/core/service/node.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func AddNode(namespace string, clusterName string, req *app.NodeReq) (*model.Nod
9898

9999
// create a MCIR & MCIS-vm
100100
idx := cluster.NextNodeIndex(app.WORKER)
101-
vms := []tumblebug.VM{}
101+
var vmgroupid []string
102102
for _, worker := range req.Worker {
103103
mcir := NewMCIR(namespace, app.WORKER, *worker)
104104
reason, msg := mcir.CreateIfNotExist()
@@ -112,12 +112,24 @@ func AddNode(namespace string, clusterName string, req *app.NodeReq) (*model.Nod
112112
cleanUpNodes(*provisioner)
113113
return nil, err
114114
}
115-
vms = append(vms, vm)
116-
provisioner.AppendWorkerNodeMachine(vm.Name, mcir.csp, mcir.region, mcir.zone, mcir.credential)
115+
vmgroupid = append(vmgroupid, name)
116+
provisioner.AppendWorkerNodeMachine(name+"-1", mcir.csp, mcir.region, mcir.zone, mcir.credential)
117117
idx = idx + 1
118118
}
119119
}
120120
}
121+
// Pull out the added VMlist
122+
if _, err := mcis.GET(); err != nil {
123+
return nil, err
124+
}
125+
vms := []tumblebug.VM{}
126+
for _, mcisvm := range mcis.VMs {
127+
for _, grupid := range vmgroupid {
128+
if mcisvm.VmGroupId == grupid {
129+
vms = append(vms, mcisvm)
130+
}
131+
}
132+
}
121133
logger.Infof("[%s.%s] MCIS(vm) creation has been completed. (len=%d)", namespace, clusterName, len(vms))
122134

123135
// save nodes metadata

0 commit comments

Comments
 (0)