@@ -158,7 +158,7 @@ func CreateCluster(namespace string, req *app.ClusterReq) (*model.Cluster, error
158158 for i := 0 ; i < mcir .vmCount ; i ++ {
159159 name := lang .GenerateNewNodeName (string (app .WORKER ), idx + 1 )
160160 mcis .VMs = append (mcis .VMs , mcir .NewVM (namespace , name , mcisName , "" , worker .RootDisk .Type , worker .RootDisk .Size ))
161- provisioner .AppendWorkerNodeMachine (name , mcir .csp , mcir .region , mcir .zone , mcir .credential )
161+ provisioner .AppendWorkerNodeMachine (name + "-1" , mcir .csp , mcir .region , mcir .zone , mcir .credential )
162162 idx = idx + 1
163163 }
164164 }
@@ -179,12 +179,11 @@ func CreateCluster(namespace string, req *app.ClusterReq) (*model.Cluster, error
179179 logger .Infof ("[%s.%s] MCIS creation has been completed." , namespace , clusterName )
180180 cluster .CpLeader = mcis .VMs [0 ].Name
181181
182- for i := 0 ; i < len ( mcis .VMs ); i ++ {
183- if cluster .CpGroup == mcis . VMs [ i ] .VmGroupId {
184- provisioner .AppendControlPlaneMachine (mcis . VMs [ i ] .Name , mcir .csp , mcir .region , mcir .zone , mcir .credential )
182+ for _ , vms := range mcis .VMs {
183+ if cluster .CpGroup == vms .VmGroupId {
184+ provisioner .AppendControlPlaneMachine (vms .Name , mcir .csp , mcir .region , mcir .zone , mcir .credential )
185185 }
186186 }
187-
188187 //create a NLB (contains control-plane)
189188 if cluster .Loadbalancer != app .LB_HAPROXY {
190189 NLB := mcir .NewNLB (namespace , mcisName , cluster .CpGroup )
@@ -193,7 +192,7 @@ func CreateCluster(namespace string, req *app.ClusterReq) (*model.Cluster, error
193192 return nil , errors .New (cluster .Status .Message )
194193 } else if ! exists {
195194 if err := NLB .POST (); err != nil {
196- cluster .FailReason (model .CreateNLBFailedReason , fmt .Sprintf ("Failed to create a NLB. (cause='%v')" , err ))
195+ cluster .FailReason (model .CreateNLBFailedReason , fmt .Sprintf ("Failed to create a NLB. (cause='%v')" , NLB ))
197196 return nil , errors .New (cluster .Status .Message )
198197 }
199198 logger .Infof ("[%s] NLB creation has been completed. (%s)" , req .ControlPlane [0 ].Connection , NLB .TargetGroup .VmGroupId )
0 commit comments