diff --git a/agent-go/executor/AppFunction.go b/agent-go/executor/AppFunction.go index d088b66..de738b7 100644 --- a/agent-go/executor/AppFunction.go +++ b/agent-go/executor/AppFunction.go @@ -158,7 +158,7 @@ func (op *AgentOsOperator) deployRke(funcArgs []string) (bool, []string) { "[deployRke] - ip args error !", } } - if !BasicReplace("/root/wdd/rke-cluster.yml", "A1C2IP", funcArgs[0]) { + if !BasicReplace("/root/wdd/cluster.yml", "A1C2IP", funcArgs[0]) { log.ErrorF("[deployRke] - rke config replace error !") } @@ -347,6 +347,10 @@ func (op *AgentOsOperator) deployTestNFS(funcArgs []string) (bool, []string) { result = append(result, "命令不存在", "kubectl") return false, result } + folder, i := CheckAppInstallFolder() + if !folder { + return false, i + } // 下载模板文件 k8sNFSYamlFile := "/root/wdd/install/k8s-nfs-test.yaml" @@ -373,8 +377,9 @@ func (op *AgentOsOperator) deployTestNFS(funcArgs []string) (bool, []string) { } // 测试文件是否存在 - if !BasicFileExists(nfsDataPath + "/default-test-claim-pvc*/NFS-CREATE-SUCCESS") { - result = append(result, "NFS 文件写入 异常!!") + commandExecutor, _ := HardCodeCommandExecutor("test -f " + nfsDataPath + "/default-test-claim-pvc*/NFS-CREATE-SUCCESS") + if !commandExecutor { + log.WarnF("[deployTestNFS] - test nfs file write error !") } if !K8sCheckPodStatusTimeout("test-pod", "default", 30) { @@ -399,6 +404,10 @@ func (op *AgentOsOperator) deployPVC(funcArgs []string) (bool, []string) { result = append(result, "命令不存在", "kubectl") return false, result } + folder, i := CheckAppInstallFolder() + if !folder { + return false, i + } // 下载模板文件 k8sPvcYamlFile := "/root/wdd/install/k8s-pvc.yaml" diff --git a/agent-go/executor/BaseFunction.go b/agent-go/executor/BaseFunction.go index 4b233f5..75bdee0 100644 --- a/agent-go/executor/BaseFunction.go +++ b/agent-go/executor/BaseFunction.go @@ -1825,7 +1825,7 @@ func (op *AgentOsOperator) installChronyByDockerExec(funcArgs []string) (bool, [ "--publish=123:123/udp", "--env=NTP_SERVERS=\"ntp1.aliyun.com,ntp2.aliyun.com,ntp3.aliyun.com,ntp4.aliyun.com\"", "--env=LOG_LEVEL=0", - funcArgs[0] + ":8033/cmii/chronyd:0.4.3", + funcArgs[0] + ":8033/cmii/chronyd:0.4.3", }) if !ok { return false, append(resultLog, "[installChronyByDockerExec] - docker chrony run error !") diff --git a/agent-go/executor/K8sFunction.go b/agent-go/executor/K8sFunction.go index ae11d9c..fad63f7 100644 --- a/agent-go/executor/K8sFunction.go +++ b/agent-go/executor/K8sFunction.go @@ -47,6 +47,15 @@ func newK8sClientInstance() *kubernetes.Clientset { func K8sCheckPodStatusTimeout(specificPod string, supreme string, waitTimeOut int) bool { + if k8sClient == nil { + // this should be the first call of k8s function + k8sClient = newK8sClientInstance() + if k8sClient == nil { + log.ErrorF("k8s client is nil, run k8s function error !") + return false + } + } + // 设置超时时间和时间间隔 timeout := time.After(time.Duration(waitTimeOut) * time.Second) tick := time.Tick(5 * time.Second) @@ -73,6 +82,15 @@ func K8sCheckPodStatusTimeout(specificPod string, supreme string, waitTimeOut in func K8sCheckDeploymentStatusTimeout(specificDeployment string, supreme string, waitTimeOut int) bool { + if k8sClient == nil { + // this should be the first call of k8s function + k8sClient = newK8sClientInstance() + if k8sClient == nil { + log.ErrorF("k8s client is nil, run k8s function error !") + return false + } + } + // 设置超时时间和时间间隔 timeout := time.After(time.Duration(waitTimeOut) * time.Second) tick := time.Tick(5 * time.Second) @@ -102,8 +120,14 @@ func K8sCheckDeploymentStatusTimeout(specificDeployment string, supreme string, func K8sListPVCInNamespace(supreme string) (bool, []string) { if k8sClient == nil { - log.ErrorF("k8s client is nil, run k8s function error !") - return false, nil + // this should be the first call of k8s function + k8sClient = newK8sClientInstance() + if k8sClient == nil { + log.ErrorF("k8s client is nil, run k8s function error !") + return false, []string{ + "[K8sListPVCInNamespace] - k8s client not exits !", + } + } } pvcs, err := k8sClient.CoreV1().PersistentVolumeClaims(supreme).List(context.TODO(), metav1.ListOptions{}) @@ -124,8 +148,12 @@ func K8sListPVCInNamespace(supreme string) (bool, []string) { func K8sCheckPVCStatusTimeOut(specificPvcName string, supreme string, waitTimeOut int) bool { if k8sClient == nil { - log.ErrorF("k8s client is nil, run k8s function error !") - return false + // this should be the first call of k8s function + k8sClient = newK8sClientInstance() + if k8sClient == nil { + log.ErrorF("k8s client is nil, run k8s function error !") + return false + } } // 设置超时时间和时间间隔 @@ -287,7 +315,16 @@ func K8sCreateNamespace(namespaceName string) bool { return true } -func K8sGetDashBoardAuthKey() { +func K8sGetDashBoardAuthKey() bool { + + if k8sClient == nil { + // this should be the first call of k8s function + k8sClient = newK8sClientInstance() + if k8sClient == nil { + log.ErrorF("k8s client is nil, run k8s function error !") + return false + } + } // 获取 kube-system 命名空间的 secrets 列表 secrets, err := k8sClient.CoreV1().Secrets("kube-system").List(context.TODO(), metav1.ListOptions{}) @@ -323,4 +360,6 @@ func K8sGetDashBoardAuthKey() { fmt.Printf("%s: %s\n", key, value) } + return false + } 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 32d51eb..99302b6 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 @@ -100,14 +100,16 @@ public class AppFuncScheduler { ); List appFunctionEnumList = List.of( - AppFunctionEnum.DEPLOY_CHRONY_SERVER +// AppFunctionEnum.DEPLOY_CHRONY_SERVER, // AppFunctionEnum.DEPLOY_RKE -// AppFunctionEnum.DEPLOY_TEST_NFS -// AppFunctionEnum.DEPLOY_K8S_NAMESPACE, -// AppFunctionEnum.DEPLOY_K8S_MYSQL -// AppFunctionEnum.DEPLOY_K8S_REDIS -// AppFunctionEnum.DEPLOY_K8S_PVC -// AppFunctionEnum.DEPLOY_INGRESS, + AppFunctionEnum.DEPLOY_K8S_DASHBOARD, + AppFunctionEnum.DEPLOY_NFS, + AppFunctionEnum.DEPLOY_TEST_NFS, + AppFunctionEnum.DEPLOY_K8S_NAMESPACE, + AppFunctionEnum.DEPLOY_K8S_MYSQL, + AppFunctionEnum.DEPLOY_K8S_REDIS, + AppFunctionEnum.DEPLOY_K8S_PVC, + AppFunctionEnum.DEPLOY_INGRESS // AppFunctionEnum.DEPLOY_FRONTEND // AppFunctionEnum.DEPLOY_BACKEND // AppFunctionEnum.DEPLOY_K8S_SRS