[agent-go] - 启动时候名称的选择
This commit is contained in:
@@ -247,10 +247,6 @@ func buildOctopusTCPConnect(agentConfig *viper.Viper) *rabbitmq.RabbitTCPConnect
|
|||||||
|
|
||||||
func refreshAgentInfoByStatusInfo(agentInfo *a_status.AgentInfo, agentServerInfo *a_agent.AgentServerInfo) {
|
func refreshAgentInfoByStatusInfo(agentInfo *a_status.AgentInfo, agentServerInfo *a_agent.AgentServerInfo) {
|
||||||
|
|
||||||
// host info
|
|
||||||
agentServerInfo.ServerName = agentInfo.HostInfo.Hostname
|
|
||||||
agentServerInfo.MachineID = agentInfo.HostInfo.HostID
|
|
||||||
|
|
||||||
// cpu part
|
// cpu part
|
||||||
agentServerInfo.CPUCore = strconv.FormatInt(int64(agentInfo.CPUInfo.NumCores), 10)
|
agentServerInfo.CPUCore = strconv.FormatInt(int64(agentInfo.CPUInfo.NumCores), 10)
|
||||||
if len(agentInfo.CPUInfo.CPUInfo) > 0 {
|
if len(agentInfo.CPUInfo.CPUInfo) > 0 {
|
||||||
@@ -289,9 +285,88 @@ func refreshAgentInfoByStatusInfo(agentInfo *a_status.AgentInfo, agentServerInfo
|
|||||||
// network part
|
// network part
|
||||||
refreshAgentNetworkInfo(agentInfo, agentServerInfo)
|
refreshAgentNetworkInfo(agentInfo, agentServerInfo)
|
||||||
|
|
||||||
|
// host info
|
||||||
|
agentServerInfo.ServerName = uniformAgentServerName(agentInfo, agentServerInfo)
|
||||||
|
agentServerInfo.MachineID = agentInfo.HostInfo.HostID
|
||||||
|
|
||||||
log.DebugF("[refreshAgentInfoByStatusInfo] - ok !")
|
log.DebugF("[refreshAgentInfoByStatusInfo] - ok !")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func uniformAgentServerName(agentInfo *a_status.AgentInfo, agentServerInfo *a_agent.AgentServerInfo) string {
|
||||||
|
|
||||||
|
hostname := agentInfo.HostInfo.Hostname
|
||||||
|
// Shanghai-amd64-01
|
||||||
|
if strings.Count(hostname, "-") == 2 {
|
||||||
|
split := strings.Split(hostname, "-")
|
||||||
|
if split[1] == getMachineType(agentInfo.HostInfo.KernelArch) {
|
||||||
|
// 第二位是 amd64 arm64
|
||||||
|
return hostname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不是标准的AgentName格式
|
||||||
|
city := agentServerInfo.City
|
||||||
|
city = strings.Title(city)
|
||||||
|
if strings.Contains(city, " ") {
|
||||||
|
city = strings.Join(strings.Split(city, " "), "")
|
||||||
|
}
|
||||||
|
arch := getMachineType(agentInfo.HostInfo.KernelArch)
|
||||||
|
|
||||||
|
var numS string
|
||||||
|
if agentServerInfo.ServerIPInV4 != "" {
|
||||||
|
split := strings.Split(agentServerInfo.ServerIPInV4, ".")
|
||||||
|
numS = fmt.Sprintf("%03d", split[3])
|
||||||
|
} else {
|
||||||
|
// Seed the random number generator
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
|
// Generate a random number between 1 and 999
|
||||||
|
num := rand.Intn(999) + 1
|
||||||
|
|
||||||
|
// Format the number as a string with leading zeros
|
||||||
|
numS = fmt.Sprintf("%03d", num)
|
||||||
|
}
|
||||||
|
|
||||||
|
return city + "-" + arch + "-" + numS
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMachineType(arch string) string {
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case strings.HasSuffix(arch, "386") || arch == "i386":
|
||||||
|
return "ia32"
|
||||||
|
case strings.HasSuffix(arch, "amd64") || arch == "x86_64":
|
||||||
|
return "amd64"
|
||||||
|
case arch == "armv5tel":
|
||||||
|
return "arm32"
|
||||||
|
case arch == "armv6l":
|
||||||
|
return "arm32"
|
||||||
|
case arch == "armv7" || arch == "armv7l":
|
||||||
|
return "arm32"
|
||||||
|
case arch == "armv8" || arch == "aarch64":
|
||||||
|
return "arm64"
|
||||||
|
case arch == "mips":
|
||||||
|
return "mips32"
|
||||||
|
case arch == "mipsle":
|
||||||
|
return "mips32le"
|
||||||
|
case arch == "mips64":
|
||||||
|
return "mips64"
|
||||||
|
case arch == "mips64le":
|
||||||
|
return "mips64le"
|
||||||
|
case arch == "ppc64":
|
||||||
|
return "ppc64"
|
||||||
|
case arch == "ppc64le":
|
||||||
|
return "ppc64le"
|
||||||
|
case arch == "riscv64":
|
||||||
|
return "riscv64"
|
||||||
|
case arch == "s390x":
|
||||||
|
return "s390x"
|
||||||
|
default:
|
||||||
|
fmt.Println("error: The architecture is not supported.")
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func refreshAgentNetworkInfo(agentInfo *a_status.AgentInfo, agentServerInfo *a_agent.AgentServerInfo) {
|
func refreshAgentNetworkInfo(agentInfo *a_status.AgentInfo, agentServerInfo *a_agent.AgentServerInfo) {
|
||||||
|
|
||||||
// 获取Agent的公网服务信息
|
// 获取Agent的公网服务信息
|
||||||
|
|||||||
@@ -443,6 +443,8 @@ func (op *CmiiK8sOperator) DeploymentUpdateTag(cmiiEnv, appName, newTag string)
|
|||||||
// 更新Cmii BIZ_GROUP
|
// 更新Cmii BIZ_GROUP
|
||||||
tagVersion := newTag
|
tagVersion := newTag
|
||||||
if strings.Contains(newTag, "-") {
|
if strings.Contains(newTag, "-") {
|
||||||
|
// 5.0.0-1243
|
||||||
|
// 5.0.0-1243-1234
|
||||||
tagVersion = strings.Split(newTag, "-")[0]
|
tagVersion = strings.Split(newTag, "-")[0]
|
||||||
}
|
}
|
||||||
envList := container.Env
|
envList := container.Env
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ public class ImageFuncScheduler {
|
|||||||
log.info("Image Sync Half Complete ! Gzip file name => {}", gzipFileName);
|
log.info("Image Sync Half Complete ! Gzip file name => {}", gzipFileName);
|
||||||
if (imageSyncContext.getDownloadAndCompressOnly()) {
|
if (imageSyncContext.getDownloadAndCompressOnly()) {
|
||||||
log.info("Image Sync download only !");
|
log.info("Image Sync download only !");
|
||||||
|
imageSyncMessage.setCurrentProcedure(FINISHED.getFuncName());
|
||||||
|
imageSyncMessage.setIsSyncFinished(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class TestImageSyncScheduler {
|
|||||||
ArrayList<String> ImageFullNameList = new ArrayList<>(List.of(
|
ArrayList<String> ImageFullNameList = new ArrayList<>(List.of(
|
||||||
// "harbor.cdcyy.com.cn/cmii/cmii-live-operator:5.2.0",
|
// "harbor.cdcyy.com.cn/cmii/cmii-live-operator:5.2.0",
|
||||||
// "harbor.cdcyy.com.cn/cmii/cmii/srs:v5.0.195"
|
// "harbor.cdcyy.com.cn/cmii/cmii/srs:v5.0.195"
|
||||||
"harbor.cdcyy.com.cn/cmii/cmii-uav-mission:5.3.0-cqly-042901"
|
"harbor.cdcyy.com.cn/cmii/cmii-uav-platform:5.3.0-cqly-042901"
|
||||||
));
|
));
|
||||||
|
|
||||||
Boolean downloadAndCompressOnly = false;
|
Boolean downloadAndCompressOnly = false;
|
||||||
@@ -102,7 +102,7 @@ public class TestImageSyncScheduler {
|
|||||||
));
|
));
|
||||||
|
|
||||||
ArrayList<String> ImageFullNameList = new ArrayList<>(List.of(
|
ArrayList<String> ImageFullNameList = new ArrayList<>(List.of(
|
||||||
"harbor.cdcyy.com.cn/cmii/cmii-uav-industrial-portfolio:5.4.0-cqly-042801"
|
"harbor.cdcyy.com.cn/cmii/cmii-uav-platform:5.3.0-cqly-042901"
|
||||||
));
|
));
|
||||||
|
|
||||||
Boolean downloadAndCompressOnly = true;
|
Boolean downloadAndCompressOnly = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user