[ Agent ] [ CMII ] - 新增Deployment的Kill更新模式
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user