[Cmii][ImageSync] - 优化处理逻辑
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="TestUpdateCmiiDeploymentImageTag in wdd.io/agent-operator"
|
||||||
|
type="GoTestRunConfiguration" factoryName="Go Test" singleton="false" nameIsGenerated="true">
|
||||||
|
<module name="ProjectOctopus"/>
|
||||||
|
<working_directory value="$PROJECT_DIR$/agent-operator"/>
|
||||||
|
<kind value="PACKAGE"/>
|
||||||
|
<package value="wdd.io/agent-operator"/>
|
||||||
|
<directory value="$PROJECT_DIR$"/>
|
||||||
|
<filePath value="$PROJECT_DIR$"/>
|
||||||
|
<framework value="gotest"/>
|
||||||
|
<pattern value="^\QTestUpdateCmiiDeploymentImageTag\E$"/>
|
||||||
|
<method v="2"/>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
@@ -51,6 +51,7 @@ func Execute(em *ExecutionMessage) (bool, []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if strings.HasPrefix(em.ExecutionType, "HARBOR") {
|
} else if strings.HasPrefix(em.ExecutionType, "HARBOR") {
|
||||||
|
// harbor function
|
||||||
if em.FuncContent == nil || len(em.FuncContent) <= 1 {
|
if em.FuncContent == nil || len(em.FuncContent) <= 1 {
|
||||||
ok = false
|
ok = false
|
||||||
resultLog = []string{
|
resultLog = []string{
|
||||||
@@ -61,6 +62,7 @@ func Execute(em *ExecutionMessage) (bool, []string) {
|
|||||||
ok, resultLog = HarborOperatorCache.Exec(em.FuncContent[0], em.FuncContent[1:]...)
|
ok, resultLog = HarborOperatorCache.Exec(em.FuncContent[0], em.FuncContent[1:]...)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// deprecated
|
||||||
// shell command
|
// shell command
|
||||||
if em.PipeLineCommand != nil && len(em.PipeLineCommand) != 0 {
|
if em.PipeLineCommand != nil && len(em.PipeLineCommand) != 0 {
|
||||||
// 管道命令
|
// 管道命令
|
||||||
|
|||||||
@@ -395,7 +395,8 @@ func BackupAllDeploymentFromEnv(cmiiEnv string) bool {
|
|||||||
// must filter
|
// must filter
|
||||||
allInterface = FilterAllCmiiAppSoft(allInterface)
|
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)
|
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) {
|
func BackUpAllCmiiAppImageNameFromEnv(cmiiEnv string) {
|
||||||
|
|
||||||
CmiiOperator.changeOperatorEnv(cmiiEnv)
|
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)
|
only := make(map[string]string, 150)
|
||||||
// front
|
// front
|
||||||
|
|||||||
@@ -211,28 +211,28 @@ func TestUpdateCmiiImageTagFromNameTagMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestScaleCmiiFrontendDeploymentToDesiredReplicas(t *testing.T) {
|
func TestScaleCmiiFrontendDeploymentToDesiredReplicas(t *testing.T) {
|
||||||
ScaleCmiiFrontendDeploymentToDesiredReplicas(dev, 0)
|
ScaleCmiiFrontendDeploymentToDesiredReplicas(uat, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestScaleCmiiBackendDeploymentToDesiredReplicas(t *testing.T) {
|
func TestScaleCmiiBackendDeploymentToDesiredReplicas(t *testing.T) {
|
||||||
ScaleCmiiBackendDeploymentToDesiredReplicas(dev, 0)
|
ScaleCmiiBackendDeploymentToDesiredReplicas(uat, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBackupAllDeploymentFromEnv(t *testing.T) {
|
func TestBackupAllDeploymentFromEnv(t *testing.T) {
|
||||||
|
|
||||||
BackupAllDeploymentFromEnv(demo)
|
BackupAllDeploymentFromEnv(integration)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBackUpAllCmiiAppImageNameFromEnv(t *testing.T) {
|
func TestBackUpAllCmiiAppImageNameFromEnv(t *testing.T) {
|
||||||
|
|
||||||
BackUpAllCmiiAppImageNameFromEnv(demo)
|
BackUpAllCmiiAppImageNameFromEnv(integration)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRestartCmiiDeployment(t *testing.T) {
|
func TestRestartCmiiDeployment(t *testing.T) {
|
||||||
cmiiEnv := integration
|
cmiiEnv := integration
|
||||||
appName := "cmii-uav-device"
|
appName := "cmii-uav-platform"
|
||||||
|
|
||||||
kill := CmiiOperator.DeploymentRestartByKill(cmiiEnv, appName)
|
kill := CmiiOperator.DeploymentRestartByKill(cmiiEnv, appName)
|
||||||
assert.Equal(t, kill, true, "have unhealthy pod !")
|
assert.Equal(t, kill, true, "have unhealthy pod !")
|
||||||
@@ -244,8 +244,8 @@ func TestRestartCmiiDeployment(t *testing.T) {
|
|||||||
func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
|
func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
|
||||||
|
|
||||||
cmiiEnv := demo
|
cmiiEnv := demo
|
||||||
appName := "cmii-uav-platform"
|
appName := "cmii-uav-process"
|
||||||
newTag := "5.4.0-031901"
|
newTag := "5.4.0-032201"
|
||||||
|
|
||||||
tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag)
|
tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag)
|
||||||
assert.Equal(t, tag, true, "update image tag failed !")
|
assert.Equal(t, tag, true, "update image tag failed !")
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const DirectPushDeployHarborHost = "36.134.71.138"
|
|||||||
type ImageSyncEntity struct {
|
type ImageSyncEntity struct {
|
||||||
ProjectName string
|
ProjectName string
|
||||||
ProjectVersion string
|
ProjectVersion string
|
||||||
DirectHarborHost string
|
DirectHarborHost string //此参数决定是否能够直连目标主机,如果有则代表直连,可以直接推送景象
|
||||||
PushToDemoMinio bool
|
PushToDemoMinio bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +32,7 @@ type ImageSyncResult struct {
|
|||||||
AllCmiiImageNameList []string
|
AllCmiiImageNameList []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PullFromEntityAndSyncConditionally 根据ImageSyncEntity拉取特定的镜像,然后上传到特定的目标机器
|
||||||
func (sync ImageSyncEntity) PullFromEntityAndSyncConditionally() (imageSyncResult ImageSyncResult) {
|
func (sync ImageSyncEntity) PullFromEntityAndSyncConditionally() (imageSyncResult ImageSyncResult) {
|
||||||
|
|
||||||
var realCmiiImageList []string
|
var realCmiiImageList []string
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ func TestCmiiK8sOperator_DeploymentFizz(t *testing.T) {
|
|||||||
func TestCmiiK8sOperator_DeploymentScale(t *testing.T) {
|
func TestCmiiK8sOperator_DeploymentScale(t *testing.T) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
CmiiOperator.DeploymentScale("devflight", "cmii-uav-depotautoreturn", 0)
|
CmiiOperator.DeploymentScale(demo, "cmii-uav-industrial-portfolio", 1)
|
||||||
elapsed := time.Since(start).Milliseconds()
|
elapsed := time.Since(start).Milliseconds()
|
||||||
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ func TestCmiiK8sOperator_DeploymentUpdateTag(t *testing.T) {
|
|||||||
|
|
||||||
func TestCmiiK8sOperator_DeploymentRestart(t *testing.T) {
|
func TestCmiiK8sOperator_DeploymentRestart(t *testing.T) {
|
||||||
|
|
||||||
cmiiEnv := "int"
|
cmiiEnv := "demo"
|
||||||
appName := "cmii-uav-gis-server"
|
appName := "cmii-uav-gis-server"
|
||||||
|
|
||||||
CmiiOperator.DeploymentRestart(cmiiEnv, appName)
|
CmiiOperator.DeploymentRestart(cmiiEnv, appName)
|
||||||
|
|||||||
@@ -185,6 +185,8 @@ func TestSaveSpecificImageToGzipFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// image pull success
|
// image pull success
|
||||||
|
log.InfoF("image should have pulled successful ! => %s", imageFullName)
|
||||||
|
|
||||||
if !SaveToTarGZ(imageFullName, imageGzipFilePathPrefix) {
|
if !SaveToTarGZ(imageFullName, imageGzipFilePathPrefix) {
|
||||||
log.ErrorF("image save to gzip file error ! => %s", imageFullName)
|
log.ErrorF("image save to gzip file error ! => %s", imageFullName)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func main() {
|
|||||||
|
|
||||||
// build from local LocalKubeConfigFile
|
// build from local LocalKubeConfigFile
|
||||||
if !utils.FileExists(LocalKubeConfigFile) {
|
if !utils.FileExists(LocalKubeConfigFile) {
|
||||||
log.ErrorF("%s not exits! error!")
|
log.ErrorF("%s not exits! error!", LocalKubeConfigFile)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
cmii_operator/log/cmii-update-log.txt
Normal file
17
cmii_operator/log/cmii-update-log.txt
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user