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

Commit 508f81a

Browse files
authored
deps: Update to lastest version spider/tumblebug
1 parent 5fd2c13 commit 508f81a

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

src/core/provision/provisioner.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,7 @@ func (self *Provisioner) InitControlPlane(kubernetesConfigReq app.ClusterConfigK
198198
} else {
199199
port = "6443"
200200
}
201-
if self.Cluster.Etcd == app.ETCD_LOCAL {
202-
if output, err := self.leader.executeSSH("cd %s;./%s %s %s %s %s %s", REMOTE_TARGET_PATH, "k8s-init.sh", kubernetesConfigReq.PodCidr, kubernetesConfigReq.ServiceCidr, kubernetesConfigReq.ServiceDnsDomain, self.leader.PublicIP, port); err != nil {
203-
return nil, "", errors.New("Failed to initialize control-plane. (k8s-init.sh)")
204-
} else if strings.Contains(output, "Your Kubernetes control-plane has initialized successfully") {
205-
joinCmd = getJoinCmd(output)
206-
} else {
207-
return nil, "", errors.New("to initialize control-plane (the output not contains 'Your Kubernetes control-plane has initialized successfully')")
208-
}
209-
} else {
201+
if self.Cluster.Etcd == app.ETCD_EXTERNAL {
210202
var etcdIp string
211203
for _, machine := range self.ControlPlaneMachines {
212204
etcdIp += fmt.Sprintf("%s ", machine.PrivateIP)
@@ -218,6 +210,14 @@ func (self *Provisioner) InitControlPlane(kubernetesConfigReq app.ClusterConfigK
218210
} else {
219211
return nil, "", errors.New("to initialize control-plane (the output not contains 'Your Kubernetes control-plane has initialized successfully')")
220212
}
213+
} else {
214+
if output, err := self.leader.executeSSH("cd %s;./%s %s %s %s %s %s", REMOTE_TARGET_PATH, "k8s-init.sh", kubernetesConfigReq.PodCidr, kubernetesConfigReq.ServiceCidr, kubernetesConfigReq.ServiceDnsDomain, self.leader.PublicIP, port); err != nil {
215+
return nil, "", errors.New("Failed to initialize control-plane. (k8s-init.sh)")
216+
} else if strings.Contains(output, "Your Kubernetes control-plane has initialized successfully") {
217+
joinCmd = getJoinCmd(output)
218+
} else {
219+
return nil, "", errors.New("to initialize control-plane (the output not contains 'Your Kubernetes control-plane has initialized successfully')")
220+
}
221221
}
222222

223223
ouput, _ := self.leader.executeSSH("sudo cat /etc/kubernetes/admin.conf")

src/core/service/cluster.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

src/core/service/mcir.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ func (self *MCIR) NewVM(namespace string, name string, mcisName string, vmCount
204204
}
205205

206206
func (self *MCIR) NewNLB(namespace string, mcisName string, groupId string) tumblebug.NLBReq {
207-
nlb := tumblebug.NewNLB(namespace, mcisName, groupId)
208-
nlb.Config = self.config
207+
nlb := tumblebug.NewNLB(namespace, mcisName, groupId, self.config)
209208
nlb.VPC = self.vpcName
210209
return *nlb
211210
}

src/core/service/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func AddNode(namespace string, clusterName string, req *app.NodeReq) (*model.Nod
113113
return nil, err
114114
}
115115
vms = append(vms, vm)
116-
provisioner.AppendWorkerNodeMachine(name, mcir.csp, mcir.region, mcir.zone, mcir.credential)
116+
provisioner.AppendWorkerNodeMachine(vm.Name, mcir.csp, mcir.region, mcir.zone, mcir.credential)
117117
idx = idx + 1
118118
}
119119
}

src/core/tumblebug/mcis.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,23 @@ func NewVM(namespace string, name string, mcisName string) *VM {
2626
}
2727

2828
/* new instance of NLB */
29-
func NewNLB(ns string, mcisName string, groupId string) *NLBReq {
29+
func NewNLB(ns string, mcisName string, groupId string, config string) *NLBReq {
3030
nlb := &NLBReq{
3131
NLBBase: NLBBase{
32-
Model: Model{Name: groupId, Namespace: ns},
33-
Type: "PUBLIC",
34-
Scope: "REGION", Listener: NLBProtocolBase{Protocol: "TCP", Port: "6443"},
32+
Model: Model{Name: groupId, Namespace: ns},
33+
Config: config,
34+
Type: "PUBLIC",
35+
Scope: "REGION", Listener: NLBProtocolBase{Protocol: "TCP", Port: "6443"},
3536
TargetGroup: TargetGroup{NLBProtocolBase: NLBProtocolBase{Protocol: "TCP", Port: "6443"}, MCIS: mcisName, VmGroupId: groupId},
3637
},
3738
HealthChecker: HealthCheckReq{
3839
NLBProtocolBase: NLBProtocolBase{Protocol: "TCP", Port: "22"},
3940
Interval: "default", Threshold: "default", Timeout: "default",
4041
},
4142
}
42-
43-
if strings.Contains(nlb.NLBBase.Config, string(app.CSP_NCPVPC)) {
43+
if strings.Contains(config, string(app.CSP_NCPVPC)) || strings.Contains(config, string(app.CSP_AZURE)) {
4444
nlb.HealthChecker.Timeout = "-1"
4545
}
46-
4746
if strings.Contains(nlb.NLBBase.Config, string(app.CSP_GCP)) {
4847
nlb.HealthChecker.NLBProtocolBase.Protocol = "HTTP"
4948
nlb.HealthChecker.NLBProtocolBase.Port = "80"

src/core/tumblebug/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ type MCIS struct {
164164
type VM struct {
165165
Model
166166
mcisName string //private
167-
VmGroupId string `json:"vmGroupId"`
168-
VmGroupSize string `json:"vmGroupSize"`
167+
VmGroupId string `json:"subGroupId"`
168+
VmGroupSize string `json:"subGroupSize"`
169169
Config string `json:"connectionName"`
170170
VPC string `json:"vNetId"`
171171
Subnet string `json:"subnetId"`
@@ -215,7 +215,7 @@ type HealthCheckRes struct {
215215
type TargetGroup struct {
216216
NLBProtocolBase
217217
MCIS string `json:"mcis"`
218-
VmGroupId string `json:"vmGroupId"`
218+
VmGroupId string `json:"subGroupId"`
219219
}
220220

221221
// NLB

src/rest-api/router/cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ func validateCreateClusterReq(clusterReq *app.ClusterReq) error {
161161
if len(clusterReq.Config.Kubernetes.Loadbalancer) != 0 && !(clusterReq.Config.Kubernetes.Loadbalancer == app.LB_HAPROXY || clusterReq.Config.Kubernetes.Loadbalancer == app.LB_NLB) {
162162
return errors.New("loadbalancer allows only haproxy or nlb")
163163
}
164+
if !(clusterReq.Config.Kubernetes.Etcd == app.ETCD_LOCAL || clusterReq.Config.Kubernetes.Etcd == app.ETCD_EXTERNAL) {
165+
return errors.New("etcd allows only local or external")
166+
}
164167
if clusterReq.Config.Kubernetes.Etcd == app.ETCD_EXTERNAL && (clusterReq.ControlPlane[0].Count != 3 && clusterReq.ControlPlane[0].Count != 5 && clusterReq.ControlPlane[0].Count != 7) {
165168
return errors.New("External etcd must have 3,5,7 controlPlane count")
166169
}

0 commit comments

Comments
 (0)