diff --git a/node/api/controller/node_controller.go b/node/api/controller/node_controller.go index 26d240c874..5b0b604a66 100644 --- a/node/api/controller/node_controller.go +++ b/node/api/controller/node_controller.go @@ -266,21 +266,32 @@ func PutLabel(w http.ResponseWriter, r *http.Request) { //DownNode 节点下线,计算节点操作 func DownNode(w http.ResponseWriter, r *http.Request) { nodeUID := strings.TrimSpace(chi.URLParam(r, "node_id")) - nodes, _ := nodeService.GetAllNode() - if nodes != nil && len(nodes) > 0 { - count := 0 - for _, node := range nodes { - if node.Role.HasRule("manage") { - count++ - } + n, err := nodeService.GetNode(nodeUID) + if err != nil { + err := utils.APIHandleError{ + Code: 402, + Err: errors.New(fmt.Sprint("Can not get node by nodeID")), } - if count < 2 { - err := utils.APIHandleError{ - Code: 403, - Err: errors.New(fmt.Sprint("manage node less one, can not down it.")), + err.Handle(r, w) + return + } + if n.Role.HasRule("manage") { + nodes, _ := nodeService.GetAllNode() + if nodes != nil && len(nodes) > 0 { + count := 0 + for _, node := range nodes { + if node.Role.HasRule("manage") { + count++ + } + } + if count < 2 { + err := utils.APIHandleError{ + Code: 403, + Err: errors.New(fmt.Sprint("manage node less two, can not down it.")), + } + err.Handle(r, w) + return } - err.Handle(r, w) - return } } logrus.Info("Node down by node api controller: ", nodeUID) diff --git a/node/core/service/node_service.go b/node/core/service/node_service.go index af335a5944..162df33c27 100644 --- a/node/core/service/node_service.go +++ b/node/core/service/node_service.go @@ -230,6 +230,7 @@ func (n *NodeService) UpNode(nodeID string) (*client.HostNode, *utils.APIHandleE if apierr != nil { return nil, apierr } + hostNode.Unschedulable = false // add the node to k8s if type is compute if hostNode.Role.HasRule(client.ComputeNode) { if k8snode, _ := n.kubecli.GetNode(hostNode.ID); k8snode == nil { diff --git a/node/masterserver/node/cluster.go b/node/masterserver/node/cluster.go index fc83f5b0c0..f2eb451047 100644 --- a/node/masterserver/node/cluster.go +++ b/node/masterserver/node/cluster.go @@ -251,11 +251,8 @@ func (n *Cluster) GetNode(id string) *client.HostNode { return nil } func (n *Cluster) handleNodeStatus(v *client.HostNode) { - logrus.Info("=====>node") if v.Role.HasRule("compute") { - logrus.Info("=====>compute") k8sNode, err := n.kubecli.GetNode(v.ID) - logrus.Info(k8sNode,"====k8sNode") status := Running if err != nil { logrus.Infof("get k8s node error:%s", err.Error()) @@ -275,7 +272,6 @@ func (n *Cluster) handleNodeStatus(v *client.HostNode) { } v.Unschedulable = false if k8sNode != nil { - logrus.Info(k8sNode.Spec.Unschedulable) v.UpdataK8sCondition(k8sNode.Status.Conditions) if v.Unschedulable == true || k8sNode.Spec.Unschedulable == true{ v.Unschedulable = true @@ -339,7 +335,6 @@ func (n *Cluster) handleNodeStatus(v *client.HostNode) { } if v.Role.HasRule("manage") && !v.Role.HasRule("compute") { //manage install_success == runnint - logrus.Info("=====>manage") if v.Status == Init || v.Status == InitSuccess || v.Status == InitFailed || v.Status == Installing { return }