[ Agent ] [ init ] - add debug feature
This commit is contained in:
@@ -2,6 +2,7 @@ package executor
|
||||
|
||||
import (
|
||||
"agent-go/status"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -33,9 +34,12 @@ func BuildAgentOsOperator(ossOfflinePrefix string) *AgentOsOperator {
|
||||
}
|
||||
|
||||
func detectByAgentStatusInfo(os *AgentOsOperator) {
|
||||
agentMetric := status.ReportAgentInfo()
|
||||
agentInfo := status.ReportAgentInfo()
|
||||
|
||||
if strings.Contains(agentMetric.HostInfo.PlatformFamily, "centos") {
|
||||
bytes, _ := json.Marshal(agentInfo)
|
||||
log.DebugF("[detectByAgentStatusInfo] - agent info is => %s", string(bytes))
|
||||
|
||||
if strings.Contains(agentInfo.HostInfo.PlatformFamily, "centos") {
|
||||
// centos
|
||||
os.IsOsTypeUbuntu = false
|
||||
os.IsOsTypeCentOS = true
|
||||
@@ -46,7 +50,7 @@ func detectByAgentStatusInfo(os *AgentOsOperator) {
|
||||
"yum", "remove",
|
||||
}
|
||||
|
||||
} else if strings.Contains(agentMetric.HostInfo.PlatformFamily, "debian") {
|
||||
} else if strings.Contains(agentInfo.HostInfo.PlatformFamily, "debian") {
|
||||
// ubuntu
|
||||
os.IsOsTypeUbuntu = true
|
||||
os.IsOsTypeCentOS = false
|
||||
@@ -56,11 +60,11 @@ func detectByAgentStatusInfo(os *AgentOsOperator) {
|
||||
}
|
||||
|
||||
// os release code
|
||||
os.AgentOSReleaseCode = judgeUbuntuReleaseFromOsVersion(agentMetric.HostInfo.PlatformVersion)
|
||||
os.AgentOSReleaseCode = judgeUbuntuReleaseFromOsVersion(agentInfo.HostInfo.PlatformVersion)
|
||||
}
|
||||
|
||||
// agent cpu arch
|
||||
os.AgentArch = judgeAgentCpuArchByKernelArch(agentMetric.HostInfo.KernelArch)
|
||||
os.AgentArch = judgeAgentCpuArchByKernelArch(agentInfo.HostInfo.KernelArch)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
|
||||
|
||||
cmiiEnv := "test"
|
||||
appName := "cmii-suav-supervision"
|
||||
newTag := "5.2.0-0117"
|
||||
newTag := "5.2.0-011901"
|
||||
|
||||
tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag)
|
||||
assert.Equal(t, tag, true, "update image tag failed !")
|
||||
|
||||
@@ -89,7 +89,16 @@ func TestCmiiK8sOperator_DeploymentUpdateTag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCmiiK8sOperator_DeploymentRestart(t *testing.T) {
|
||||
CmiiOperator.DeploymentRestart("int", "cmii-uav-user")
|
||||
|
||||
cmiiEnv := "int"
|
||||
appName := "cmii-uav-gis-server"
|
||||
|
||||
CmiiOperator.DeploymentRestart(cmiiEnv, appName)
|
||||
|
||||
utils.SplitLinePrint()
|
||||
|
||||
check := CmiiOperator.DeploymentStatusCheck(cmiiEnv, appName, 180)
|
||||
assert.Equal(t, check, true, "deployment run failed!")
|
||||
}
|
||||
|
||||
func TestCmiiK8sOperator_DeploymentRestartByKill(t *testing.T) {
|
||||
|
||||
@@ -23,3 +23,4 @@
|
||||
2024-01-16-13-55-32 uavcloud-test cmii-suav-supervision 5.2.0-011602 5.2.0-011603
|
||||
2024-01-16-14-51-05 uavcloud-test cmii-suav-supervision 5.2.0-011603 5.2.0-011604
|
||||
2024-01-17-16-13-39 uavcloud-test cmii-suav-supervision 5.2.0-011604 5.2.0-0117
|
||||
2024-01-19-14-17-03 uavcloud-test cmii-suav-supervision 5.2.0-0117 5.2.0-011901
|
||||
|
||||
@@ -56,6 +56,7 @@ func ReportAgentMetric() *AgentMetric {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetCPUMetric error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetCPUMetric success !"
|
||||
})
|
||||
@@ -69,6 +70,7 @@ func ReportAgentMetric() *AgentMetric {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetMemoryMetric error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetMemoryMetric success !"
|
||||
})
|
||||
@@ -82,6 +84,7 @@ func ReportAgentMetric() *AgentMetric {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetDiskInfo error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetDiskInfo success !"
|
||||
})
|
||||
@@ -95,6 +98,7 @@ func ReportAgentMetric() *AgentMetric {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetNetworkMetric error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetNetworkMetric success !"
|
||||
})
|
||||
@@ -107,6 +111,7 @@ func ReportAgentMetric() *AgentMetric {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetDockerMetric error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetDockerMetric success !"
|
||||
})
|
||||
@@ -147,6 +152,7 @@ func ReportAgentInfo() *AgentInfo {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetCPUInfo error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetCPUInfo success !"
|
||||
})
|
||||
@@ -160,6 +166,7 @@ func ReportAgentInfo() *AgentInfo {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetMemoryInfo error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetMemoryInfo success !"
|
||||
})
|
||||
@@ -173,6 +180,7 @@ func ReportAgentInfo() *AgentInfo {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetDiskInfo error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetDiskInfo success !"
|
||||
})
|
||||
@@ -186,6 +194,7 @@ func ReportAgentInfo() *AgentInfo {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetHostInfo error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "hostInfo success !"
|
||||
})
|
||||
@@ -199,6 +208,7 @@ func ReportAgentInfo() *AgentInfo {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetNetworkInfo error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetNetworkInfo success !"
|
||||
})
|
||||
@@ -212,6 +222,7 @@ func ReportAgentInfo() *AgentInfo {
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetDockerMetric error !"
|
||||
return
|
||||
}
|
||||
waitResultChan <- "GetDockerMetric success !"
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user