[agent-go] - bug fixs

This commit is contained in:
zeaslity
2024-05-08 11:13:45 +08:00
parent e56b9bd65c
commit c8e5184aaa
8 changed files with 45 additions and 15 deletions

View File

@@ -55,6 +55,9 @@ func (op *AgentOsOperator) Exec(baseFuncName string, funcArgs ...string) (bool,
case "shutdownFirewall": case "shutdownFirewall":
resultOk, errorLog = op.shutdownFirewallExec() resultOk, errorLog = op.shutdownFirewallExec()
break break
case "MODIFY_SYSCONFIG":
resultOk, errorLog = op.modifySystemConfigExec()
break
case "modifyHostname": case "modifyHostname":
resultOk, errorLog = op.modifyHostnameExec(funcArgs) resultOk, errorLog = op.modifyHostnameExec(funcArgs)
break break

View File

@@ -322,9 +322,18 @@ func uniformAgentServerName(agentInfo *a_status.AgentInfo, agentServerInfo *a_ag
var numS string var numS string
if agentServerInfo.ServerIPInV4 != "" { if agentServerInfo.ServerIPInV4 != "" {
// 使用IP最为Agent的序号代码
split := strings.Split(agentServerInfo.ServerIPInV4, ".") split := strings.Split(agentServerInfo.ServerIPInV4, ".")
numS = split[3] numS = split[3]
// 归一化长度为 003 123 234
parseInt, err := strconv.ParseInt(numS, 10, 64)
if err != nil {
log.WarnF("parse server ip to int error ! => %v", err)
}
numS = fmt.Sprintf("%03d", parseInt)
} else { } else {
// 没有IP信息随机生成一个
// Seed the random number generator // Seed the random number generator
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())

View File

@@ -16,6 +16,10 @@ public enum BaseFunctionEnum {
"关闭虚拟内存" "关闭虚拟内存"
), ),
MODIFY_SYSCONFIG(
"MODIFY_SYSCONFIG",
"修改系统配置"
),
DISABLE_SELINUX( DISABLE_SELINUX(
"DISABLE_SELINUX", "DISABLE_SELINUX",

View File

@@ -157,6 +157,9 @@ public class BaseFuncScheduler {
agentTopicName, agentTopicName,
durationBaseFunc durationBaseFunc
); );
// remove
baseFuncArgList.remove(0);
return false; return false;
} }

View File

@@ -97,6 +97,11 @@ mybatis-plus:
# mapper-locations: classpath*:/real-mappers/**/*.xml # mapper-locations: classpath*:/real-mappers/**/*.xml
octopus: octopus:
notify:
# 消息通知的URL地址
pusher_url: http://192.168.35.71:8080
# 发送消息的密钥 不需要使用
access_token: tk_zvdb67fwj1hrjivkq3ga9z7u63av5
message: message:
# agent boot up default common exchange # agent boot up default common exchange
init_exchange: InitExchange init_exchange: InitExchange

View File

@@ -9,7 +9,7 @@ spring:
allow-circular-references: true allow-circular-references: true
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
rabbitmq: rabbitmq:
host: 10.250.0.100 host: 42.192.52.227
port: 20672 port: 20672
username: boge username: boge
password: boge8tingH password: boge8tingH
@@ -24,7 +24,7 @@ spring:
max-interval: 65000 max-interval: 65000
initial-interval: 2000 initial-interval: 2000
redis: redis:
host: 10.250.0.100 host: 42.192.52.227
port: 21370 port: 21370
database: 0 database: 0
password: boge8tingH password: boge8tingH
@@ -46,7 +46,7 @@ spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.250.0.100:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8 url: jdbc:mysql://42.192.52.227:21306/octopus_server?autoReconnect=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8
username: boge username: boge
password: boge8tingH password: boge8tingH
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource

View File

@@ -50,7 +50,8 @@ public class TestBaseFuncScheduler {
// Long projectServerId = 1764575895186030593L;// 上海雷视联动 // Long projectServerId = 1764575895186030593L;// 上海雷视联动
// Long projectServerId = 1777152043483353089L;// 吉林移动 // Long projectServerId = 1777152043483353089L;// 吉林移动
// Long projectServerId = 1765654823726669826L;// 资阳公安 // Long projectServerId = 1765654823726669826L;// 资阳公安
Long projectServerId = 1778681124701483009L;// 北京通感 // Long projectServerId = 1778681124701483009L;// 北京通感
Long projectServerId = 1788026824445317122L;// 新疆移动
// Long projectServerId = 1773619219367120898L; // 内网35-71项目 // Long projectServerId = 1773619219367120898L; // 内网35-71项目
@@ -60,7 +61,8 @@ public class TestBaseFuncScheduler {
// String masterNodeServerName = "Shanghai-amd64-09"; // cgga // String masterNodeServerName = "Shanghai-amd64-09"; // cgga
// String masterNodeServerName = "Chengdu-amd64-51"; // 吉林移动 // String masterNodeServerName = "Chengdu-amd64-51"; // 吉林移动
// String masterNodeServerName = "Chengdu-amd64-51"; // 吉林移动 // String masterNodeServerName = "Chengdu-amd64-51"; // 吉林移动
String masterNodeServerName = "Chengdu-amd64-10"; // 北京通感 // String masterNodeServerName = "Chengdu-amd64-10"; // 北京通感
String masterNodeServerName = "Chengdu-amd64-14"; // 新疆移动
// String masterNodeServerName = "Ziyang-amd64-61"; // 资阳公安 // String masterNodeServerName = "Ziyang-amd64-61"; // 资阳公安
ProjectServerVO projectServerVO = coreProjectServerService.projectServerOne(projectServerId); ProjectServerVO projectServerVO = coreProjectServerService.projectServerOne(projectServerId);
@@ -81,12 +83,14 @@ public class TestBaseFuncScheduler {
List<BaseFunctionEnum> masterNodeProcedure = List.of( List<BaseFunctionEnum> masterNodeProcedure = List.of(
BaseFunctionEnum.DISABLE_SWAP, // BaseFunctionEnum.DISABLE_SWAP,
BaseFunctionEnum.DISABLE_SELINUX, // BaseFunctionEnum.DISABLE_SELINUX,
BaseFunctionEnum.SHUTDOWN_FIREWALL, // BaseFunctionEnum.MODIFY_SYSCONFIG,
BaseFunctionEnum.INSTALL_DOCKER, // BaseFunctionEnum.SHUTDOWN_FIREWALL,
BaseFunctionEnum.INSTALL_DEFAULT_SSH_KEY, // BaseFunctionEnum.INSTALL_DOCKER,
BaseFunctionEnum.INSTALL_DOCKER_COMPOSE, // BaseFunctionEnum.INSTALL_DEFAULT_SSH_KEY,
// BaseFunctionEnum.INSTALL_DOCKER_COMPOSE,
// BaseFunctionEnum.INSTALL_NFS_SERVER_ONLINE,
BaseFunctionEnum.MODIFY_DOCKER_CONFIG, BaseFunctionEnum.MODIFY_DOCKER_CONFIG,
BaseFunctionEnum.INSTALL_HARBOR BaseFunctionEnum.INSTALL_HARBOR
); );
@@ -94,10 +98,12 @@ public class TestBaseFuncScheduler {
List<BaseFunctionEnum> agentNodeProcedure = List.of( List<BaseFunctionEnum> agentNodeProcedure = List.of(
BaseFunctionEnum.DISABLE_SWAP, BaseFunctionEnum.DISABLE_SWAP,
BaseFunctionEnum.INSTALL_DEFAULT_SSH_KEY, BaseFunctionEnum.INSTALL_DEFAULT_SSH_KEY,
BaseFunctionEnum.MODIFY_SYSCONFIG,
BaseFunctionEnum.DISABLE_SELINUX, BaseFunctionEnum.DISABLE_SELINUX,
BaseFunctionEnum.SHUTDOWN_FIREWALL, BaseFunctionEnum.SHUTDOWN_FIREWALL,
BaseFunctionEnum.INSTALL_DOCKER, BaseFunctionEnum.INSTALL_DOCKER,
BaseFunctionEnum.INSTALL_DOCKER_COMPOSE, BaseFunctionEnum.INSTALL_DOCKER_COMPOSE,
BaseFunctionEnum.INSTALL_NFS_ONLINE,
BaseFunctionEnum.MODIFY_DOCKER_CONFIG BaseFunctionEnum.MODIFY_DOCKER_CONFIG
); );
@@ -116,7 +122,7 @@ public class TestBaseFuncScheduler {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
// baseFuncScheduler.runProcedure(projectDeployContext); baseFuncScheduler.runProcedure(projectDeployContext);
// 只能支持 带端口的HarborHost 默认为8033 // 只能支持 带端口的HarborHost 默认为8033
// harborFuncScheduler.runProcedure(projectDeployContext); // harborFuncScheduler.runProcedure(projectDeployContext);
@@ -144,7 +150,7 @@ public class TestBaseFuncScheduler {
); );
projectDeployContext.setMasterAppProcedure(appFunctionEnumList); projectDeployContext.setMasterAppProcedure(appFunctionEnumList);
appFuncScheduler.runProcedure(projectDeployContext); // appFuncScheduler.runProcedure(projectDeployContext);
masterNodeProcedure = List.of(BaseFunctionEnum.CHRONY_TO_MASTER); masterNodeProcedure = List.of(BaseFunctionEnum.CHRONY_TO_MASTER);

View File

@@ -38,13 +38,13 @@ public class TestImageSyncScheduler {
public void runImageSync() { public void runImageSync() {
ArrayList<String> CmiiAppNameList = new ArrayList<>(List.of( ArrayList<String> CmiiAppNameList = new ArrayList<>(List.of(
// "cmii-uav-process:5.4.0-041901"1 // "cmii-uav-process:5.3.0-050601"
)); ));
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-platform:5.3.0-cqly-042902" "harbor.cdcyy.com.cn/cmii/cmii-uav-platform:5.3.0-cqly-050702"
)); ));
Boolean downloadAndCompressOnly = false; Boolean downloadAndCompressOnly = false;