From 3e3fdbd089f2629ec3ed4eb03d400c1d4f4f3621 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Wed, 8 Nov 2023 13:32:05 +0800 Subject: [PATCH 01/28] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E7=BB=84?= =?UTF-8?q?=E5=8F=91=E5=B8=83ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 111 ++++++++++++++++++ .../ci/dynamic-stock-batch-deployment.yaml | 25 ++++ 2 files changed, 136 insertions(+) create mode 100644 .github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml create mode 100644 module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml new file mode 100644 index 000000000..854777888 --- /dev/null +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -0,0 +1,111 @@ +name: Module Controller Integration Test +run-name: ${{ github.actor }} pushed module-controller code + +on: + push: + branches: + - master + paths: + - 'module-controller/**' + + pull_request: + branches: + - master + paths: + - 'module-controller/**' + + # enable manually running the workflow + workflow_dispatch: + +env: + CGO_ENABLED: 0 + GOOS: linux + WORK_DIR: module-controller + TAG: ci-test-master-latest + DOCKERHUB_REGISTRY: serverless-registry.cn-shanghai.cr.aliyuncs.com + MODULE_CONTROLLER_IMAGE_PATH: opensource/test/module-controller + INTEGRATION_TESTS_IMAGE_PATH: opensource/test/module-controller-integration-tests + POD_NAMESPACE: default + +defaults: + run: + working-directory: module-controller + +jobs: + unit-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Docker login + uses: docker/login-action@v2.2.0 + with: + registry: ${{ env.DOCKERHUB_REGISTRY }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + logout: false + + - name: Set up Docker buildx + uses: docker/setup-buildx-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ hashFiles('${{ env.WORK_DIR }}/*Dockerfile') }} + + - name: Build and push module-controller Docker images + uses: docker/build-push-action@v4.1.1 + with: + context: ${{ env.WORK_DIR }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + file: ${{ env.WORK_DIR }}/Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.MODULE_CONTROLLER_IMAGE_PATH }}:${{ env.TAG }} + + - run: sleep 30 + + - name: Set up Minikube + run: | + curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 + sudo install minikube-linux-amd64 /usr/local/bin/minikube + + - name: Start Minikube + run: minikube start + + - name: Prepare development env + run: | + kubectl apply -f config/crd/bases/serverless.alipay.com_moduledeployments.yaml + kubectl apply -f config/crd/bases/serverless.alipay.com_modulereplicasets.yaml + kubectl apply -f config/crd/bases/serverless.alipay.com_modules.yaml + kubectl apply -f config/crd/bases/serverless.alipay.com_moduletemplates.yaml + kubectl apply -f config/rbac/role.yaml + kubectl apply -f config/rbac/role_binding.yaml + kubectl apply -f config/rbac/service_account.yaml + kubectl apply -f config/samples/ci/dynamic-stock-batch-deployment.yaml + kubectl apply -f config/samples/ci/module-deployment-controller.yaml + kubectl apply -f config/samples/ci/dynamic-stock-service.yaml + + - run: sleep 60 + + - name: minikube logs + run: minikube logs + + - name: get pod + run: | + kubectl get pod + + - name: describe pod + run: | + kubectl describe pod + + - name: wait base pod available + run: | + kubectl wait --for=condition=available deployment/dynamic-stock-deployment --timeout=300s + + - name: get module controller pod available + run: | + kubectl wait --for=condition=available deployment/module-controller --timeout=300s \ No newline at end of file diff --git a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml new file mode 100644 index 000000000..b6ebd3724 --- /dev/null +++ b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dynamic-stock-deployment +spec: + replicas: 3 + selector: + matchLabels: + app: dynamic-stock + template: + metadata: + labels: + app: dynamic-stock + maxModuleCount: "10" + spec: + containers: + - name: dynamic-stock-container + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock-mng:v0.6 + ports: + - containerPort: 8080 + - containerPort: 1238 + resources: + limits: + cpu: "500m" + memory: "1Gi" \ No newline at end of file From de8c91e717f93b713e92e6f8878403702096daf6 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Wed, 8 Nov 2023 13:38:29 +0800 Subject: [PATCH 02/28] add log --- .../module_controller_ci_build_batch_deploy_to_aliyun.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 854777888..daaddc9e4 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -108,4 +108,8 @@ jobs: - name: get module controller pod available run: | - kubectl wait --for=condition=available deployment/module-controller --timeout=300s \ No newline at end of file + kubectl wait --for=condition=available deployment/module-controller --timeout=300s + + - name: get pod + run: | + kubectl get pod \ No newline at end of file From 91aae3e7f5897e9cc72d216b0267496647d3c207 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Thu, 9 Nov 2023 15:11:10 +0800 Subject: [PATCH 03/28] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=88=86=E7=BB=84=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 103 +++++++++++++++++- ...lpha1_moduledeployment_batch_provider.yaml | 28 +++++ ...ledeployment_batch_provider_scaledown.yaml | 28 +++++ 3 files changed, 153 insertions(+), 6 deletions(-) create mode 100644 module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml create mode 100644 module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index daaddc9e4..d69f87d10 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -98,10 +98,6 @@ jobs: run: | kubectl get pod - - name: describe pod - run: | - kubectl describe pod - - name: wait base pod available run: | kubectl wait --for=condition=available deployment/dynamic-stock-deployment --timeout=300s @@ -110,6 +106,101 @@ jobs: run: | kubectl wait --for=condition=available deployment/module-controller --timeout=300s - - name: get pod + - name: apply moduledeployment batch release + run: | + kubectl apply -f config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml + + - name: get moduledeployment + run: | + kubectl get moduledeployment + + - name: get modulereplicaset + run: | + kubectl get modulereplicaset + + - run: sleep 15 + + - name: get module + run: | + kubectl get module -oyaml + + - name: exist module + run: | + moduleCount=$(kubectl get module | wc -l) + if [[ $moduleCount -lt 1 ]]; then + echo "ERROR: 不存在module" + exit 1 + fi + + - name: wait module available + run: | + # 定义要等待的资源名称和字段值 + modulename=$(kubectl get module -o name) + desired_field_value="Available" + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件" + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - name: check moduledeployment pause + run: | + # 定义要等待的资源名称和字段值 + moduledeploymentname=$(kubectl get moduledeployment -o name) + desired_field_value=true + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件,执行分组确认" + kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - run: sleep 15 + + - name: exist module run: | - kubectl get pod \ No newline at end of file + moduleCount=$(kubectl get module | wc -l) + if [[ $moduleCount -lt 2 ]]; then + echo "ERROR: 不存在module" + exit 1 + fi \ No newline at end of file diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml new file mode 100644 index 000000000..c97fa6bb2 --- /dev/null +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml @@ -0,0 +1,28 @@ +apiVersion: serverless.alipay.com/v1alpha1 +kind: ModuleDeployment +metadata: + labels: + app.kubernetes.io/name: moduledeployment + app.kubernetes.io/instance: moduledeployment-sample + app.kubernetes.io/part-of: module-controller + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/created-by: module-controller + name: moduledeployment-sample-provider +spec: + baseDeploymentName: dynamic-stock-deployment + template: + spec: + module: + name: dynamic-provider + version: '1.0.0' + url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.0-ark-biz.jar + replicas: 3 + operationStrategy: + needConfirm: true + grayTimeBetweenBatchSeconds: 120 + useBeta: false + batchCount: 3 + upgradePolicy: install_then_uninstall + schedulingStrategy: + schedulingPolicy: scatter + diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml new file mode 100644 index 000000000..be834a450 --- /dev/null +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml @@ -0,0 +1,28 @@ +apiVersion: serverless.alipay.com/v1alpha1 +kind: ModuleDeployment +metadata: + labels: + app.kubernetes.io/name: moduledeployment + app.kubernetes.io/instance: moduledeployment-sample + app.kubernetes.io/part-of: module-controller + app.kubernetes.io/managed-by: kustomize + app.kubernetes.io/created-by: module-controller + name: moduledeployment-sample-provider +spec: + baseDeploymentName: dynamic-stock-deployment + template: + spec: + module: + name: dynamic-provider + version: '1.0.0' + url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.0-ark-biz.jar + replicas: 0 + operationStrategy: + needConfirm: true + grayTimeBetweenBatchSeconds: 120 + useBeta: false + batchCount: 3 + upgradePolicy: install_then_uninstall + schedulingStrategy: + schedulingPolicy: scatter + From 74ba3fc3fce942e74622a134c5aaf2c6541a8b99 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Thu, 9 Nov 2023 15:31:36 +0800 Subject: [PATCH 04/28] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=88=86=E7=BB=84=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index d69f87d10..3fbdb72e6 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -197,10 +197,50 @@ jobs: - run: sleep 15 + - name: get module + run: | + kubectl get module -oyaml + - name: exist module run: | moduleCount=$(kubectl get module | wc -l) if [[ $moduleCount -lt 2 ]]; then echo "ERROR: 不存在module" exit 1 - fi \ No newline at end of file + fi + + - name: get moduledeployment + run: | + kubectl describe moduledeployment + + - name: check moduledeployment pause + run: | + # 定义要等待的资源名称和字段值 + moduledeploymentname=$(kubectl get moduledeployment -o name) + desired_field_value=true + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件,执行分组确认" + kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done \ No newline at end of file From 642eb6f87350d597ba6374453d07b01d1961292c Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Thu, 9 Nov 2023 15:42:18 +0800 Subject: [PATCH 05/28] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=88=86=E7=BB=84=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 3fbdb72e6..cc76422f1 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -199,9 +199,9 @@ jobs: - name: get module run: | - kubectl get module -oyaml + kubectl get module - - name: exist module + - name: exist module more then 2 run: | moduleCount=$(kubectl get module | wc -l) if [[ $moduleCount -lt 2 ]]; then @@ -243,4 +243,53 @@ jobs: echo "等待字段值满足条件..." sleep 5 # 等待一段时间后再次检查 fi - done \ No newline at end of file + done + + - name: get module + run: | + kubectl get module + + - name: exist module more then 3 + run: | + moduleCount=$(kubectl get module | wc -l) + if [[ $moduleCount -lt 3 ]]; then + echo "ERROR: 不存在module" + exit 1 + fi + + - name: wait module available + run: | + # 定义要等待的资源名称和字段值 + modulename=$(kubectl get module -o name) + desired_field_value="Available" + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件" + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - name: check module + run: | + podname=$(kubectl get pod -l app=dynamic-stock -o name) + logcount=(kubectl exec -it $podname -- sh -c 'grep "dynamic-provider:1.0.0 started" logs/stock-mng/sofa-ark/*.log' | wc -l) + echo $logcount From 3e4df3257f4ee27c4cf2d0e9fdfcec9395e1aabe Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Thu, 9 Nov 2023 15:58:54 +0800 Subject: [PATCH 06/28] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=88=86=E7=BB=84=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index cc76422f1..95c090df0 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -259,33 +259,39 @@ jobs: - name: wait module available run: | - # 定义要等待的资源名称和字段值 - modulename=$(kubectl get module -o name) + # 定义要等待的资源类型和期望的字段值 + moduletype="module" desired_field_value="Available" - + # 定义等待的超时时间(以秒为单位) timeout_seconds=300 - + start_time=$(date +%s) end_time=$((start_time + timeout_seconds)) - + while true; do current_time=$(date +%s) if [ $current_time -gt $end_time ]; then echo "等待超时" exit 1 fi - - # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 - field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers) - - if [ "$field_value" == "$desired_field_value" ]; then - echo "字段值已满足条件" - exit 0 - else - echo "等待字段值满足条件..." - sleep 5 # 等待一段时间后再次检查 - fi + + # 获取所有的资源对象名,并循环处理 + for modulename in $(kubectl get $moduletype -o name); do + # 使用 kubectl get 命令获取每个资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers) + + # 检查字段值是否满足期望 + if [ "$field_value" != "$desired_field_value" ]; then + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + continue 2 # 如果字段值未满足,则跳出循环,进入下一轮等待 + fi + done + + # 如果所有资源对象的字段值都满足期望,则结束脚本 + echo "字段值已满足条件" + exit 0 done - name: check module From 00414fba925d312a3ed10de3e7ddd57a2d8b2c72 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Thu, 9 Nov 2023 16:41:18 +0800 Subject: [PATCH 07/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=BB=84?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=8B=89=E8=B5=B7pod=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E4=B8=BA2=EF=BC=8C3=E4=B8=AA=E4=BC=9A=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E4=B8=8D=E8=B6=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 50 +------------------ ...e_controller_ci_build_deploy_to_aliyun.yml | 2 + .../ci/dynamic-stock-batch-deployment.yaml | 2 +- ...lpha1_moduledeployment_batch_provider.yaml | 4 +- ...ledeployment_batch_provider_scaledown.yaml | 2 +- 5 files changed, 7 insertions(+), 53 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 95c090df0..4be1b37a7 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -201,7 +201,7 @@ jobs: run: | kubectl get module - - name: exist module more then 2 + - name: exist module more then 1 run: | moduleCount=$(kubectl get module | wc -l) if [[ $moduleCount -lt 2 ]]; then @@ -209,54 +209,6 @@ jobs: exit 1 fi - - name: get moduledeployment - run: | - kubectl describe moduledeployment - - - name: check moduledeployment pause - run: | - # 定义要等待的资源名称和字段值 - moduledeploymentname=$(kubectl get moduledeployment -o name) - desired_field_value=true - - # 定义等待的超时时间(以秒为单位) - timeout_seconds=300 - - start_time=$(date +%s) - end_time=$((start_time + timeout_seconds)) - - while true; do - current_time=$(date +%s) - if [ $current_time -gt $end_time ]; then - echo "等待超时" - exit 1 - fi - - # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 - field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) - - if [ "$field_value" == "$desired_field_value" ]; then - echo "字段值已满足条件,执行分组确认" - kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge - exit 0 - else - echo "等待字段值满足条件..." - sleep 5 # 等待一段时间后再次检查 - fi - done - - - name: get module - run: | - kubectl get module - - - name: exist module more then 3 - run: | - moduleCount=$(kubectl get module | wc -l) - if [[ $moduleCount -lt 3 ]]; then - echo "ERROR: 不存在module" - exit 1 - fi - - name: wait module available run: | # 定义要等待的资源类型和期望的字段值 diff --git a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml index 5125a9ac1..49f9c24a1 100644 --- a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml @@ -363,6 +363,8 @@ jobs: fi done + - run: sleep 15 + - name: delete pod then check module run: | podname=$(kubectl get pod -l app=dynamic-stock -o name) diff --git a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml index b6ebd3724..d164eb437 100644 --- a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml @@ -3,7 +3,7 @@ kind: Deployment metadata: name: dynamic-stock-deployment spec: - replicas: 3 + replicas: 2 selector: matchLabels: app: dynamic-stock diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml index c97fa6bb2..46e454008 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml @@ -16,12 +16,12 @@ spec: name: dynamic-provider version: '1.0.0' url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.0-ark-biz.jar - replicas: 3 + replicas: 2 operationStrategy: needConfirm: true grayTimeBetweenBatchSeconds: 120 useBeta: false - batchCount: 3 + batchCount: 2 upgradePolicy: install_then_uninstall schedulingStrategy: schedulingPolicy: scatter diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml index be834a450..fd2d8da30 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml @@ -21,7 +21,7 @@ spec: needConfirm: true grayTimeBetweenBatchSeconds: 120 useBeta: false - batchCount: 3 + batchCount: 2 upgradePolicy: install_then_uninstall schedulingStrategy: schedulingPolicy: scatter From 3952cffc25ee387773723ba3e2bdddf360f7b1aa Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Thu, 16 Nov 2023 08:59:25 +0800 Subject: [PATCH 08/28] =?UTF-8?q?=E5=88=86=E7=BB=84=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 43 +++++++++++++++++++ .../ci/dynamic-stock-batch-deployment.yaml | 2 +- ...lpha1_moduledeployment_batch_provider.yaml | 4 +- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 4be1b37a7..c1525d41a 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -209,6 +209,49 @@ jobs: exit 1 fi + - name: check moduledeployment pause + run: | + # 定义要等待的资源名称和字段值 + moduledeploymentname=$(kubectl get moduledeployment -o name) + desired_field_value=true + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件,执行分组确认" + kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - name: get module + run: | + kubectl get module + + - name: exist module more then 1 + run: | + moduleCount=$(kubectl get module | wc -l) + if [[ $moduleCount -lt 3 ]]; then + echo "ERROR: 不存在module" + exit 1 + fi - name: wait module available run: | # 定义要等待的资源类型和期望的字段值 diff --git a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml index d164eb437..b6ebd3724 100644 --- a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml @@ -3,7 +3,7 @@ kind: Deployment metadata: name: dynamic-stock-deployment spec: - replicas: 2 + replicas: 3 selector: matchLabels: app: dynamic-stock diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml index 46e454008..c97fa6bb2 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml @@ -16,12 +16,12 @@ spec: name: dynamic-provider version: '1.0.0' url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.0-ark-biz.jar - replicas: 2 + replicas: 3 operationStrategy: needConfirm: true grayTimeBetweenBatchSeconds: 120 useBeta: false - batchCount: 2 + batchCount: 3 upgradePolicy: install_then_uninstall schedulingStrategy: schedulingPolicy: scatter From d549d849bee5ff5d235682f51aa1e7ea19934182 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Thu, 16 Nov 2023 16:46:29 +0800 Subject: [PATCH 09/28] =?UTF-8?q?ci=20test=20=E6=B7=BB=E5=8A=A0log?= =?UTF-8?q?=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_controller_ci_build_deploy_to_aliyun.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml index 49f9c24a1..17dfa1c3a 100644 --- a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml @@ -136,6 +136,12 @@ jobs: exit 1 fi + - run: sleep 15 + + - name: get module controller logs + run: | + kubectl logs deployment/module-controller + - name: wait module available run: | # 定义要等待的资源名称和字段值 From bd9cf0c6110d5c7f646045e21be15a74e4134992 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Mon, 20 Nov 2023 20:32:45 +0800 Subject: [PATCH 10/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E5=9D=97url?= =?UTF-8?q?=E4=B8=BA=E6=9C=80=E6=96=B0=E7=9A=84url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ule-deployment_v1alpha1_moduledeployment_batch_provider.yaml | 2 +- ...ment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml | 2 +- ...deployment_v1alpha1_moduledeployment_provider_scaledown.yaml | 2 +- .../module-deployment_v1alpha1_moduledeployment_facade.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml index c97fa6bb2..5b45151e2 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml @@ -15,7 +15,7 @@ spec: module: name: dynamic-provider version: '1.0.0' - url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.0-ark-biz.jar + url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.2-ark-biz.jar replicas: 3 operationStrategy: needConfirm: true diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml index fd2d8da30..bb426dc9f 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml @@ -15,7 +15,7 @@ spec: module: name: dynamic-provider version: '1.0.0' - url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.0-ark-biz.jar + url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.2-ark-biz.jar replicas: 0 operationStrategy: needConfirm: true diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_provider_scaledown.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_provider_scaledown.yaml index 634868de3..e5a28cac8 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_provider_scaledown.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_provider_scaledown.yaml @@ -15,7 +15,7 @@ spec: module: name: dynamic-provider version: '1.0.0' - url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.0-ark-biz.jar + url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.2-ark-biz.jar replicas: 0 operationStrategy: needConfirm: false diff --git a/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_facade.yaml b/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_facade.yaml index 3dfd31575..ec036a782 100644 --- a/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_facade.yaml +++ b/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_facade.yaml @@ -15,7 +15,7 @@ spec: module: name: dynamic-facade version: '1.0.0' - url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-facade-1.0.0-ark-biz.jar + url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.2-ark-biz.jar replicas: 1 operationStrategy: needConfirm: true From ca428e436312c0255aa60a998e216f9504aba6e0 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Mon, 20 Nov 2023 20:46:24 +0800 Subject: [PATCH 11/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E5=BA=A7Deplo?= =?UTF-8?q?yment=20image=E5=AD=97=E6=AE=B5=E4=B8=BA=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/samples/ci/dynamic-stock-batch-deployment.yaml | 2 +- .../config/samples/ci/dynamic-stock-deployment.yaml | 2 +- module-controller/config/samples/dynamic-stock-deployment.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml index b6ebd3724..05885f61a 100644 --- a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock-mng:v0.6 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 ports: - containerPort: 8080 - containerPort: 1238 diff --git a/module-controller/config/samples/ci/dynamic-stock-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-deployment.yaml index efb644a20..fc69f0705 100644 --- a/module-controller/config/samples/ci/dynamic-stock-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock-mng:v0.6 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 ports: - containerPort: 8080 - containerPort: 1238 diff --git a/module-controller/config/samples/dynamic-stock-deployment.yaml b/module-controller/config/samples/dynamic-stock-deployment.yaml index 8df06a3b8..fc69f0705 100644 --- a/module-controller/config/samples/dynamic-stock-deployment.yaml +++ b/module-controller/config/samples/dynamic-stock-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock-mng:v1.0-linux + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 ports: - containerPort: 8080 - containerPort: 1238 From 7d9af21b0916fe6791b64f243143832f791acd00 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Mon, 20 Nov 2023 20:54:18 +0800 Subject: [PATCH 12/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E5=BA=A7Deplo?= =?UTF-8?q?yment=20image=E5=AD=97=E6=AE=B5=E4=B8=BA=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module-deployment_v1alpha1_moduledeployment_facade.yaml | 2 +- .../module-deployment_v1alpha1_moduledeployment_provider.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_facade.yaml b/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_facade.yaml index ec036a782..3dfd31575 100644 --- a/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_facade.yaml +++ b/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_facade.yaml @@ -15,7 +15,7 @@ spec: module: name: dynamic-facade version: '1.0.0' - url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.2-ark-biz.jar + url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-facade-1.0.0-ark-biz.jar replicas: 1 operationStrategy: needConfirm: true diff --git a/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_provider.yaml b/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_provider.yaml index 9bc7e1188..42fe88cf8 100644 --- a/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_provider.yaml +++ b/module-controller/config/samples/module-deployment_v1alpha1_moduledeployment_provider.yaml @@ -15,7 +15,7 @@ spec: module: name: dynamic-provider version: '1.0.0' - url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.0-ark-biz.jar + url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.2-ark-biz.jar replicas: 1 operationStrategy: needConfirm: false From bd43e8e1f8cd8fe3c5b0b5612cf28a45d98c7f73 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Wed, 22 Nov 2023 15:45:08 +0800 Subject: [PATCH 13/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E5=BA=A7image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_controller_ci_build_deploy_to_aliyun.yml | 8 +++++++- .../config/samples/ci/dynamic-stock-batch-deployment.yaml | 2 +- .../config/samples/ci/dynamic-stock-deployment.yaml | 2 +- .../config/samples/dynamic-stock-deployment.yaml | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml index 17dfa1c3a..64c61164a 100644 --- a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml @@ -102,11 +102,17 @@ jobs: run: | kubectl describe pod + - name: delete base pod + run: | + kubectl delete pod deployment/dynamic-stock-deployment + + - run: sleep 10 + - name: wait base pod available run: | kubectl wait --for=condition=available deployment/dynamic-stock-deployment --timeout=300s - - name: get module controller pod available + - name: wait module controller pod available run: | kubectl wait --for=condition=available deployment/module-controller --timeout=300s diff --git a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml index 05885f61a..d8d99f8d4 100644 --- a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 ports: - containerPort: 8080 - containerPort: 1238 diff --git a/module-controller/config/samples/ci/dynamic-stock-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-deployment.yaml index fc69f0705..c93c805ef 100644 --- a/module-controller/config/samples/ci/dynamic-stock-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 ports: - containerPort: 8080 - containerPort: 1238 diff --git a/module-controller/config/samples/dynamic-stock-deployment.yaml b/module-controller/config/samples/dynamic-stock-deployment.yaml index fc69f0705..c93c805ef 100644 --- a/module-controller/config/samples/dynamic-stock-deployment.yaml +++ b/module-controller/config/samples/dynamic-stock-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 ports: - containerPort: 8080 - containerPort: 1238 From 9ef9f679544c04d83de8a4693b1dcaf4c4238928 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Wed, 22 Nov 2023 16:08:36 +0800 Subject: [PATCH 14/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E5=BA=A7image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/module_controller_ci_build_deploy_to_aliyun.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml index 64c61164a..bc094bafb 100644 --- a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml @@ -104,7 +104,8 @@ jobs: - name: delete base pod run: | - kubectl delete pod deployment/dynamic-stock-deployment + podname=$(kubectl get pod -l app=dynamic-stock -o name | cut -d/ -f2) + kubectl delete -n default pod $podname - run: sleep 10 From 3c437b1e628f9280040928ac493eccc456560947 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Wed, 22 Nov 2023 16:17:59 +0800 Subject: [PATCH 15/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E5=BA=A7image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_controller_ci_build_deploy_to_aliyun.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml index bc094bafb..ca4aa7929 100644 --- a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml @@ -109,6 +109,14 @@ jobs: - run: sleep 10 + - name: get pod + run: | + kubectl get pod + + - name: describe pod + run: | + kubectl describe pod + - name: wait base pod available run: | kubectl wait --for=condition=available deployment/dynamic-stock-deployment --timeout=300s From 62298ca966312753c10dc9a7761f29cc1ada2547 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Wed, 22 Nov 2023 16:23:41 +0800 Subject: [PATCH 16/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9F=BA=E5=BA=A7image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/samples/ci/dynamic-stock-batch-deployment.yaml | 2 +- .../config/samples/ci/dynamic-stock-deployment.yaml | 2 +- module-controller/config/samples/dynamic-stock-deployment.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml index d8d99f8d4..05885f61a 100644 --- a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 ports: - containerPort: 8080 - containerPort: 1238 diff --git a/module-controller/config/samples/ci/dynamic-stock-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-deployment.yaml index c93c805ef..fc69f0705 100644 --- a/module-controller/config/samples/ci/dynamic-stock-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 ports: - containerPort: 8080 - containerPort: 1238 diff --git a/module-controller/config/samples/dynamic-stock-deployment.yaml b/module-controller/config/samples/dynamic-stock-deployment.yaml index c93c805ef..fc69f0705 100644 --- a/module-controller/config/samples/dynamic-stock-deployment.yaml +++ b/module-controller/config/samples/dynamic-stock-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 ports: - containerPort: 8080 - containerPort: 1238 From 0269119c707b16d84159890a76f8e941f78349a6 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Thu, 23 Nov 2023 09:11:58 +0800 Subject: [PATCH 17/28] =?UTF-8?q?=E6=B7=BB=E5=8A=A0log=20pod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...module_controller_ci_build_deploy_to_aliyun.yml | 14 +++----------- .../samples/ci/dynamic-stock-batch-deployment.yaml | 2 +- .../samples/ci/dynamic-stock-deployment.yaml | 2 +- .../config/samples/dynamic-stock-deployment.yaml | 2 +- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml index ca4aa7929..c8aaf32a9 100644 --- a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml @@ -102,20 +102,12 @@ jobs: run: | kubectl describe pod - - name: delete base pod - run: | - podname=$(kubectl get pod -l app=dynamic-stock -o name | cut -d/ -f2) - kubectl delete -n default pod $podname - - run: sleep 10 - - name: get pod + - name: log base pod run: | - kubectl get pod - - - name: describe pod - run: | - kubectl describe pod + podname=$(kubectl get pod -l app=dynamic-stock -o name | cut -d/ -f2) + minikube logs $podname - name: wait base pod available run: | diff --git a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml index 05885f61a..d8d99f8d4 100644 --- a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 ports: - containerPort: 8080 - containerPort: 1238 diff --git a/module-controller/config/samples/ci/dynamic-stock-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-deployment.yaml index fc69f0705..c93c805ef 100644 --- a/module-controller/config/samples/ci/dynamic-stock-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 ports: - containerPort: 8080 - containerPort: 1238 diff --git a/module-controller/config/samples/dynamic-stock-deployment.yaml b/module-controller/config/samples/dynamic-stock-deployment.yaml index fc69f0705..c93c805ef 100644 --- a/module-controller/config/samples/dynamic-stock-deployment.yaml +++ b/module-controller/config/samples/dynamic-stock-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 ports: - containerPort: 8080 - containerPort: 1238 From ba417048210164e738f18572e938f30045aacb47 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 08:59:54 +0800 Subject: [PATCH 18/28] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=86=85=E6=A8=A1=E5=9D=97name=E3=80=81version=E3=80=81url?= =?UTF-8?q?=E4=B8=BA=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_controller_ci_build_batch_deploy_to_aliyun.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index c1525d41a..779e8c6f4 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -291,6 +291,6 @@ jobs: - name: check module run: | - podname=$(kubectl get pod -l app=dynamic-stock -o name) - logcount=(kubectl exec -it $podname -- sh -c 'grep "dynamic-provider:1.0.0 started" logs/stock-mng/sofa-ark/*.log' | wc -l) - echo $logcount + for podname=$(kubectl get pod -l app=dynamic-stock -o name); do + echo kubectl exec -it &podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' | wc -l + exit 0 \ No newline at end of file From 4c1e120049007d0fde9883f8302b4c438774f064 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 09:05:28 +0800 Subject: [PATCH 19/28] fix image --- .../config/samples/ci/dynamic-stock-batch-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml index d8d99f8d4..05885f61a 100644 --- a/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml +++ b/module-controller/config/samples/ci/dynamic-stock-batch-deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: dynamic-stock-container - image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1.1 + image: serverless-registry.cn-shanghai.cr.aliyuncs.com/opensource/test/dynamic-stock:v0.1 ports: - containerPort: 8080 - containerPort: 1238 From f5f2f712137872d667f5b3dad387ef6eb1b793de Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 09:13:24 +0800 Subject: [PATCH 20/28] fix image --- .../module_controller_ci_build_batch_deploy_to_aliyun.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 779e8c6f4..11f8d903a 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -292,5 +292,6 @@ jobs: - name: check module run: | for podname=$(kubectl get pod -l app=dynamic-stock -o name); do - echo kubectl exec -it &podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' | wc -l + kubectl exec -it &podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' + done exit 0 \ No newline at end of file From 341015c0b87ca106efc583ce57b988602fb102d2 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 09:37:26 +0800 Subject: [PATCH 21/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_controller_ci_build_batch_deploy_to_aliyun.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 11f8d903a..36cd255cc 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -292,6 +292,6 @@ jobs: - name: check module run: | for podname=$(kubectl get pod -l app=dynamic-stock -o name); do - kubectl exec -it &podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' + kubectl exec -it $podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' done exit 0 \ No newline at end of file From a4a7900ceaf1fe1ff3a8f8d38910384d04174c9d Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 09:45:32 +0800 Subject: [PATCH 22/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 42 +++++++++++++++++-- ...e_controller_ci_build_deploy_to_aliyun.yml | 29 ++++++++++--- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 36cd255cc..1bc927591 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -291,7 +291,41 @@ jobs: - name: check module run: | - for podname=$(kubectl get pod -l app=dynamic-stock -o name); do - kubectl exec -it $podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' - done - exit 0 \ No newline at end of file + label_selector="app=dynamic-stock" + max_attempts=10 + timeout=300 + interval=30 + + for ((i=0; i<$max_attempts; i++)); do + # 获取满足标签选择器条件的所有Pod + podnames=($(kubectl get pods -l $label_selector -o jsonpath='{.items[*].metadata.name}')) + + # 初始化一个变量,用于检测是否所有Pod都满足条件 + all_pods_condition_met=true + + # 遍历所有Pod进行日志检索 + for podname in "${podnames[@]}"; do + log_entry=$(kubectl exec -it $podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' 2>/dev/null) + + # 如果没有找到日志条目,则将标志设置为false + if [ -z "$log_entry" ]; then + all_pods_condition_met=false + break + fi + done + + # 如果所有Pod都满足条件,则退出循环 + if $all_pods_condition_met; then + echo "所有Pod都满足条件。" + break + fi + + # 如果这不是最后一次尝试,则等待一段时间后继续 + if [ $i -lt $((max_attempts-1)) ]; then + echo "有些Pod未满足条件。等待 $interval 秒后进行下一次尝试。" + sleep $interval + else + # 如果是最后一次尝试,则输出超时消息 + echo "已达到最大尝试次数。有些Pod未满足条件。" + fi + done \ No newline at end of file diff --git a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml index 791ff492a..db21e3cb1 100644 --- a/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_deploy_to_aliyun.yml @@ -381,11 +381,30 @@ jobs: - name: delete pod then check module run: | podname=$(kubectl get pod -l app=dynamic-stock -o name) - kubectl exec -it $podname -- sh -c 'ls -al' - kubectl exec -it $podname -- sh -c 'ls -al ~/' - kubectl exec -it $podname -- sh -c 'ls -al ~/logs' - kubectl exec -it $podname -- sh -c 'ls -al ~/logs/sofa-ark' - kubectl exec -it $podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' + max_attempts=10 + timeout=300 + interval=30 + + for ((i=0; i<$max_attempts; i++)); do + # 执行您的日志检索命令 + log_entry=$(kubectl exec -it $podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' 2>/dev/null) + + # 如果找到了日志条目,则退出循环 + if [ -n "$log_entry" ]; then + echo "找到日志条目。" + break + fi + + # 如果这不是最后一次尝试,则等待一段时间后继续 + if [ $i -lt $((max_attempts-1)) ]; then + echo "未找到日志条目。等待 $interval 秒后进行下一次尝试。" + sleep $interval + else + # 如果是最后一次尝试,则输出超时消息 + echo "已达到最大尝试次数。未找到日志条目。" + fi + done + - name: scaledown module then delete deployment run: From 1a0c7008eaa41165d96e66262af78b98f82833c9 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 10:03:57 +0800 Subject: [PATCH 23/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 1bc927591..741da6fae 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -289,7 +289,7 @@ jobs: exit 0 done - - name: check module + - name: batch release successfully then check module install run: | label_selector="app=dynamic-stock" max_attempts=10 @@ -328,4 +328,22 @@ jobs: # 如果是最后一次尝试,则输出超时消息 echo "已达到最大尝试次数。有些Pod未满足条件。" fi - done \ No newline at end of file + done + + - name: batch scaledown + run: | + kubectl apply -f config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml + + - run: sleep 15 + + - name: get module + run: | + kubectl get module -oyaml + + - name: exist module + run: | + moduleCount=$(kubectl get module | wc -l) + if [[ $moduleCount -ge 2 ]]; then + echo "缩容失败" + exit 1 + fi \ No newline at end of file From 95d730efae73d24e6b8157e3f1e988723cea3ea3 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 11:07:36 +0800 Subject: [PATCH 24/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 121 +++++++++++++++++- 1 file changed, 116 insertions(+), 5 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 741da6fae..5f4da2fa2 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -336,14 +336,125 @@ jobs: - run: sleep 15 - - name: get module + - name: exist module run: | - kubectl get module -oyaml + moduleCount=$(kubectl get module | wc -l) + echo $moduleCount + if [[ $moduleCount -lt 3 ]]; then + echo "缩容失败" + exit 1 + fi - - name: exist module + - name: check moduledeployment pause then confirm + run: | + # 定义要等待的资源名称和字段值 + moduledeploymentname=$(kubectl get moduledeployment -o name) + desired_field_value=true + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件,执行分组确认" + kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - name: exist module less then 2 run: | moduleCount=$(kubectl get module | wc -l) - if [[ $moduleCount -ge 2 ]]; then + echo $moduleCount + if [[ $moduleCount -lt 2 ]]; then echo "缩容失败" exit 1 - fi \ No newline at end of file + fi + + - name: check moduledeployment pause then confirm + run: | + # 定义要等待的资源名称和字段值 + moduledeploymentname=$(kubectl get moduledeployment -o name) + desired_field_value=true + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件,执行分组确认" + kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - name: exist module less then 1 + run: | + moduleCount=$(kubectl get module | wc -l) + echo $moduleCount + if [[ $moduleCount -lt 1 ]]; then + echo "缩容失败" + exit 1 + fi + + - name: check moduledeployment pause then confirm + run: | + # 定义要等待的资源名称和字段值 + moduledeploymentname=$(kubectl get moduledeployment -o name) + desired_field_value=true + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件,执行分组确认" + kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done \ No newline at end of file From 3b8c6496e17483b592301e2a9fb6a9c3111818b9 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 11:14:45 +0800 Subject: [PATCH 25/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 74 ++++++++----------- 1 file changed, 29 insertions(+), 45 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 5f4da2fa2..72839701f 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -7,16 +7,16 @@ on: - master paths: - 'module-controller/**' - + pull_request: branches: - master paths: - 'module-controller/**' - + # enable manually running the workflow workflow_dispatch: - + env: CGO_ENABLED: 0 GOOS: linux @@ -26,7 +26,7 @@ env: MODULE_CONTROLLER_IMAGE_PATH: opensource/test/module-controller INTEGRATION_TESTS_IMAGE_PATH: opensource/test/module-controller-integration-tests POD_NAMESPACE: default - + defaults: run: working-directory: module-controller @@ -270,12 +270,12 @@ jobs: echo "等待超时" exit 1 fi - + # 获取所有的资源对象名,并循环处理 for modulename in $(kubectl get $moduletype -o name); do # 使用 kubectl get 命令获取每个资源对象的详细信息,并提取自定义字段的值 field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers) - + # 检查字段值是否满足期望 if [ "$field_value" != "$desired_field_value" ]; then echo "等待字段值满足条件..." @@ -299,27 +299,27 @@ jobs: for ((i=0; i<$max_attempts; i++)); do # 获取满足标签选择器条件的所有Pod podnames=($(kubectl get pods -l $label_selector -o jsonpath='{.items[*].metadata.name}')) - + # 初始化一个变量,用于检测是否所有Pod都满足条件 all_pods_condition_met=true - + # 遍历所有Pod进行日志检索 for podname in "${podnames[@]}"; do log_entry=$(kubectl exec -it $podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' 2>/dev/null) - + # 如果没有找到日志条目,则将标志设置为false if [ -z "$log_entry" ]; then all_pods_condition_met=false break fi done - + # 如果所有Pod都满足条件,则退出循环 if $all_pods_condition_met; then echo "所有Pod都满足条件。" break fi - + # 如果这不是最后一次尝试,则等待一段时间后继续 if [ $i -lt $((max_attempts-1)) ]; then echo "有些Pod未满足条件。等待 $interval 秒后进行下一次尝试。" @@ -336,6 +336,10 @@ jobs: - run: sleep 15 + - name: exist module + run: | + kubectl get module + - name: exist module run: | moduleCount=$(kubectl get module | wc -l) @@ -377,6 +381,12 @@ jobs: fi done + - run: sleep 15 + + - name: exist module + run: | + kubectl get module + - name: exist module less then 2 run: | moduleCount=$(kubectl get module | wc -l) @@ -416,7 +426,13 @@ jobs: echo "等待字段值满足条件..." sleep 5 # 等待一段时间后再次检查 fi - done + done + + - run: sleep 15 + + - name: exist module + run: | + kubectl get module - name: exist module less then 1 run: | @@ -425,36 +441,4 @@ jobs: if [[ $moduleCount -lt 1 ]]; then echo "缩容失败" exit 1 - fi - - - name: check moduledeployment pause then confirm - run: | - # 定义要等待的资源名称和字段值 - moduledeploymentname=$(kubectl get moduledeployment -o name) - desired_field_value=true - - # 定义等待的超时时间(以秒为单位) - timeout_seconds=300 - - start_time=$(date +%s) - end_time=$((start_time + timeout_seconds)) - - while true; do - current_time=$(date +%s) - if [ $current_time -gt $end_time ]; then - echo "等待超时" - exit 1 - fi - - # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 - field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) - - if [ "$field_value" == "$desired_field_value" ]; then - echo "字段值已满足条件,执行分组确认" - kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge - exit 0 - else - echo "等待字段值满足条件..." - sleep 5 # 等待一段时间后再次检查 - fi - done \ No newline at end of file + fi \ No newline at end of file From b5e0c01803d3cdeff767b3919655eb8890784403 Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 11:22:25 +0800 Subject: [PATCH 26/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module_controller_ci_build_batch_deploy_to_aliyun.yml | 6 +++--- ..._v1alpha1_moduledeployment_batch_provider_scaledown.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index 72839701f..e4e7fcae4 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -344,7 +344,7 @@ jobs: run: | moduleCount=$(kubectl get module | wc -l) echo $moduleCount - if [[ $moduleCount -lt 3 ]]; then + if [[ $moduleCount -gt 3 ]]; then echo "缩容失败" exit 1 fi @@ -391,7 +391,7 @@ jobs: run: | moduleCount=$(kubectl get module | wc -l) echo $moduleCount - if [[ $moduleCount -lt 2 ]]; then + if [[ $moduleCount -gt 2 ]]; then echo "缩容失败" exit 1 fi @@ -438,7 +438,7 @@ jobs: run: | moduleCount=$(kubectl get module | wc -l) echo $moduleCount - if [[ $moduleCount -lt 1 ]]; then + if [[ $moduleCount -ge 1 ]]; then echo "缩容失败" exit 1 fi \ No newline at end of file diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml index bb426dc9f..bf921acf5 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml @@ -21,7 +21,7 @@ spec: needConfirm: true grayTimeBetweenBatchSeconds: 120 useBeta: false - batchCount: 2 + batchCount: 3 upgradePolicy: install_then_uninstall schedulingStrategy: schedulingPolicy: scatter From 0ae0288a45df30672d068dd6a1ca6ac835655f9e Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 11:36:20 +0800 Subject: [PATCH 27/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...roller_ci_build_batch_deploy_to_aliyun.yml | 260 +++++++++++++++++- 1 file changed, 257 insertions(+), 3 deletions(-) diff --git a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml index e4e7fcae4..0a7039be2 100644 --- a/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml +++ b/.github/workflows/module_controller_ci_build_batch_deploy_to_aliyun.yml @@ -245,7 +245,7 @@ jobs: run: | kubectl get module - - name: exist module more then 1 + - name: exist module more then 2 run: | moduleCount=$(kubectl get module | wc -l) if [[ $moduleCount -lt 3 ]]; then @@ -430,7 +430,7 @@ jobs: - run: sleep 15 - - name: exist module + - name: not exist module run: | kubectl get module @@ -441,4 +441,258 @@ jobs: if [[ $moduleCount -ge 1 ]]; then echo "缩容失败" exit 1 - fi \ No newline at end of file + fi + + - name: batch scaleup + run: | + kubectl apply -f config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml + + - run: sleep 15 + + - name: get module + run: | + kubectl get module -oyaml + + - name: exist module + run: | + moduleCount=$(kubectl get module | wc -l) + if [[ $moduleCount -lt 1 ]]; then + echo "ERROR: 不存在module" + exit 1 + fi + + - name: scaleup then wait module available + run: | + # 定义要等待的资源名称和字段值 + modulename=$(kubectl get module -o name) + desired_field_value="Available" + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件" + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - name: check moduledeployment pause + run: | + # 定义要等待的资源名称和字段值 + moduledeploymentname=$(kubectl get moduledeployment -o name) + desired_field_value=true + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件,执行分组确认" + kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - run: sleep 15 + + - name: get module + run: | + kubectl get module + + - name: exist module more then 1 + run: | + moduleCount=$(kubectl get module | wc -l) + if [[ $moduleCount -lt 2 ]]; then + echo "ERROR: 不存在module" + exit 1 + fi + + - name: wait module available + run: | + # 定义要等待的资源类型和期望的字段值 + moduletype="module" + desired_field_value="Available" + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 获取所有的资源对象名,并循环处理 + for modulename in $(kubectl get $moduletype -o name); do + # 使用 kubectl get 命令获取每个资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers) + + # 检查字段值是否满足期望 + if [ "$field_value" != "$desired_field_value" ]; then + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + continue 2 # 如果字段值未满足,则跳出循环,进入下一轮等待 + fi + done + + # 如果所有资源对象的字段值都满足期望,则结束脚本 + echo "字段值已满足条件" + exit 0 + done + + - name: scaleup check moduledeployment pause + run: | + # 定义要等待的资源名称和字段值 + moduledeploymentname=$(kubectl get moduledeployment -o name) + desired_field_value=true + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 使用 kubectl get 命令获取资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $moduledeploymentname -o custom-columns=PAUSE:.spec.pause --no-headers) + + if [ "$field_value" == "$desired_field_value" ]; then + echo "字段值已满足条件,执行分组确认" + kubectl patch $moduledeploymentname -p '{"spec":{"pause":false}}' --type=merge + exit 0 + else + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + fi + done + + - name: get module + run: | + kubectl get module + + - name: exist module more then 2 + run: | + moduleCount=$(kubectl get module | wc -l) + if [[ $moduleCount -lt 3 ]]; then + echo "ERROR: 不存在module" + exit 1 + fi + + - name: wait module available + run: | + # 定义要等待的资源类型和期望的字段值 + moduletype="module" + desired_field_value="Available" + + # 定义等待的超时时间(以秒为单位) + timeout_seconds=300 + + start_time=$(date +%s) + end_time=$((start_time + timeout_seconds)) + + while true; do + current_time=$(date +%s) + if [ $current_time -gt $end_time ]; then + echo "等待超时" + exit 1 + fi + + # 获取所有的资源对象名,并循环处理 + for modulename in $(kubectl get $moduletype -o name); do + # 使用 kubectl get 命令获取每个资源对象的详细信息,并提取自定义字段的值 + field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers) + + # 检查字段值是否满足期望 + if [ "$field_value" != "$desired_field_value" ]; then + echo "等待字段值满足条件..." + sleep 5 # 等待一段时间后再次检查 + continue 2 # 如果字段值未满足,则跳出循环,进入下一轮等待 + fi + done + + # 如果所有资源对象的字段值都满足期望,则结束脚本 + echo "字段值已满足条件" + exit 0 + done + + - name: batch scaleup successfully then check module install + run: | + label_selector="app=dynamic-stock" + max_attempts=10 + timeout=300 + interval=30 + + for ((i=0; i<$max_attempts; i++)); do + # 获取满足标签选择器条件的所有Pod + podnames=($(kubectl get pods -l $label_selector -o jsonpath='{.items[*].metadata.name}')) + + # 初始化一个变量,用于检测是否所有Pod都满足条件 + all_pods_condition_met=true + + # 遍历所有Pod进行日志检索 + for podname in "${podnames[@]}"; do + log_entry=$(kubectl exec -it $podname -- sh -c 'grep "Install Biz: provider:1.0.2 success" ~/logs/sofa-ark/*.log' | wc -l) + + # 如果没有找到日志条目,则将标志设置为false + if [ $log_entry -lt 2 ]; then + all_pods_condition_met=false + break + fi + done + + # 如果所有Pod都满足条件,则退出循环 + if $all_pods_condition_met; then + echo "所有Pod都满足条件。" + break + fi + + # 如果这不是最后一次尝试,则等待一段时间后继续 + if [ $i -lt $((max_attempts-1)) ]; then + echo "有些Pod未满足条件。等待 $interval 秒后进行下一次尝试。" + sleep $interval + else + # 如果是最后一次尝试,则输出超时消息 + echo "已达到最大尝试次数。有些Pod未满足条件。" + fi + done From 2a96bef8f879ac8bd87913039570afe993fb872c Mon Sep 17 00:00:00 2001 From: LiuLiqi <837397251@qq.com> Date: Fri, 24 Nov 2023 11:53:12 +0800 Subject: [PATCH 28/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e-deployment_v1alpha1_moduledeployment_batch_provider.yaml | 4 ++-- ...nt_v1alpha1_moduledeployment_batch_provider_scaledown.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml index 5b45151e2..482009f3f 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider.yaml @@ -13,8 +13,8 @@ spec: template: spec: module: - name: dynamic-provider - version: '1.0.0' + name: provider + version: '1.0.2' url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.2-ark-biz.jar replicas: 3 operationStrategy: diff --git a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml index bf921acf5..8449eff25 100644 --- a/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml +++ b/module-controller/config/samples/ci/module-deployment_v1alpha1_moduledeployment_batch_provider_scaledown.yaml @@ -13,8 +13,8 @@ spec: template: spec: module: - name: dynamic-provider - version: '1.0.0' + name: provider + version: '1.0.2' url: http://serverless-opensource.oss-cn-shanghai.aliyuncs.com/module-packages/stable/dynamic-provider-1.0.2-ark-biz.jar replicas: 0 operationStrategy: