diff --git a/node/core/service/node_service.go b/node/core/service/node_service.go index 26828bc8b..d968beef3 100644 --- a/node/core/service/node_service.go +++ b/node/core/service/node_service.go @@ -38,15 +38,15 @@ import ( ) const ( - Running = "running" - Offline = "offline" - Unknown = "unknown" - Error = "error" - Init = "init" + Running = "running" + Offline = "offline" + Unknown = "unknown" + Error = "error" + Init = "init" InstallSuccess = "install_success" InstallFailed = "install_failed" - Installing = "installing" - NotInstalled = "not_installed" + Installing = "installing" + NotInstalled = "not_installed" ) //NodeService node service @@ -159,7 +159,7 @@ func (n *NodeService) DeleteNode(nodeID string) *utils.APIHandleError { return utils.CreateAPIHandleError(400, fmt.Errorf("node is online, can not delete")) } // TODO:compute node check node is offline - if node.Status != Offline && node.Status != NotInstalled && node.Status != InstallFailed && node.Status != InstallSuccess { + if node.Status != Offline && node.Status != Unknown && node.Status != NotInstalled && node.Status != InstallFailed && node.Status != InstallSuccess && node.Status != Installing { return utils.CreateAPIHandleError(401, fmt.Errorf("node is not offline")) } n.nodecluster.RemoveNode(node.ID) diff --git a/node/masterserver/node/cluster.go b/node/masterserver/node/cluster.go index 1d6516585..064f00e56 100644 --- a/node/masterserver/node/cluster.go +++ b/node/masterserver/node/cluster.go @@ -297,9 +297,25 @@ func (n *Cluster) handleNodeStatus(v *client.HostNode) { v.UpdataCondition(r) return } - //var haveready bool for _, condiction := range v.NodeStatus.Conditions { + + if condiction.Type == "OutOfDisk" || condiction.Type == "MemoryPressure" || condiction.Type == "DiskPressure"{ + if condiction.Status == "False"{ + v.DeleteCondition(condiction.Type) + }else { + message := n.getKubeletMessage(v) + r := client.NodeCondition{ + Type: "kubelet", + Status: client.ConditionFalse, + LastHeartbeatTime: time.Now(), + LastTransitionTime: time.Now(), + Message:message + "/" + condiction.Message, + } + v.UpdataCondition(r) + } + } + if (condiction.Status == "True" || condiction.Status == "Unknown") && (condiction.Type == "OutOfDisk" || condiction.Type == "MemoryPressure" || condiction.Type == "DiskPressure") { v.Status = status v.NodeStatus.Status = status @@ -696,3 +712,13 @@ func (n *Cluster) handleNodeHealth(v *client.HostNode) { } } } + +func (n *Cluster) getKubeletMessage(v *client.HostNode) string{ + + for _, condiction := range v.NodeStatus.Conditions { + if condiction.Type == "kubelet"{ + return condiction.Message + } + } + return "" +} \ No newline at end of file