[ Agent ] [ App ] - offline fix bugs

This commit is contained in:
zeaslity
2023-12-15 14:56:34 +08:00
parent a3185f0241
commit 3312052645
4 changed files with 66 additions and 16 deletions

View File

@@ -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"

View File

@@ -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 !")

View File

@@ -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
}