diff --git a/.run/TestUpdateCmiiDeploymentImageTag in wdd.io_agent-operator.run.xml b/.run/TestUpdateCmiiDeploymentImageTag in wdd.io_agent-operator.run.xml new file mode 100644 index 0000000..e5c8b83 --- /dev/null +++ b/.run/TestUpdateCmiiDeploymentImageTag in wdd.io_agent-operator.run.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/agent-go/executor/CommandExecutor.go b/agent-go/executor/CommandExecutor.go index ccb0310..af28461 100644 --- a/agent-go/executor/CommandExecutor.go +++ b/agent-go/executor/CommandExecutor.go @@ -51,6 +51,7 @@ func Execute(em *ExecutionMessage) (bool, []string) { } } else if strings.HasPrefix(em.ExecutionType, "HARBOR") { + // harbor function if em.FuncContent == nil || len(em.FuncContent) <= 1 { ok = false resultLog = []string{ @@ -61,6 +62,7 @@ func Execute(em *ExecutionMessage) (bool, []string) { ok, resultLog = HarborOperatorCache.Exec(em.FuncContent[0], em.FuncContent[1:]...) } else { + // deprecated // shell command if em.PipeLineCommand != nil && len(em.PipeLineCommand) != 0 { // 管道命令 diff --git a/agent-operator/CmiiK8sOperator.go b/agent-operator/CmiiK8sOperator.go index c466c2e..1547538 100644 --- a/agent-operator/CmiiK8sOperator.go +++ b/agent-operator/CmiiK8sOperator.go @@ -395,7 +395,8 @@ func BackupAllDeploymentFromEnv(cmiiEnv string) bool { // must filter allInterface = FilterAllCmiiAppSoft(allInterface) - filePath := "C:\\Users\\wddsh\\Documents\\IdeaProjects\\ProjectOctopus\\cmii_operator\\log\\all-" + CmiiOperator.CurrentNamespace + "-" + utils.TimeSplitFormatString() + ".txt" + //filePath := "C:\\Users\\wddsh\\Documents\\IdeaProjects\\ProjectOctopus\\cmii_operator\\log\\all-" + CmiiOperator.CurrentNamespace + "-" + utils.TimeSplitFormatString() + ".txt" + filePath := "/home/wdd/IdeaProjects/ProjectOctopus/agent-operator/log/all-" + CmiiOperator.CurrentNamespace + "-" + utils.TimeSplitFormatString() + ".txt" log.InfoF("[BackupAllDeploymentFromEnv] - backup all image from %s => %s", CmiiOperator.CurrentNamespace, filePath) @@ -493,7 +494,8 @@ func BackupAllCmiiDeploymentToMap(cmiiEnv string) (backendMap, frontendMap, srsM func BackUpAllCmiiAppImageNameFromEnv(cmiiEnv string) { CmiiOperator.changeOperatorEnv(cmiiEnv) - filePath := "C:\\Users\\wddsh\\Documents\\IdeaProjects\\ProjectOctopus\\cmii_operator\\log\\images-" + CmiiOperator.CurrentNamespace + "-" + utils.TimeSplitFormatString() + ".txt" + //filePath := "C:\\Users\\wddsh\\Documents\\IdeaProjects\\ProjectOctopus\\cmii_operator\\log\\images-" + CmiiOperator.CurrentNamespace + "-" + utils.TimeSplitFormatString() + ".txt" + filePath := "/home/wdd/IdeaProjects/ProjectOctopus/agent-operator/log/images-" + CmiiOperator.CurrentNamespace + "-" + utils.TimeSplitFormatString() + ".txt" only := make(map[string]string, 150) // front diff --git a/agent-operator/CmiiK8sOperator_test.go b/agent-operator/CmiiK8sOperator_test.go index db71a8c..cd5b366 100644 --- a/agent-operator/CmiiK8sOperator_test.go +++ b/agent-operator/CmiiK8sOperator_test.go @@ -211,28 +211,28 @@ func TestUpdateCmiiImageTagFromNameTagMap(t *testing.T) { } func TestScaleCmiiFrontendDeploymentToDesiredReplicas(t *testing.T) { - ScaleCmiiFrontendDeploymentToDesiredReplicas(dev, 0) + ScaleCmiiFrontendDeploymentToDesiredReplicas(uat, 0) } func TestScaleCmiiBackendDeploymentToDesiredReplicas(t *testing.T) { - ScaleCmiiBackendDeploymentToDesiredReplicas(dev, 0) + ScaleCmiiBackendDeploymentToDesiredReplicas(uat, 0) } func TestBackupAllDeploymentFromEnv(t *testing.T) { - BackupAllDeploymentFromEnv(demo) + BackupAllDeploymentFromEnv(integration) } func TestBackUpAllCmiiAppImageNameFromEnv(t *testing.T) { - BackUpAllCmiiAppImageNameFromEnv(demo) + BackUpAllCmiiAppImageNameFromEnv(integration) } func TestRestartCmiiDeployment(t *testing.T) { cmiiEnv := integration - appName := "cmii-uav-device" + appName := "cmii-uav-platform" kill := CmiiOperator.DeploymentRestartByKill(cmiiEnv, appName) assert.Equal(t, kill, true, "have unhealthy pod !") @@ -244,8 +244,8 @@ func TestRestartCmiiDeployment(t *testing.T) { func TestUpdateCmiiDeploymentImageTag(t *testing.T) { cmiiEnv := demo - appName := "cmii-uav-platform" - newTag := "5.4.0-031901" + appName := "cmii-uav-process" + newTag := "5.4.0-032201" tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag) assert.Equal(t, tag, true, "update image tag failed !") diff --git a/agent-operator/CmiiOperator.go b/agent-operator/CmiiOperator.go index 0f3a876..a201ae4 100644 --- a/agent-operator/CmiiOperator.go +++ b/agent-operator/CmiiOperator.go @@ -19,7 +19,7 @@ const DirectPushDeployHarborHost = "36.134.71.138" type ImageSyncEntity struct { ProjectName string ProjectVersion string - DirectHarborHost string + DirectHarborHost string //此参数决定是否能够直连目标主机,如果有则代表直连,可以直接推送景象 PushToDemoMinio bool } @@ -32,6 +32,7 @@ type ImageSyncResult struct { AllCmiiImageNameList []string } +// PullFromEntityAndSyncConditionally 根据ImageSyncEntity拉取特定的镜像,然后上传到特定的目标机器 func (sync ImageSyncEntity) PullFromEntityAndSyncConditionally() (imageSyncResult ImageSyncResult) { var realCmiiImageList []string diff --git a/agent-operator/K8sOperator_test.go b/agent-operator/K8sOperator_test.go index e3268c0..dee84e3 100644 --- a/agent-operator/K8sOperator_test.go +++ b/agent-operator/K8sOperator_test.go @@ -75,7 +75,7 @@ func TestCmiiK8sOperator_DeploymentFizz(t *testing.T) { func TestCmiiK8sOperator_DeploymentScale(t *testing.T) { start := time.Now() - CmiiOperator.DeploymentScale("devflight", "cmii-uav-depotautoreturn", 0) + CmiiOperator.DeploymentScale(demo, "cmii-uav-industrial-portfolio", 1) elapsed := time.Since(start).Milliseconds() fmt.Printf("执行耗时: %d ms\n", elapsed) @@ -91,7 +91,7 @@ func TestCmiiK8sOperator_DeploymentUpdateTag(t *testing.T) { func TestCmiiK8sOperator_DeploymentRestart(t *testing.T) { - cmiiEnv := "int" + cmiiEnv := "demo" appName := "cmii-uav-gis-server" CmiiOperator.DeploymentRestart(cmiiEnv, appName) diff --git a/agent-operator/image/CmiiImageSync_test.go b/agent-operator/image/CmiiImageSync_test.go index 6fab820..39ffd10 100644 --- a/agent-operator/image/CmiiImageSync_test.go +++ b/agent-operator/image/CmiiImageSync_test.go @@ -185,6 +185,8 @@ func TestSaveSpecificImageToGzipFile(t *testing.T) { } // image pull success + log.InfoF("image should have pulled successful ! => %s", imageFullName) + if !SaveToTarGZ(imageFullName, imageGzipFilePathPrefix) { log.ErrorF("image save to gzip file error ! => %s", imageFullName) return diff --git a/agent-operator/main.go b/agent-operator/main.go index b84903e..fc6a42a 100644 --- a/agent-operator/main.go +++ b/agent-operator/main.go @@ -15,7 +15,7 @@ func main() { // build from local LocalKubeConfigFile if !utils.FileExists(LocalKubeConfigFile) { - log.ErrorF("%s not exits! error!") + log.ErrorF("%s not exits! error!", LocalKubeConfigFile) return } diff --git a/cmii_operator/log/cmii-update-log.txt b/cmii_operator/log/cmii-update-log.txt new file mode 100644 index 0000000..1517543 --- /dev/null +++ b/cmii_operator/log/cmii-update-log.txt @@ -0,0 +1,17 @@ +2024-03-20-11-53-54 uavcloud-test cmii-uav-platform 5.4.0-staging 5.4.0-032001 +2024-03-20-11-55-04 uavcloud-test cmii-uav-device 5.5.0-integration 5.4.0-032001 +2024-03-20-11-56-42 uavcloud-test cmii-uav-surveillance 5.4.0-staging 5.4.0-032001 +2024-03-20-11-57-50 uavcloud-test cmii-uav-mission 5.4.0-staging 5.4.0-032001 +2024-03-20-13-47-06 uavcloud-demo cmii-uav-platform 5.4.0-031901 5.4.0-25263-ai-032001 +2024-03-20-14-18-39 uavcloud-test cmii-uav-platform 5.4.0-032001 5.4.0-032002 +2024-03-20-17-20-29 uavcloud-demo cmii-uav-industrial-portfolio 5.4.0-27348-032001 5.4.0-26714-032001 +2024-03-20-17-35-34 uavcloud-demo cmii-uav-platform 5.4.0-25263-ai-032001 5.4.0-26807-25263-emerg-ai-0320 +2024-03-20-17-46-10 uavcloud-demo cmii-uav-platform 5.4.0-26807-25263-emerg-ai-03205.4.0-26807-25263-emerg-ai-032002 +2024-03-21-10-00-49 uavcloud-demo cmii-uav-industrial-portfolio 5.4.0-27348-032001 5.4.0-27348-032101 +2024-03-21-14-32-38 uavcloud-demo cmii-uav-device 5.4.0-25916 5.4.0-0321 +2024-03-21-14-36-48 uavcloud-demo cmii-uav-alarm 5.4.0 5.4.0-0321 +2024-03-21-17-47-31 uavcloud-demo cmii-uav-industrial-portfolio 5.4.0-27348-032101 5.4.0-27348-0321 +2024-03-22-09-17-06 uavcloud-demo cmii-uav-industrial-portfolio 5.4.0-27348-0321 5.4.0-032201 +2024-03-22-14-02-05 uavcloud-demo cmii-uav-platform 5.4.0-25263-032011 5.4.0-25263-emerg-ai-032201 +2024-03-22-17-14-43 uavcloud-demo cmii-uav-platform-armypeople 5.4.0 5.4.0-26860-032201 +2024-03-22-17-17-15 uavcloud-demo cmii-uav-process 5.4.0 5.4.0-032201