mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[ADD] Merging three k8s metrics into kubelet
This commit is contained in:
parent
1f25c7c216
commit
a124016df0
@ -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)
|
||||
|
@ -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 ""
|
||||
}
|
Loading…
Reference in New Issue
Block a user