diff --git a/.github/workflows/auto-upgrade-ci.yaml b/.github/workflows/auto-upgrade-ci.yaml index 2bfb94b20e..c193dd819d 100644 --- a/.github/workflows/auto-upgrade-ci.yaml +++ b/.github/workflows/auto-upgrade-ci.yaml @@ -9,7 +9,11 @@ env: on: schedule: - cron: "0 20 * * *" - + workflow_call: + inputs: + dest_tag: + required: true + type: string workflow_dispatch: inputs: ref: @@ -36,6 +40,7 @@ jobs: outputs: ref: ${{ env.RUN_REF }} old_version: ${{ env.OLD_VERSION }} + new_version: ${{ env.NEW_VERSION }} e2e_enabled: ${{ env.RUN_E2E_ENABLED }} steps: @@ -46,16 +51,35 @@ jobs: echo "call by self workflow_dispatch" echo "RUN_TAG=${{ github.event.inputs.ref }}" >> $GITHUB_ENV echo "OLD_VERSION=${{ github.event.inputs.old_version }}" >> $GITHUB_ENV + echo "NEW_VERSION=${{ github.event.inputs.ref }}" >> $GITHUB_ENV if ${{ github.event.inputs.e2e_enabled == 'true' }}; then echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV else echo "RUN_E2E_ENABLED=false" >> $GITHUB_ENV fi + elif ${{ inputs.dest_tag != '' }}; then + echo "call by workflow_call" + echo "RUN_TAG=${{ inputs.dest_tag }}" >> $GITHUB_ENV + echo "NEW_VERSION=${{ inputs.dest_tag }}" >> $GITHUB_ENV + echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV + YBranchName=` grep -Eo "v[0-9]+\.[0-9]+" <<< "${{ inputs.dest_tag }}" ` + # Get the previous minor version of version y + LATEST_RELEASE_VERISON=$(curl -s https://api.github.com/repos/spidernet-io/spiderpool/releases | grep '"tag_name":' | grep -Eo "v([0-9]+\.[0-9]+\.[0-9])" | grep ${YBranchName} | sort -r | head -n 1) + if [ -z "${LATEST_RELEASE_VERISON}" ]; then + echo "No version has been released to your version branch. You may have released a new x.y version." + LATEST_RELEASE_VERISON=$(curl -s https://api.github.com/repos/spidernet-io/spiderpool/releases | grep '"tag_name":' | grep -Eo "v([0-9]+\.[0-9]+\.[0-9])" | sort -r | head -n 1) + echo "LATEST_RELEASE_VERISON: ${LATEST_RELEASE_VERISON} " + echo "OLD_VERSION=${LATEST_RELEASE_VERISON}" >> $GITHUB_ENV + else + echo "LATEST_RELEASE_VERISON: ${LATEST_RELEASE_VERISON} " + echo "OLD_VERSION=${LATEST_RELEASE_VERISON}" >> $GITHUB_ENV + fi else # schedule event # use main sha for ci image tag echo "trigger by schedule" echo "RUN_TAG=main" >> $GITHUB_ENV + echo "NEW_VERSION=main" >> $GITHUB_ENV LATEST_RELEASE_VERISON=$(curl -s https://api.github.com/repos/spidernet-io/spiderpool/releases | grep '"tag_name":' | grep -Eo "v([0-9]+\.[0-9]+\.[0-9])" | sort -r | head -n 1) echo "OLD_VERSION=${LATEST_RELEASE_VERISON}" >> $GITHUB_ENV echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV @@ -153,7 +177,7 @@ jobs: echo "restart docker before trying again" systemctl restart docker command: | - make e2e_init_calico -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \ + make e2e_init_underlay -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \ -e E2E_SPIDERPOOL_TAG=${{ needs.get_ref.outputs.old_version }} \ -e PYROSCOPE_LOCAL_PORT="" @@ -168,7 +192,7 @@ jobs: ref: ${{ needs.get_ref.outputs.ref }} fetch-depth: 0 - - name: Move kubeconfig from oldVersion ${{ needs.get_ref.outputs.old_version }} to the upgradeVersion ${{ needs.get_ref.outputs.ref }} + - name: Move kubeconfig from oldVersion ${{ needs.get_ref.outputs.old_version }} to the upgradeVersion ${{ needs.get_ref.outputs.new_version }} run: | mkdir -p ${{ env.KUBECONFIG_PATH }}/${{ env.E2E_CLUSTER_NAME }}/.kube/ cp -r /tmp/config ${{ env.KUBECONFIG_PATH }}/${{ env.E2E_CLUSTER_NAME }}/.kube/config @@ -202,6 +226,12 @@ jobs: make upgrade_e2e_spiderpool -e E2E_SPIDERPOOL_TAG=${{ needs.call_build_ci_image.outputs.imageTag }} \ -e SPIDERPOOL_AGENT_IMAGE_NAME=spiderpool-agent-race \ -e SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race \ + -e INSTALL_KUBEVIRT=true \ + -e INSTALL_KRUISE=true \ + -e INSTALL_KDOCTOR=true \ + -e INSTALL_OVS=${INSTALL_OVS_VALUE} \ + -e INSTALL_RDMA=true \ + -e INSTALL_SRIOV=true - name: Run e2e Test on ${{ needs.get_ref.outputs.ref }} id: run_e2e @@ -209,43 +239,32 @@ jobs: if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' }} run: | RESULT=0 - export KUBECONFIG=${{ env.KUBECONFIG_PATH }}/${{ env.E2E_CLUSTER_NAME }}/.kube/config - export DEBUG_ENV_PATH=${{ env.KUBECONFIG_PATH }}/../scripts/debugEnv.sh - RESULT=$(kubectl get po -A | grep "spiderpool" | grep -Ev "Running|Completed" | wc -l ) - if ((RESULT!=0)) ; then - sleep 120 - RESULT=$(kubectl get po -A | grep "spiderpool" | grep -Ev "Running|Completed" | wc -l ) - fi - kubectl get po -A | grep "spiderpool" - kubectl get network-attachment-definitions.k8s.cni.cncf.io -A + make e2e_test_underlay -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \ + -e E2E_TIMEOUT=${{ env.E2E_TIME_OUT }} \ + -e E2E_IP_FAMILY=dual || RESULT=1 if ((RESULT==0)) ; then - kubectl get po -l app=test-pod -oyaml - echo "after the upgrade is completed, restart the Pod. The Pod will run normally on the new version." - kubectl delete po -l app=test-pod - if kubectl wait --for=condition=ready -l app=test-pod --timeout=300s pod; then - kubectl get po -l app=test-pod -owide - kubectl get po -l app=test-pod -oyaml - echo "RUN_E2E_PASS=true" >> $GITHUB_ENV - else - kubectl get po -l app=test-pod -owide - kubectl describe po -l app=test-pod - KIND_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} - ./${DEBUG_ENV_PATH} ${KUBECONFIG} "detail" - echo "RUN_E2E_PASS=false" >> $GITHUB_ENV - fi + echo "RUN_E2E_PASS=true" >> $GITHUB_ENV else - KIND_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} - ./${DEBUG_ENV_PATH} ${KUBECONFIG} "detail" - kubectl describe po -n kube-system -l app.kubernetes.io/instance=spiderpool - kubectl logs -n kube-system -l app.kubernetes.io/instance=spiderpool echo "RUN_E2E_PASS=false" >> $GITHUB_ENV fi + if [ -f "test/e2edebugLog" ] ; then + echo "UPLOAD_E2E_LOG=true" >> $GITHUB_ENV + else + echo "UPLOAD_E2E_LOG=false" >> $GITHUB_ENV + fi + if [ -f "./e2ereport.json" ] ; then + echo "error, did not find e2e report" + echo "UPLOAD_E2E_REPORT=true" >> $GITHUB_ENV + else + echo "UPLOAD_E2E_REPORT=false" >> $GITHUB_ENV + fi + - name: Upload e2e log if: ${{ needs.get_ref.outputs.e2e_enabled == 'true' }} uses: actions/upload-artifact@v3.1.3 with: - name: ${{ needs.get_ref.outputs.old_version }}-debuglog.txt + name: ${{ needs.get_ref.outputs.old_version }}-to-${{ needs.get_ref.outputs.new_version }}-debuglog.txt path: test/e2edebugLog.txt retention-days: 7 @@ -253,7 +272,7 @@ jobs: if: ${{ env.UPLOAD_E2E_REPORT == 'true' }} uses: actions/upload-artifact@v3.1.3 with: - name: ${{ needs.get_ref.outputs.old_version }}-e2ereport.json + name: ${{ needs.get_ref.outputs.old_version }}-to-${{ needs.get_ref.outputs.new_version }}-e2ereport.json path: e2ereport.json retention-days: 1 diff --git a/.github/workflows/auto-version-release.yaml b/.github/workflows/auto-version-release.yaml index 3824818459..93be73415b 100644 --- a/.github/workflows/auto-version-release.yaml +++ b/.github/workflows/auto-version-release.yaml @@ -117,11 +117,18 @@ jobs: dest_tag: ${{ needs.get-tag.outputs.tag }} secrets: inherit + call-upgrade-test: + needs: [build-release-image, get-tag] + uses: ./.github/workflows/auto-upgrade-ci.yaml + with: + dest_tag: ${{ needs.get-tag.outputs.tag }} + secrets: inherit + update-release-version: needs: [build-release-image, get-tag] uses: ./.github/workflows/call-release-version.yaml with: - dest_tag: ${{ needs.get-tag.outputs.tag }} + ref: ${{ needs.get-tag.outputs.tag }} secrets: inherit create-release: