Skip to content

Commit

Permalink
feature: cluster manager support ctyun creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Maclon9573 committed Oct 12, 2023
1 parent f0dd075 commit 9c6ee6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ func (ca *CreateAction) createNodegroup(cls *cmproto.Cluster) error {
}
ng.LaunchTemplate.InitLoginPassword = enPasswd
}
blog.Infof("---------- worker system disk type %s", ng.LaunchTemplate.SystemDisk.DiskType)

err := ca.model.CreateNodeGroup(context.Background(), ng)
if err != nil {
Expand Down Expand Up @@ -517,8 +516,6 @@ func (ca *CreateAction) createClusterTask(ctx context.Context, cls *cmproto.Clus
// encrypt password
if len(cls.Template) != 0 {
for _, t := range cls.Template {
blog.Infof("---------- worker system disk type %s", t.SystemDisk.DiskType)

if t.InitLoginPassword != "" {
enPasswd, err := encrypt.Encrypt(nil, t.InitLoginPassword)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ func generateWorkerNodes(cls *proto.Cluster, vpcId, subnetId uint32, groups []*p
})
}

blog.Infof("---------- worker system disk type %s", ng.LaunchTemplate.SystemDisk.DiskType)
workerNodes = append(workerNodes, &api.WorkerNode{
DataDisks: dataDisks,
ImageName: cls.ClusterBasicSettings.OS,
Expand Down Expand Up @@ -341,8 +340,6 @@ func generateMasterNodes(cls *proto.Cluster, vpcId, subnetId uint32) (*api.Maste
})
}

blog.Infof("---------- master system disk type %s", cls.Template[0].SystemDisk.DiskType)

masterNode := &api.MasterNode{
DataDisks: dataDisks,
ImageName: cls.ClusterBasicSettings.OS,
Expand Down Expand Up @@ -465,7 +462,7 @@ func checkClusterStatus(ctx context.Context, info *cloudprovider.CloudDependBasi
err = loop.LoopDoFunc(ctx, func() error {
cluster, errGet := cli.GetCluster(systemID)
if errGet != nil {
blog.Errorf("checkClusterStatus[%s] GetCluster failed: %v", taskID, errGet)
blog.Errorf("checkClusterStatus[%s] failed: %v", taskID, errGet)
return nil
}

Expand Down Expand Up @@ -604,18 +601,22 @@ func checkNodesGroupStatus(ctx context.Context, info *cloudprovider.CloudDependB
err = loop.LoopDoFunc(ctx, func() error {
index := 0
for _, ng := range nodeGroups {
eckNodePools, err := cli.ListNodePool(&api.ListNodePoolReq{
eckNodePools, errQuery := cli.ListNodePool(&api.ListNodePoolReq{
ClusterID: systemID,
NodePoolName: ng.NodeGroupID,
})
if err != nil {
blog.Errorf("checkNodesGroupStatus[%s] ListNodePool failed: %v", taskID, err)
if errQuery != nil {
blog.Errorf("checkNodesGroupStatus[%s] failed: %v", taskID, err)
return nil
}
if len(eckNodePools) == 0 {
blog.Errorf("checkNodesGroupStatus[%s] ListNodePool[%s] not found", taskID, ng.NodeGroupID)
return nil
}

blog.Infof("checkNodesGroupStatus[%s] nodeGroup[%s] status %s",
taskID, ng.NodeGroupID, eckNodePools[0].State)

switch eckNodePools[0].State {
case api.NodePoolStatusActive:
running = append(running, ng.NodeGroupID)
Expand All @@ -638,6 +639,9 @@ func checkNodesGroupStatus(ctx context.Context, info *cloudprovider.CloudDependB
return nil, nil, err
}

blog.Infof("checkNodesGroupStatus[%s] success[%v] failure[%v]",
taskID, addSuccessNodeGroups, addFailureNodeGroups)

return addSuccessNodeGroups, addFailureNodeGroups, nil
}

Expand Down Expand Up @@ -862,18 +866,20 @@ func checkClusterNodesStatus(ctx context.Context, info *cloudprovider.CloudDepen
PerPage: totalNodesNum,
})
if errGet != nil {
blog.Errorf("checkClusterNodesStatus[%s] ListNodes failed: %v", taskID, errGet)
blog.Errorf("checkClusterNodesStatus[%s] failed: %v", taskID, errGet)
return nil
}

blog.Infof("checkClusterNodesStatus expected nodes %d , current nodes %d ", totalNodesNum, len(nodes))
blog.Infof("checkClusterNodesStatus[%s] expected nodes %d , current nodes %d ",
taskID, totalNodesNum, len(nodes))

running, failure := make([]string, 0), make([]string, 0)
index := 0
for _, node := range nodes {
if !utils.StringInSlice(node.NodePoolId, nodePoolList) {
continue
}
blog.Infof("checkClusterNodesStatus[%s] node[%s] state %s", taskID, node.NodeName, node.State)
switch node.State {
case api.NodeStatusRunning:
index++
Expand Down

0 comments on commit 9c6ee6d

Please sign in to comment.