[REV] optimize node status

This commit is contained in:
bay1ts 2017-12-07 16:48:30 +08:00
parent f91a2749d5
commit 37366342c2
2 changed files with 17 additions and 4 deletions

View File

@ -77,15 +77,23 @@ func GetNodes(w http.ResponseWriter, r *http.Request) {
return
}
for _,v:=range nodes {
if v.NodeStatus!=nil{
for _,condiction:=range v.Conditions{
handleStatus(v)
}
httputil.ReturnSuccess(r, w, nodes)
}
func handleStatus(v *model.HostNode){
if v.NodeStatus!=nil{
for _,condiction:=range v.Conditions{
if v.Status == "unschedulable" {
}else{
if condiction.Type=="Ready"&&condiction.Status=="True" {
v.Status="running"
}
}
}
}
}
httputil.ReturnSuccess(r, w, nodes)
}
//GetNode 获取一个节点详情

View File

@ -124,6 +124,11 @@ func (n *NodeService) CordonNode(nodeID string, unschedulable bool) *utils.APIHa
//更新节点状态
hostNode.Unschedulable = unschedulable
//k8s节点存在
if unschedulable {
hostNode.Status="unschedulable"
}else{
hostNode.Status="schedulable"
}
if hostNode.NodeStatus != nil {
//true表示drain不可调度
node, err := k8s.CordonOrUnCordon(hostNode.ID, unschedulable)