[ Agent ] [ CMII ] - 新增Deployment的Kill更新模式
This commit is contained in:
@@ -218,7 +218,7 @@ func UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag string) bool {
|
||||
log.DebugF("[UpdateCmiiDeploymentImageTag] - prepare to update [%s]!", content)
|
||||
|
||||
// update
|
||||
tag := CmiiOperator.DeploymentUpdateTag(cmiiEnv, appName, newTag)
|
||||
tag := CmiiOperator.DeploymentUpdateTag(cmiiDeploymentInterface.Namespace, cmiiDeploymentInterface.Name, newTag)
|
||||
if !tag {
|
||||
log.ErrorF("[UpdateCmiiDeploymentImageTag] - [%s] update failed !", content)
|
||||
return false
|
||||
|
||||
@@ -49,9 +49,9 @@ func TestBackupAllCmiiDeploymentToMap(t *testing.T) {
|
||||
|
||||
func TestUpdateCmiiDeploymentImageTag(t *testing.T) {
|
||||
|
||||
cmiiEnv := "uavms"
|
||||
appName := "uavms-lowaltitude-platform"
|
||||
newTag := "5.2.0-011202"
|
||||
cmiiEnv := "demo"
|
||||
appName := "cmii-uav-platform"
|
||||
newTag := "5.2.0-011201"
|
||||
|
||||
tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag)
|
||||
assert.Equal(t, tag, true, "update image tag failed !")
|
||||
|
||||
@@ -394,13 +394,38 @@ func (op *CmiiK8sOperator) DeploymentRestart(cmiiEnv, appName string) bool {
|
||||
return result
|
||||
}
|
||||
|
||||
func (op *CmiiK8sOperator) DeploymentRestartByKill(cmiiEnv, appName string) bool {
|
||||
|
||||
deployment := op.DeploymentOneInterface(cmiiEnv, appName)
|
||||
if deployment == nil {
|
||||
log.ErrorF("[DeploymentRestart] - [%s] [%s] not exists !", cmiiEnv, appName)
|
||||
return false
|
||||
}
|
||||
|
||||
podList := op.PodByAppName(deployment.Namespace, deployment.Name)
|
||||
if podList == nil {
|
||||
log.ErrorF("[DeploymentRestart] - [%s] [%s] no pod success !", deployment.Namespace, deployment.Name)
|
||||
return true
|
||||
}
|
||||
|
||||
for _, podInterface := range podList {
|
||||
if !op.PodDelete(cmiiEnv, podInterface.Name) {
|
||||
log.ErrorF("[DeploymentRestart] - [%s] [%s] delete pod failed !", podInterface.Namespace, podInterface.Name)
|
||||
} else {
|
||||
log.DebugF("[DeploymentRestart] - [%s] [%s] delete pod success !", podInterface.Namespace, podInterface.Name)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (op *CmiiK8sOperator) DeploymentStatusCheck(cmiiEnv, appName string, waitTimeOut int) bool {
|
||||
|
||||
op.changeOperatorEnv(cmiiEnv)
|
||||
|
||||
// 设置超时时间和时间间隔
|
||||
timeout := time.After(time.Duration(waitTimeOut) * time.Second)
|
||||
tick := time.Tick(2 * time.Second)
|
||||
tick := time.Tick(time.Second)
|
||||
|
||||
// 监控Pod状态
|
||||
for {
|
||||
@@ -416,11 +441,11 @@ func (op *CmiiK8sOperator) DeploymentStatusCheck(cmiiEnv, appName string, waitTi
|
||||
return false
|
||||
}
|
||||
if deployment.AvailableReplicas == deployment.Replicas {
|
||||
log.InfoF("[DeploymentStatusCheck] - [%s] [%s] Available: %d, Total: %d success !", cmiiEnv, appName, deployment.AvailableReplicas, deployment.Replicas)
|
||||
log.InfoF("[DeploymentStatusCheck] - [%s] [%s] Available: %d, Total: %d success !", deployment.Namespace, deployment.Name, deployment.AvailableReplicas, deployment.Replicas)
|
||||
return true
|
||||
}
|
||||
|
||||
log.DebugF("[DeploymentStatusCheck] - [%s] [%s] Available: %d, Total: %d waiting !", cmiiEnv, appName, deployment.AvailableReplicas, deployment.Replicas)
|
||||
log.DebugF("[DeploymentStatusCheck] - [%s] [%s] Available: %d, Total: %d waiting !", deployment.Namespace, deployment.Name, deployment.AvailableReplicas, deployment.Replicas)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func TestCmiiK8sOperator_DeploymentAllInterface(t *testing.T) {
|
||||
func TestCmiiK8sOperator_DeploymentFizz(t *testing.T) {
|
||||
|
||||
start := time.Now()
|
||||
deploymentFizz := CmiiOperator.DeploymentFizz("demo", "helm-proxysql")
|
||||
deploymentFizz := CmiiOperator.DeploymentFizz("int", "cmii-suav-supervision")
|
||||
elapsed := time.Since(start).Milliseconds()
|
||||
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
||||
|
||||
@@ -61,10 +61,10 @@ func TestCmiiK8sOperator_DeploymentFizz(t *testing.T) {
|
||||
|
||||
cmiiDeploymentInterface := CmiiDeploymentInterface{}
|
||||
for _, pod := range deploymentFizz {
|
||||
utils.BeautifulPrint(pod)
|
||||
|
||||
convert := cmiiDeploymentInterface.Convert(pod)
|
||||
utils.BeautifulPrint(convert)
|
||||
|
||||
utils.BeautifulPrint(pod)
|
||||
}
|
||||
|
||||
// elastic search
|
||||
@@ -88,10 +88,19 @@ func TestCmiiK8sOperator_DeploymentUpdateTag(t *testing.T) {
|
||||
fmt.Printf("执行耗时: %d ms\n", elapsed)
|
||||
}
|
||||
|
||||
func TestDeploymentRestart(t *testing.T) {
|
||||
func TestCmiiK8sOperator_DeploymentRestart(t *testing.T) {
|
||||
CmiiOperator.DeploymentRestart("int", "cmii-uav-user")
|
||||
}
|
||||
|
||||
func TestCmiiK8sOperator_DeploymentRestartByKill(t *testing.T) {
|
||||
cmiiEnv := "int"
|
||||
appName := "cmii-suav-supervision"
|
||||
|
||||
kill := CmiiOperator.DeploymentRestartByKill(cmiiEnv, appName)
|
||||
assert.Equal(t, kill, true, "deployment restart by kill failed !")
|
||||
|
||||
}
|
||||
|
||||
func TestCmiiK8sOperator_DeploymentOneInterface(t *testing.T) {
|
||||
start := time.Now()
|
||||
deploy := CmiiOperator.DeploymentOneInterface("devflight", "cmii-uav-depotautoreturn")
|
||||
@@ -156,10 +165,10 @@ func TestCmiiK8sOperator_PodFizz(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCmiiK8sOperator_PodByAppName(t *testing.T) {
|
||||
cmiiEnv := "uavcloud-devflight"
|
||||
nodeName := "dev-01.ecs.io"
|
||||
cmiiEnv := "uat"
|
||||
appName := "cmii-admin-data"
|
||||
|
||||
exists := CmiiOperator.PodByNodeName(cmiiEnv, nodeName)
|
||||
exists := CmiiOperator.PodByNodeName(cmiiEnv, appName)
|
||||
|
||||
for _, podInterface := range exists {
|
||||
utils.BeautifulPrint(podInterface)
|
||||
@@ -193,13 +202,19 @@ func TestCmiiK8sOperator_PodFizz2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCmiiK8sOperator_PodByNodeName(t *testing.T) {
|
||||
cmiiEnv := "uavcloud-devflight"
|
||||
appName := "cmii-admin-data"
|
||||
|
||||
exists := CmiiOperator.PodByAppName(cmiiEnv, appName)
|
||||
cmiiEnv := "uat"
|
||||
nodeName := "test-03.ecs.io"
|
||||
|
||||
exists := CmiiOperator.PodByNodeName(cmiiEnv, nodeName)
|
||||
exists = FilterAllCmiiPodSoft(exists)
|
||||
for _, podInterface := range exists {
|
||||
utils.BeautifulPrint(podInterface)
|
||||
|
||||
if !podInterface.PodStatus {
|
||||
podDelete := CmiiOperator.PodDelete(podInterface.Namespace, podInterface.Name)
|
||||
assert.Equal(t, podDelete, true, "delete pod failed !")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,3 +14,5 @@
|
||||
2024-01-11-17-49-09 uavcloud-uavms uavms-lowaltitude-platform 5.1.0-011102 5.1.0-011104
|
||||
2024-01-12-10-38-30 uavcloud-uavms uavms-lowaltitude-platform 5.1.0-011105 5.2.0-011201
|
||||
2024-01-12-12-09-59 uavcloud-uavms uavms-lowaltitude-platform 5.2.0-011201 5.2.0-011202
|
||||
2024-01-12-17-13-32 uavcloud-test cmii-suav-supervision 5.2.0-011001 5.2.0-011201
|
||||
2024-01-12-17-22-47 uavcloud-demo cmii-uav-platform 5.2.0-011102 5.2.0-011201
|
||||
|
||||
Reference in New Issue
Block a user