diff --git a/builder/exector/plugin_image.go b/builder/exector/plugin_image.go index 07839313b..3a374cde7 100644 --- a/builder/exector/plugin_image.go +++ b/builder/exector/plugin_image.go @@ -18,22 +18,6 @@ package exector -/* -Copyright 2017 The Goodrain Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - import ( "fmt" "strings" diff --git a/node/api/controller/node_controller.go b/node/api/controller/node_controller.go index 12056d2a5..3bb37fc0a 100644 --- a/node/api/controller/node_controller.go +++ b/node/api/controller/node_controller.go @@ -109,6 +109,8 @@ func handleStatus(v *model.HostNode) { } } } + } else { + v.Status = "down" } if v.Role.HasRule("manage") { //manage install_success == runnint if v.Status == "init" || v.Status == "init_success" || v.Status == "init_failed" || v.Status == "installing" || v.Status == "install_failed" { diff --git a/node/api/model/node.go b/node/api/model/node.go index d5c608fc6..51d5ff885 100644 --- a/node/api/model/node.go +++ b/node/api/model/node.go @@ -79,6 +79,7 @@ type HostNode struct { } type NodeList []*HostNode + func (list NodeList) Len() int { return len(list) } @@ -96,7 +97,9 @@ func (list NodeList) Swap(i, j int) { list[i] = list[j] list[j] = temp } + type TaskResult []*ExecedTask + func (c TaskResult) Len() int { return len(c) } @@ -104,11 +107,11 @@ func (c TaskResult) Swap(i, j int) { c[i], c[j] = c[j], c[i] } func (c TaskResult) Less(i, j int) bool { - if c[i].Status == "complete"&&(c[j].Status=="start"||c[j].Status=="wait") { + if c[i].Status == "complete" && (c[j].Status == "start" || c[j].Status == "wait") { return true } - if c[i].Status=="start" { - if c[j].Status=="complete" { + if c[i].Status == "start" { + if c[j].Status == "complete" { return false } if c[j].Status == "wait" { @@ -116,11 +119,12 @@ func (c TaskResult) Less(i, j int) bool { } return true } - if c[i].Status=="wait" { + if c[i].Status == "wait" { return false } return true } + //GetNodeFromKV 从etcd解析node信息 func GetNodeFromKV(kv *mvccpb.KeyValue) *HostNode { var node HostNode @@ -146,6 +150,17 @@ func (h *HostNode) UpdataK8sCondition(conditions []v1.NodeCondition) { } } +//DeleteCondition DeleteCondition +func (h *HostNode) DeleteCondition(types ...NodeConditionType) { + for i, c := range h.Conditions { + for _, t := range types { + if c.Type.Compare(t) { + h.Conditions = append(h.Conditions[:i], h.Conditions[i+1:]...) + } + } + } +} + //UpdataCondition 更新状态 func (h *HostNode) UpdataCondition(conditions ...NodeCondition) { var ready = ConditionTrue @@ -215,7 +230,10 @@ const ( // InstallNotReady means the installation task was not completed in this node. InstallNotReady NodeConditionType = "InstallNotReady" // NodeInit means node already install rainbond node and regist - NodeInit NodeConditionType = "NodeInit" + NodeInit NodeConditionType = "NodeInit" + OutOfDisk NodeConditionType = "OutOfDisk" + MemoryPressure NodeConditionType = "MemoryPressure" + DiskPressure NodeConditionType = "DiskPressure" ) //Compare 比较 diff --git a/node/core/service/node_service.go b/node/core/service/node_service.go index b5f6306e4..f7e666edf 100644 --- a/node/core/service/node_service.go +++ b/node/core/service/node_service.go @@ -172,11 +172,11 @@ 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())) } + hostNode.Status = "down" hostNode.NodeStatus = nil n.nodecluster.UpdateNode(hostNode) return hostNode, nil diff --git a/node/masterserver/node/nodecluster.go b/node/masterserver/node/nodecluster.go index a0affccc1..87f5b7740 100644 --- a/node/masterserver/node/nodecluster.go +++ b/node/masterserver/node/nodecluster.go @@ -318,6 +318,7 @@ func (n *NodeCluster) loadAndWatchK8sNodes() { if node, ok := event.Object.(*v1.Node); ok { if rbnode := n.GetNode(node.Name); rbnode != nil { rbnode.NodeStatus = nil + rbnode.DeleteCondition(model.NodeReady, model.OutOfDisk, model.MemoryPressure, model.DiskPressure) n.UpdateNode(rbnode) } }