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 d1c3471 commit f0dd075
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (
// ClusterStatusCreateFailed create failed
ClusterStatusCreateFailed = "K8S_CLUSTER_STATE_CREATE_FAILED"

// MasterNodePoolName master node pool name
MasterNodePoolName = "system-nodepool"
// NodePoolStatusInitial nodepool initial state
NodePoolStatusInitial = "NODE_POOL_STATE_INITIAL"
// NodePoolStatusCreateFailed nodepool create failed state
Expand All @@ -33,6 +35,11 @@ const (
// NodeStatusUnknown node unknown state
NodeStatusUnknown = "NODE_STATE_UNKNOWN"

// NodeRoleMaster master node
NodeRoleMaster = "NODE_ROLE_MASTER"
// NodeRoleWorker worker node
NodeRoleWorker = "NODE_ROLE_WORKER"

// DisKIOTypeNormal normal IO disk
DisKIOTypeNormal = "DISK_IO_TYPE_NORMAL"
// DisKIOTypeHigh high IO disk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ func checkClusterNodesStatus(ctx context.Context, info *cloudprovider.CloudDepen
nodePoolList = append(nodePoolList, nodeGroup.CloudNodeGroupID)
}

// add master node num
totalNodesNum += info.Cluster.Template[0].ApplyNum
// master节点的节点池由ecp自动创建, 有默认名称
nodePoolList = append(nodePoolList, api.MasterNodePoolName)

// get eopCloud client
cli, err := api.NewCTClient(info.CmOption)
if err != nil {
Expand All @@ -861,6 +866,8 @@ func checkClusterNodesStatus(ctx context.Context, info *cloudprovider.CloudDepen
return nil
}

blog.Infof("checkClusterNodesStatus expected nodes %d , current nodes %d ", totalNodesNum, len(nodes))

running, failure := make([]string, 0), make([]string, 0)
index := 0
for _, node := range nodes {
Expand Down Expand Up @@ -1022,6 +1029,23 @@ func updateNodeToDB(ctx context.Context, info *cloudprovider.CloudDependBasicInf
return nil
}

if result[0].Role == api.NodeRoleMaster {
node := &proto.Node{
NodeID: result[0].InstanceId,
InnerIP: result[0].InnerIp,
InstanceType: info.Cluster.Template[0].InstanceType,
ClusterID: info.Cluster.ClusterID,
VPC: info.Cluster.Template[0].VpcID,
Region: info.Cluster.Template[0].Region,
NodeName: result[0].NodeName,
}
err = cloudprovider.GetStorageModel().CreateNode(context.Background(), node)
if err != nil {
return fmt.Errorf("updateNodeToDB CreateNode[%s] failed, %v", node.NodeName, err)
}
continue
}

for _, ng := range nodeGroups {
if result[0].NodePoolId == ng.CloudNodeGroupID {
node := &proto.Node{
Expand Down

0 comments on commit f0dd075

Please sign in to comment.