fix:修复集群删除超时程序崩溃问题

This commit is contained in:
devad 2023-02-23 11:30:54 +08:00
parent c4cee86f8c
commit a22e653c26
1 changed files with 12 additions and 11 deletions

View File

@ -227,7 +227,6 @@ func ListClusterWithLabel(c *gin.Context) {
// @Failure 500
// @Router /api/v1/cluster/unJoin [delete]
func UnJoin(c *gin.Context) {
copyContext := c.Copy()
clusterName := c.Query("cluster_name")
domainId := c.Query("domain_id")
if clusterName == "" || domainId == "" {
@ -241,19 +240,21 @@ func UnJoin(c *gin.Context) {
Wait: options.DefaultKarmadactlCommandDuration,
}
go func() {
glog.Info("异步执行:" + copyContext.Request.URL.Path)
err := karmadactl.UnJoinCluster(ControlPlaneRestConfig, nil, opts)
if err != nil {
glog.Errorf("failed to delete cluster. context: %s, kube-config: %s, error: %v", opts.KarmadaContext, opts.KubeConfig, err)
Response(c, http.StatusInternalServerError, fmt.Sprintf("failed to delete cluster. context: %s, kube-config: %s, error: %v",
opts.KarmadaContext, opts.KubeConfig, err), "")
return
}
}()
go kdUnCluster(opts)
Response(c, http.StatusOK, "success", "")
}
// 删除指定集群
func kdUnCluster(opts karmadactl.CommandUnjoinOption) {
glog.Info("调度中心删除集群,集群名称:", opts.ClusterName)
err := karmadactl.UnJoinCluster(ControlPlaneRestConfig, nil, opts)
if err != nil {
glog.Errorf("failed to delete cluster. error: %v", err)
return
}
return
}
// @Summary 直接连模式加入联邦
// @Description 直连模式加入联邦
// @Tags cluster