diff --git a/app/cluster.go b/app/cluster.go index 9d6f6b0..ed3bb73 100644 --- a/app/cluster.go +++ b/app/cluster.go @@ -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