From 5952f3e843bc20e0584c341def44f197415440c6 Mon Sep 17 00:00:00 2001 From: kunlongli Date: Fri, 15 Sep 2023 20:03:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BF=BD=E7=95=A5=E6=89=A9=E7=BC=A9?= =?UTF-8?q?=E5=AE=B9=E5=88=86=E6=9E=90=E4=BB=BB=E5=8A=A1Deployment?= =?UTF-8?q?=E6=97=B6409=E9=94=99=E8=AF=AF=20#1172?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KubernetesDeploymentDispatcher.kt | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/dispatcher/KubernetesDeploymentDispatcher.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/dispatcher/KubernetesDeploymentDispatcher.kt index 505f9a9152..1c1b633584 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/dispatcher/KubernetesDeploymentDispatcher.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/dispatcher/KubernetesDeploymentDispatcher.kt @@ -82,7 +82,7 @@ class KubernetesDeploymentDispatcher( if (e.code != HttpStatus.NOT_FOUND.value()) { throw e } - logger.info("delete deployment[$deploymentName] success") + logger.warn("delete deployment[$deploymentName], not found") } } } @@ -118,14 +118,21 @@ class KubernetesDeploymentDispatcher( "from ${deployment.spec!!.replicas} to $targetReplicas" ) deployment.spec!!.replicas = targetReplicas - // 更新Deployment - api!!.replaceNamespacedDeployment( - deployment.metadata!!.name!!, - deployment.metadata!!.namespace!!, - deployment, - null, null, null - ) - logger.info("scale deployment[${deployment.metadata!!.name}] success") + try { + // 更新Deployment + api!!.replaceNamespacedDeployment( + deployment.metadata!!.name!!, + deployment.metadata!!.namespace!!, + deployment, + null, null, null + ) + logger.info("scale deployment[${deployment.metadata!!.name}] success") + } catch (e: ApiException) { + if (e.code != HttpStatus.CONFLICT.value()) { + throw e + } + logger.warn("scale deployment[${deployment.metadata!!.name}] conflict, targetReplicas[$targetReplicas]") + } } }