[agent-go] - fix bugs

This commit is contained in:
zeaslity
2024-07-11 16:06:10 +08:00
parent 90999380aa
commit 110314901e
5 changed files with 105 additions and 30 deletions

View File

@@ -228,6 +228,25 @@ func CmiiEnvironmentDeploy(isCompleteDeploy bool, commonEnv *z_dep.CommonEnviron
}
func CmiiNewAppDeploy(commonEnv *z_dep.CommonEnvironmentConfig, isFrontendDeploy bool, backendImageVersionMap, frontendImageVersionMap map[string]string) {
// get cmii env config from namespace
//cmiiEnvConfig := getCmiiEnvConfigurationFromNamespace(commonEnv.Namespace)
if isFrontendDeploy {
configMapDeploy(commonEnv)
d_app.DefaultIngressConfig.IngressDeploy(commonEnv)
// frontend
frontendDeploy(commonEnv, frontendImageVersionMap)
}
// backend
backendDeploy(commonEnv, backendImageVersionMap)
}
func getCmiiEnvConfigurationFromNamespace(namespace string) *e_cmii.CmiiEnvConfig {
switch namespace {
case dev:

View File

@@ -88,7 +88,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -177,7 +177,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -266,7 +266,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -355,7 +355,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -444,7 +444,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -533,7 +533,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -622,7 +622,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -711,7 +711,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -800,7 +800,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -889,7 +889,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -978,7 +978,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1067,7 +1067,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1156,7 +1156,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1245,7 +1245,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1334,7 +1334,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1423,7 +1423,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1512,7 +1512,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1601,7 +1601,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1690,7 +1690,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1779,7 +1779,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1868,7 +1868,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -1957,7 +1957,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -2046,7 +2046,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -2135,7 +2135,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -2224,7 +2224,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js
@@ -2313,7 +2313,7 @@ spec:
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx.conf
- name: tenant-prefix
subPath: ingress-config.js

View File

@@ -50,7 +50,7 @@ func CmiiEnvDeploy(deployCommonEnv *z_dep.CommonEnvironmentConfig, shouldDoCompl
utils.BeautifulPrintWithTitle(frontendMap, "frontendMap")
utils.BeautifulPrintWithTitle(srsMap, "srsMap")
//
// get the apply file path
deployCommonEnv.GenerateApplyFilePath()
// do generate all application files
@@ -72,6 +72,55 @@ func CmiiEnvDeploy(deployCommonEnv *z_dep.CommonEnvironmentConfig, shouldDoCompl
}
func CmiiNewAppDeploy(deployCommonEnv *z_dep.CommonEnvironmentConfig, isFrontEnd bool, newAppNamespace string) {
folderPrefix := "/home/wdd/IdeaProjects/ProjectOctopus/agent-deploy/" + deployCommonEnv.Namespace + "/"
tenantEnv := deployCommonEnv.Namespace
// uavcloud-devflight ==> devflight
// uavcloud-dev ==> dev
if strings.Contains(tenantEnv, "-") {
split := strings.Split(tenantEnv, "-")
tenantEnv = split[len(split)-1]
} else {
// demo ==> ""
// cqlyj ==> ""
tenantEnv = ""
}
// assign folder prefix
deployCommonEnv.ApplyFilePrefix = folderPrefix
var backendMap map[string]string
var frontendMap map[string]string
var srsMap map[string]string
// 输出特定版本的Tag
backendMap, frontendMap, srsMap = image.GenerateCmiiTagVersionImageMap(deployCommonEnv.TagVersion)
if newAppNamespace != "" {
// 从 backupFromEnv 环境拉取特定版本的所有Tag
backendMapFromEnv, frontendMapFromEnv, srsMapFromEnv := BackupAllCmiiDeploymentToMap(newAppNamespace)
backendMap = utils.MergeMap(backendMap, backendMapFromEnv)
frontendMap = utils.MergeMap(frontendMap, frontendMapFromEnv)
srsMap = utils.MergeMap(srsMap, srsMapFromEnv)
}
utils.BeautifulPrintWithTitle(backendMap, "backendMap")
utils.BeautifulPrintWithTitle(frontendMap, "frontendMap")
utils.BeautifulPrintWithTitle(srsMap, "srsMap")
// get the apply file path
deployCommonEnv.GenerateApplyFilePath()
// generate application file
agentdeploy.CmiiNewAppDeploy(deployCommonEnv, isFrontEnd, backendMap, frontendMap)
// apply file
applyNewAppStuff(deployCommonEnv, false)
}
func applyNewAppStuff(common *z_dep.CommonEnvironmentConfig, shouldDoCompleteDeploy bool) bool {
files, err := os.ReadDir(common.ApplyFilePrefix)
if err != nil {
@@ -133,6 +182,9 @@ func applyNewAppStuff(common *z_dep.CommonEnvironmentConfig, shouldDoCompleteDep
// backend
ApplyByKubectl(z_dep.BackendApplyFilePath, namespace)
// srs
ApplyByKubectl(z_dep.SRSApplyFilePath, namespace)
return true
}

View File

@@ -253,7 +253,7 @@ func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
// 计算20:00的时间
now := time.Now()
targetTime := time.Date(now.Year(), now.Month(), now.Day(), 11, 37, 00, 0, now.Location())
targetTime := time.Date(now.Year(), now.Month(), now.Day(), 17, 35, 00, 0, now.Location())
duration := time.Duration(0)
@@ -277,10 +277,11 @@ func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
appNameTagMap := map[string]string{
//"cmii-uav-platform-dispatchh5": "5.6.0-062401",
//"cmii-uav-data-post-process": "5.6.0-062401",
"cmii-uav-industrial-portfolio": "5.6.0-070301",
//"cmii-uav-multilink": "5.5.0",
//"cmii-uav-developer": "5.6.0-062701",
//"cmii-uav-platform": "5.6.0-0626",
"cmii-uav-platform": "5.6.0-070401",
"cmii-uav-platform-share": "5.6.0-070401",
"cmii-uav-industrial-portfolio": "5.6.0-070401",
}
for appName, newTag := range appNameTagMap {

View File

@@ -91,3 +91,6 @@
2024-07-01-18-12-13 uavcloud-demo cmii-uav-platform 5.6.0-0626 5.6.0-070101
2024-07-01-18-19-57 uavcloud-demo cmii-uav-platform 5.6.0-070101 5.6.0-0626
2024-07-03-11-37-00 uavcloud-demo cmii-uav-industrial-portfolio 5.6.0-sense-070103 5.6.0-070301
2024-07-04-17-35-00 uavcloud-demo cmii-uav-platform-share 5.6.0-0704 5.6.0-070401
2024-07-04-17-35-06 uavcloud-demo cmii-uav-industrial-portfolio 5.6.0-070301 5.6.0-070401
2024-07-04-17-36-38 uavcloud-demo cmii-uav-platform 5.6.0-070203 5.6.0-070401