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
f91a2749d5
commit
37366342c2
@ -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 获取一个节点详情
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user