Merge branch 'V3.7' of github.com:goodrain/rainbond into V3.7

This commit is contained in:
ysicing 2018-08-06 17:01:32 +08:00
commit c6a5739a8c
3 changed files with 25 additions and 18 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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
}