[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 return
} }
for _,v:=range nodes { for _,v:=range nodes {
if v.NodeStatus!=nil{ handleStatus(v)
for _,condiction:=range v.Conditions{ }
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" { if condiction.Type=="Ready"&&condiction.Status=="True" {
v.Status="running" v.Status="running"
} }
} }
} }
} }
httputil.ReturnSuccess(r, w, nodes)
} }
//GetNode 获取一个节点详情 //GetNode 获取一个节点详情

View File

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