diff --git a/agent-go/executor/AppFunction.go b/agent-go/executor/AppFunction.go index be58603..ba6b138 100644 --- a/agent-go/executor/AppFunction.go +++ b/agent-go/executor/AppFunction.go @@ -133,7 +133,11 @@ func (op *AgentOsOperator) deployRke(funcArgs []string) (bool, []string) { }, }) - // + if !BasicCreateFolder("/root/.kube") { + return false, []string{ + "[deployRke] - folder [/root/.kube] create error!", + } + } // replace ip addr parseIP := net.ParseIP(funcArgs[0]) diff --git a/agent-go/executor/BaseFunction.go b/agent-go/executor/BaseFunction.go index cf19019..50c1025 100644 --- a/agent-go/executor/BaseFunction.go +++ b/agent-go/executor/BaseFunction.go @@ -1826,5 +1826,6 @@ func (op *AgentOsOperator) ok(funcArgs []string) [][]string { } func (op *AgentOsOperator) okExec(funcArgs []string) (bool, []string) { + log.WarnF("call empty base func ! func args are => %#v", funcArgs) return true, nil } diff --git a/agent-go/executor/K8sFunction.go b/agent-go/executor/K8sFunction.go index 7a953d2..711b452 100644 --- a/agent-go/executor/K8sFunction.go +++ b/agent-go/executor/K8sFunction.go @@ -121,7 +121,7 @@ func CheckDeploymentStatusTimeout(specificDeployment string, supreme string, wai func KubectlApplyExec(resourcesYamlFile string) (bool, []string) { // check kubectl - if !BasicCommandExists("kubectl") { + if !BasicCommandExistByPath("kubectl") { return false, []string{ "[KubectlApplyExec] - kubectl command not exist !", } @@ -136,7 +136,7 @@ func KubectlApplyExec(resourcesYamlFile string) (bool, []string) { // apply -f ok, resultLog := AllCommandExecutor([]string{ - "kubectl", + "/usr/local/bin/kubectl", "apply", "-f", resourcesYamlFile, @@ -152,7 +152,7 @@ func KubectlApplyExec(resourcesYamlFile string) (bool, []string) { func KubectlDeleteExec(resourcesYamlFile string) (bool, []string) { // check kubectl - if !BasicCommandExists("kubectl") { + if !BasicCommandExistByPath("kubectl") { return false, []string{ "[KubectlDeleteExec] - kubectl command not exist !", } @@ -167,7 +167,7 @@ func KubectlDeleteExec(resourcesYamlFile string) (bool, []string) { // apply -f ok, resultLog := AllCommandExecutor([]string{ - "kubectl", + "/usr/local/bin/kubectl", "delete", "-f", resourcesYamlFile, diff --git a/server/src/main/java/io/wdd/func/auto/service/AppFuncScheduler.java b/server/src/main/java/io/wdd/func/auto/service/AppFuncScheduler.java index 86ab746..bee2162 100644 --- a/server/src/main/java/io/wdd/func/auto/service/AppFuncScheduler.java +++ b/server/src/main/java/io/wdd/func/auto/service/AppFuncScheduler.java @@ -94,8 +94,8 @@ public class AppFuncScheduler { ); List appFunctionEnumList = List.of( - AppFunctionEnum.DEPLOY_RKE -// AppFunctionEnum.DEPLOY_K8S_DASHBOARD +// AppFunctionEnum.DEPLOY_RKE + AppFunctionEnum.DEPLOY_K8S_DASHBOARD ); diff --git a/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java b/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java index 2d74ace..fa97d1c 100644 --- a/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java +++ b/server/src/main/java/io/wdd/func/auto/service/BaseFuncScheduler.java @@ -7,6 +7,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -43,12 +44,8 @@ public class BaseFuncScheduler { private void doRunProcedure(ProjectDeployContext projectDeployContext) { - // 执行 基础功能施工的内容 - String masterTopicName = projectDeployContext - .getMasterNode() - .getTopicName(); - if (!MasterNodeBaseProcedure(masterTopicName)) { + if (!MasterNodeBaseProcedure(projectDeployContext)) { log.error("Master 初始化过程错误! 即将终止!"); } @@ -83,7 +80,19 @@ public class BaseFuncScheduler { } - private boolean MasterNodeBaseProcedure(String masterTopicName) { + private boolean MasterNodeBaseProcedure(ProjectDeployContext projectDeployContext) { + + // 执行 基础功能施工的内容 + String masterTopicName = projectDeployContext + .getMasterNode() + .getTopicName(); + + // base func args + ArrayList baseFuncArgList = new ArrayList<>(); + baseFuncArgList.add(projectDeployContext + .getMasterNode() + .getServerIpInV4()); + List masterNodeProcedureList = List.of( // BaseFunctionEnum.DISABLE_SWAP, @@ -98,10 +107,17 @@ public class BaseFuncScheduler { for (BaseFunctionEnum procedure : masterNodeProcedureList) { + + // add op name + baseFuncArgList.add( + 0, + procedure.getFuncName() + ); + if (!funcService.callBaseFuncAndJudge( masterTopicName, procedure, - null, + baseFuncArgList, false )) { @@ -115,17 +131,24 @@ public class BaseFuncScheduler { } List masterNodeDurationTaskList = List.of( - BaseFunctionEnum.INSTALL_DEFAULT_SSH_KEY + BaseFunctionEnum.MODIFY_DOCKER_CONFIG // BaseFunctionEnum.INSTALL_DOCKER, // BaseFunctionEnum.INSTALL_DOCKER_COMPOSE, // BaseFunctionEnum.INSTALL_HARBOR ); for (BaseFunctionEnum durationBaseFunc : masterNodeDurationTaskList) { + + // add op name + baseFuncArgList.add( + 0, + durationBaseFunc.getFuncName() + ); + if (!funcService.callBaseFuncAndJudge( masterTopicName, durationBaseFunc, - null, + baseFuncArgList, true )) { log.error( diff --git a/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java b/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java index 5cbdae6..8662a69 100644 --- a/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java +++ b/server/src/main/java/io/wdd/func/auto/service/FuncServiceImpl.java @@ -50,14 +50,6 @@ public class FuncServiceImpl implements FuncService { "调用基本脚本 => {}", baseFunctionEnum.getDesc() ); - // 重新构造内容,增加Function Name - if (CollectionUtils.isEmpty(funcArgs)) { - funcArgs = new ArrayList<>(); - } - funcArgs.add( - 0, - baseFunctionEnum.getFuncName() - ); List syncResultLog = syncCallFunction( agentTopicName, diff --git a/server/src/test/java/io/wdd/server/func/TestBaseFuncScheduler.java b/server/src/test/java/io/wdd/server/func/TestBaseFuncScheduler.java index 22c092c..99e1e6d 100644 --- a/server/src/test/java/io/wdd/server/func/TestBaseFuncScheduler.java +++ b/server/src/test/java/io/wdd/server/func/TestBaseFuncScheduler.java @@ -53,11 +53,11 @@ public class TestBaseFuncScheduler { projectDeployContext.setMasterNode(serverInfoPO); - baseFuncScheduler.runProcedure(projectDeployContext); +// baseFuncScheduler.runProcedure(projectDeployContext); // harborFuncScheduler.runProcedure(projectDeployContext); -// appFuncScheduler.runProcedure(projectDeployContext); + appFuncScheduler.runProcedure(projectDeployContext); } }