[ Agent ] [ CMII ] - 新增Node部分
This commit is contained in:
@@ -92,6 +92,52 @@ func FindDeploymentNotHealthy(cmiiEnv string) (deploymentList []CmiiDeploymentIn
|
||||
|
||||
return deploymentList
|
||||
}
|
||||
func FindAllNodeNotHealthy() (nodeList []CmiiNodeInterface) {
|
||||
|
||||
// dev-cluster
|
||||
devNodeList := CmiiOperator.NodeAllInterface("dev")
|
||||
|
||||
// core-cluster
|
||||
coreNodeList := CmiiOperator.NodeAllInterface("uat")
|
||||
|
||||
// append
|
||||
coreNodeList = append(coreNodeList, devNodeList...)
|
||||
|
||||
// filter
|
||||
for _, node := range coreNodeList {
|
||||
if node.Unschedulable {
|
||||
nodeList = append(nodeList, node)
|
||||
continue
|
||||
}
|
||||
|
||||
if !node.NodeStatus {
|
||||
nodeList = append(nodeList, node)
|
||||
continue
|
||||
}
|
||||
|
||||
if node.MemoryPressure || node.PIDPressure || node.NetworkUnavailable || node.DiskPressure {
|
||||
nodeList = append(nodeList, node)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return nodeList
|
||||
}
|
||||
|
||||
func FindPodNotHealthy(cmiiEnv string) (podList []CmiiPodInterface) {
|
||||
// all unhealthy pods
|
||||
allInterface := CmiiOperator.PodAllInterface(cmiiEnv)
|
||||
|
||||
// find the deployments
|
||||
for _, podInterface := range allInterface {
|
||||
if !podInterface.PodStatus {
|
||||
// unhealthy pod
|
||||
podList = append(podList, podInterface)
|
||||
}
|
||||
}
|
||||
|
||||
return podList
|
||||
}
|
||||
|
||||
func RestartDeploymentFromList(deploymentList []CmiiDeploymentInterface) bool {
|
||||
|
||||
@@ -190,7 +236,7 @@ func UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag string) bool {
|
||||
}
|
||||
|
||||
// log
|
||||
log.InfoF("[UpdateCmiiDeploymentImageTag] - [%s] success ! real image tag are [%s] ", content, deploy.Image)
|
||||
log.InfoF("[UpdateCmiiDeploymentImageTag] - real image tag are [%s] \n update tag [%s] success ! ", deploy.Image, content)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -275,19 +321,19 @@ func BackupAllDeploymentFromEnv(cmiiEnv string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func BackupAllCmiiDeploymentToMap(cmiiEnv string) (backendMap, frontendMap map[string]int32) {
|
||||
func BackupAllCmiiDeploymentToMap(cmiiEnv string) (backendMap, frontendMap map[string]string) {
|
||||
|
||||
allInterface := CmiiOperator.DeploymentAllInterface(cmiiEnv)
|
||||
allInterface = FilterAllCmiiAppSoft(allInterface)
|
||||
|
||||
backendMap = make(map[string]int32, len(allInterface))
|
||||
frontendMap = make(map[string]int32, len(allInterface))
|
||||
backendMap = make(map[string]string, len(allInterface))
|
||||
frontendMap = make(map[string]string, len(allInterface))
|
||||
|
||||
for _, deploymentInterface := range allInterface {
|
||||
if strings.Contains(deploymentInterface.Name, "platform") {
|
||||
frontendMap[deploymentInterface.Name] = deploymentInterface.Replicas
|
||||
frontendMap[deploymentInterface.Name] = deploymentInterface.ImageTag
|
||||
} else {
|
||||
backendMap[deploymentInterface.Name] = deploymentInterface.Replicas
|
||||
backendMap[deploymentInterface.Name] = deploymentInterface.ImageTag
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,3 +394,58 @@ func FilterAllCmiiAppSoft(source []CmiiDeploymentInterface) (result []CmiiDeploy
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func FilterAllCmiiPodStrict(podList []CmiiPodInterface) (result []CmiiPodInterface) {
|
||||
for _, c := range podList {
|
||||
_, ok := CmiiBackendAppMap[c.ContainerName]
|
||||
if !ok {
|
||||
_, ok = CmiiFrontendAppMap[c.ContainerName]
|
||||
if !ok {
|
||||
log.WarnF("[FilterAllCmiiPodStrict] - [%s] not cmii pod !", c.ContainerName)
|
||||
continue
|
||||
}
|
||||
}
|
||||
result = append(result, c)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func FilterAllCmiiPodSoft(podList []CmiiPodInterface) (result []CmiiPodInterface) {
|
||||
for _, c := range podList {
|
||||
if strings.Contains(c.ContainerName, "redis") {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(c.ContainerName, "emqxs") {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(c.ContainerName, "rabbitmq") {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(c.ContainerName, "nacos") {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(c.ContainerName, "oss") {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(c.ContainerName, "minio") {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(c.ContainerName, "nfs") {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(c.ContainerName, "operator") {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(c.ContainerName, "proxy") {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(c.ContainerName, "cleanlog") {
|
||||
continue
|
||||
}
|
||||
|
||||
result = append(result, c)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user