Skip to content

Commit

Permalink
feat: kubeconfig和云帐号导入集群优化
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyudeqiu committed Nov 13, 2024
1 parent 4029c0a commit 0f32c54
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ func ImportClusterNodesTask(taskID string, stepName string) error {
return retErr
}

// import cluster instances
err = importClusterInstances(basicInfo)
if err != nil {
blog.Errorf("ImportClusterNodesTask[%s]: importClusterInstances failed: %v", taskID, err)
retErr := fmt.Errorf("importClusterInstances failed, %s", err.Error())
_ = state.UpdateStepFailure(start, stepName, retErr)
return retErr
}

// update cluster masterNodes info
err = cloudprovider.GetStorageModel().UpdateCluster(context.Background(), basicInfo.Cluster)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ func importClusterInstances(data *cloudprovider.CloudDependBasicInfo) error {
}
}

err = importClusterNodesToCM(context.Background(), nodes.Items, data.Cluster.ClusterID)
if err != nil {
return err
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ func importClusterInstances(data *cloudprovider.CloudDependBasicInfo) error {
data.Cluster.Master = masterNodes
// data.Cluster.Status = icommon.StatusRunning

// 导入方式是 kubeconfig 集群节点不写入数据库
if data.Cluster.ImportCategory == icommon.KubeConfigImport {
return nil
}

err = importClusterNodesToCM(context.Background(), nodeIPs, &cloudprovider.ListNodesOption{
Common: data.CmOption,
ClusterVPCID: data.Cluster.VpcID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ func ImportClusterNodesTask(taskID string, stepName string) error {
return retErr
}

// import cluster instances
err = importClusterInstances(basicInfo)
if err != nil {
blog.Errorf("ImportClusterNodesTask[%s]: importClusterInstances failed: %v", taskID, err)
retErr := fmt.Errorf("importClusterInstances failed, %s", err.Error())
_ = state.UpdateStepFailure(start, stepName, retErr)
return retErr
}

// update cluster masterNodes info
_ = cloudprovider.GetStorageModel().UpdateCluster(context.Background(), basicInfo.Cluster)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,6 @@ func ImportClusterNodesTask(taskID string, stepName string) error {
return retErr
}

// import cluster instances
err = importClusterInstances(basicInfo)
if err != nil {
blog.Errorf("ImportClusterNodesTask[%s]: importClusterInstances failed: %v", taskID, err)
retErr := fmt.Errorf("importClusterInstances failed, %s", err.Error())
_ = state.UpdateStepFailure(start, stepName, retErr)
return retErr
}

// update cluster masterNodes info
err = cloudprovider.GetStorageModel().UpdateCluster(context.Background(), basicInfo.Cluster)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,21 +419,6 @@ func importClusterInstances(data *cloudprovider.CloudDependBasicInfo) ([]string,
data.Cluster.Master = masterNodes
}

err = importClusterNodesToCM(context.Background(), nodeInfos, &cloudprovider.ListNodesOption{
Common: data.CmOption,
ClusterVPCID: data.Cluster.VpcID,
ClusterID: data.Cluster.ClusterID,
NodeTemplateID: func() string {
if data.NodeTemplate != nil {
return data.NodeTemplate.NodeTemplateID
}
return ""
}(),
})
if err != nil {
return nil, nil, err
}

return masterIPs, nodeIPs, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,6 @@ func ImportClusterNodesTask(taskID string, stepName string) error {
return retErr
}

// import cluster instances
err = importClusterInstances(basicInfo)
if err != nil {
cloudprovider.GetStorageModel().CreateTaskStepLogError(context.Background(), taskID, stepName,
fmt.Sprintf("import cluster instances failed [%s]", err))
blog.Errorf("ImportClusterNodesTask[%s]: importClusterInstances failed: %v", taskID, err)
retErr := fmt.Errorf("importClusterInstances failed, %s", err.Error())
_ = state.UpdateStepFailure(start, stepName, retErr)
return retErr
}

// update cluster masterNodes info
err = cloudprovider.GetStorageModel().UpdateCluster(context.Background(), basicInfo.Cluster)
if err != nil {
Expand Down

0 comments on commit 0f32c54

Please sign in to comment.