mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[REV] optimize node status
This commit is contained in:
parent
84b34ea2e9
commit
661676382d
@ -76,6 +76,15 @@ func GetNodes(w http.ResponseWriter, r *http.Request) {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
for _,v:=range nodes {
|
||||
if v.NodeStatus!=nil{
|
||||
for _,v:=range v.Conditions{
|
||||
if v.Type=="Ready"&&v.Status=="True" {
|
||||
v.Status="running"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
httputil.ReturnSuccess(r, w, nodes)
|
||||
}
|
||||
|
||||
|
@ -78,11 +78,21 @@ func ExecTask(w http.ResponseWriter, r *http.Request) {
|
||||
if ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &nodes, nil); !ok {
|
||||
return
|
||||
}
|
||||
|
||||
err := taskService.ExecTask(taskID, nodes.Nodes)
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
for _,v:=range nodes.Nodes {
|
||||
node, err := nodeService.GetNode(v)
|
||||
if err != nil {
|
||||
err.Handle(r, w)
|
||||
return
|
||||
}
|
||||
node.Status="install"
|
||||
}
|
||||
|
||||
httputil.ReturnSuccess(r, w, nil)
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,7 @@ func (n *NodeService) AddNode(node *model.APIHostNode) *utils.APIHandleError {
|
||||
}
|
||||
}
|
||||
rbnode := node.Clone()
|
||||
rbnode.Status="init"
|
||||
rbnode.CreateTime = time.Now()
|
||||
rbnode.Conditions = make([]model.NodeCondition, 0)
|
||||
if _, err := rbnode.Update(); err != nil {
|
||||
@ -163,6 +164,7 @@ func (n *NodeService) DownNode(nodeID string) (*model.HostNode, *utils.APIHandle
|
||||
if !hostNode.Role.HasRule(model.ComputeNode) || hostNode.NodeStatus == nil {
|
||||
return nil, utils.CreateAPIHandleError(400, fmt.Errorf("node is not k8s node or it not up"))
|
||||
}
|
||||
hostNode.Status="down"
|
||||
err := k8s.DeleteNode(hostNode.ID)
|
||||
if err != nil {
|
||||
return nil, utils.CreateAPIHandleError(500, fmt.Errorf("k8s node down error,%s", err.Error()))
|
||||
|
Loading…
Reference in New Issue
Block a user