Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug ci x #189

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 76 additions & 48 deletions .github/workflows/auto-upgrade-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
e2e_enabled: ${{ env.RUN_E2E_ENABLED }}
run_upgrade_enabled: ${{ env.RUN_UPGRADE_ENABLED }}
skip_create_pr: ${{ env.SKIP_CREATE_PR }}
build_old_image_tag: ${{ env.BUILD_OLD_IMAGE_TAG }}
steps:
- name: Check Code Changes
uses: dorny/[email protected]
Expand Down Expand Up @@ -79,6 +80,7 @@ jobs:
echo "OLD_VERSION=${{ github.event.inputs.old_version }}" >> $GITHUB_ENV
echo "NEW_VERSION=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
echo "SKIP_CREATE_PR=true" >> $GITHUB_ENV
echo "BUILD_OLD_IMAGE_TAG=false" >> $GITHUB_ENV
if ${{ github.event.inputs.e2e_enabled == 'true' }}; then
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
else
Expand All @@ -90,6 +92,7 @@ jobs:
echo "NEW_VERSION=${{ inputs.dest_tag }}" >> $GITHUB_ENV
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
echo "SKIP_CREATE_PR=true" >> $GITHUB_ENV
echo "BUILD_OLD_IMAGE_TAG=false" >> $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)
Expand All @@ -107,15 +110,19 @@ jobs:
echo "RUN_TAG=${{ github.sha }}" >> $GITHUB_ENV
echo "NEW_VERSION=${{ github.sha }}" >> $GITHUB_ENV
# for PR scenarios, the latest version of the main branch will be used as old-version
echo "OLD_VERSION=main" >> $GITHUB_ENV
echo "OLD_VERSION: ${{ github.event.pull_request.base.sha }}"
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
echo "SKIP_CREATE_PR=false" >> $GITHUB_ENV
echo "BUILD_OLD_IMAGE_TAG=true" >> $GITHUB_ENV
elif ${{ github.event_name == 'pull_request_target' }} ; then
echo "trigger by pull_request_target"
echo "RUN_TAG=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "NEW_VERSION=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
# for PR scenarios, the latest version of the main branch will be used as old-version
echo "OLD_VERSION=main" >> $GITHUB_ENV
echo "BUILD_OLD_IMAGE_TAG=true" >> $GITHUB_ENV
echo "OLD_VERSION=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
echo "OLD_VERSION: ${{ github.event.pull_request.base.sha }}"
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
echo "SKIP_CREATE_PR=true" >> $GITHUB_ENV
if ${{ steps.filter_pr.outputs.run_upgrade == 'true' }} ; then
echo "RUN_UPGRADE_ENABLED=true" >> $GITHUB_ENV
Expand All @@ -128,6 +135,7 @@ jobs:
echo "trigger by schedule"
echo "RUN_TAG=main" >> $GITHUB_ENV
echo "NEW_VERSION=main" >> $GITHUB_ENV
echo "BUILD_OLD_IMAGE_TAG=false" >> $GITHUB_ENV
LATEST_RELEASE_VERISON=$(curl -s https://api.github.com/repos/spidernet-io/spiderpool/releases | grep '"tag_name":' | sort -r | head -n 1)
rc_version=$(grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]' <<< ${LATEST_RELEASE_VERISON})
echo "SKIP_CREATE_PR=false" >> $GITHUB_ENV
Expand All @@ -154,34 +162,29 @@ jobs:
ref=$( git show -s --format='format:%H')
echo "RUN_REF=${ref}" >> $GITHUB_ENV

call_build_ci_image:
call_build_old_ci_image:
needs: [get_ref]
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }}
# get image:${{ needs.get_ref.outputs.ref }} and image-ci:${{ needs.get_ref.outputs.ref }}
uses: ./.github/workflows/build-image-ci.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
ref: ${{ needs.get_ref.outputs.old_version }}
push: false
imageTarName: old-image-tar
secrets: inherit

lint_chart_against_release_image:
needs: get_ref
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }}
uses: ./.github/workflows/call-lint-chart.yaml
with:
ref: ${{ needs.get_ref.outputs.ref }}
secrets: inherit

trivy_scan_images:
needs: [call_build_ci_image, get_ref]
call_build_new_ci_image:
needs: [get_ref]
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }}
uses: ./.github/workflows/trivy-scan-image.yaml
uses: ./.github/workflows/build-image-ci.yaml
with:
image_tag: ${{ needs.call_build_ci_image.outputs.imageTag }}
ref: ${{ needs.get_ref.outputs.ref }}
ref: ${{ needs.get_ref.outputs.new_version }}
push: false
imageTarName: new-image-tar
secrets: inherit

run_upgrade_tests_on_release_version:
needs: [call_build_ci_image, get_ref]
needs: [get_ref, call_build_old_ci_image, call_build_new_ci_image]
if: ${{ needs.get_ref.outputs.run_upgrade_enabled == 'true' }}
runs-on: ubuntu-latest
steps:
Expand All @@ -196,25 +199,12 @@ jobs:
docker-images: true
swap-storage: true

- name: Checkout code
uses: actions/checkout@v4
- name: Download old spiderpool-agent image
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }}
uses: actions/download-artifact@v3
with:
persist-credentials: false
ref: ${{ needs.get_ref.outputs.new_version }}

- name: Prepare
id: prepare
run: |
echo "ref: ${{ inputs.ref }} "
echo "===== image "
if ${{ needs.get_ref.outputs.old_version == 'main' }} ; then
echo "ci image tag: ghcr.io/${{ github.repository }}/spiderpool-controller:latest"
else
echo "ci image tag: ghcr.io/${{ github.repository }}/spiderpool-controller:${{ needs.get_ref.outputs.old_version }}"
fi
TMP=` date +%m%d%H%M%S `
E2E_CLUSTER_NAME="spiderpool${TMP}"
echo "E2E_CLUSTER_NAME=${E2E_CLUSTER_NAME}" >> $GITHUB_ENV
ref: ${{ needs.get_ref.outputs.old_version }}

- name: Setup Golang
uses: actions/setup-go@v5
Expand All @@ -230,6 +220,41 @@ jobs:
run: |
bash ./test/scripts/install-tools.sh

- name: Download old spiderpool-agent image
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }}
uses: actions/download-artifact@v3
with:
name: old-image-tar-spiderpool-agent
path: test/.download

- name: Download old spiderpool-controller image
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }}
uses: actions/download-artifact@v3
with:
name: old-image-tar-spiderpool-controller
path: test/.download

- name: Load Images
if: ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }}
run: |
TAR_FILES=` ls test/.download `
echo $TAR_FILES
for ITEM in $TAR_FILES ; do
IMAGE_NAME=${ITEM%*.tar}
echo ${IMAGE_NAME}
cat test/.download/${ITEM} | docker import - ${IMAGE_NAME}:${{ needs.call_build_old_ci_image.outputs.imageTag }}
done

- name: Prepare
id: prepare
run: |
echo "ref: ${{ inputs.ref }} "
echo "===== image "
echo "ci image tag: ghcr.io/${{ github.repository }}/spiderpool-controller:${{ needs.get_ref.outputs.old_version }}"
TMP=` date +%m%d%H%M%S `
E2E_CLUSTER_NAME="spiderpool${TMP}"
echo "E2E_CLUSTER_NAME=${E2E_CLUSTER_NAME}" >> $GITHUB_ENV

- name: Setup Kind Cluster on oldVersion ${{ needs.get_ref.outputs.old_version }}
uses: nick-invision/retry@v2
with:
Expand All @@ -242,13 +267,16 @@ jobs:
echo "restart docker before trying again"
systemctl restart docker
command: |
E2E_SPIDERPOOL_TAG=""
if ${{ needs.get_ref.outputs.old_version == 'main' }} ; then
E2E_SPIDERPOOL_TAG=latest
else
E2E_SPIDERPOOL_TAG=${{ needs.get_ref.outputs.old_version }}
E2E_SPIDERPOOL_TAG=${{ needs.get_ref.outputs.old_version }}
SPIDERPOOL_AGENT_IMAGE_NAME=""
SPIDERPOOL_CONTROLLER_IMAGE_NAME=""
if ${{ needs.get_ref.outputs.build_old_image_tag == 'true' }} ; then
SPIDERPOOL_AGENT_IMAGE_NAME=spiderpool-agent-race
SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race
fi
make e2e_init_underlay -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \
-e SPIDERPOOL_AGENT_IMAGE_NAME=${SPIDERPOOL_AGENT_IMAGE_NAME} \
-e SPIDERPOOL_CONTROLLER_IMAGE_NAME=${SPIDERPOOL_CONTROLLER_IMAGE_NAME} \
-e E2E_SPIDERPOOL_TAG=${E2E_SPIDERPOOL_TAG} \
-e PYROSCOPE_LOCAL_PORT="" \
-e INSTALL_KUBEVIRT=true \
Expand All @@ -265,24 +293,24 @@ jobs:
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ needs.get_ref.outputs.ref }}
ref: ${{ needs.get_ref.outputs.new_version }}
fetch-depth: 0

- 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

- name: Download spiderpool-agent image
- name: Download new spiderpool-agent image
uses: actions/download-artifact@v3
with:
name: image-tar-spiderpool-agent
name: new-image-tar-spiderpool-agent
path: test/.download

- name: Download spiderpool-controller image
- name: Download new spiderpool-controller image
uses: actions/download-artifact@v3
with:
name: image-tar-spiderpool-controller
name: new-image-tar-spiderpool-controller
path: test/.download

- name: Load Images
Expand All @@ -292,15 +320,15 @@ jobs:
for ITEM in $TAR_FILES ; do
IMAGE_NAME=${ITEM%*.tar}
echo ${IMAGE_NAME}
cat test/.download/${ITEM} | docker import - ${IMAGE_NAME}:${{ needs.call_build_ci_image.outputs.imageTag }}
cat test/.download/${ITEM} | docker import - ${IMAGE_NAME}:${{ needs.call_build_new_ci_image.outputs.imageTag }}
done

- name: Upgrade to version ${{ needs.get_ref.outputs.ref }}
id: upgrade
continue-on-error: true
run: |
make upgrade_e2e_spiderpool -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \
-e E2E_SPIDERPOOL_TAG=${{ needs.call_build_ci_image.outputs.imageTag }} \
-e E2E_SPIDERPOOL_TAG=${{ needs.call_build_new_ci_image.outputs.imageTag }} \
-e SPIDERPOOL_AGENT_IMAGE_NAME=spiderpool-agent-race \
-e SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race

Expand Down Expand Up @@ -358,7 +386,7 @@ jobs:

creat_issue:
runs-on: ubuntu-latest
needs: [run_upgrade_tests_on_release_version, trivy_scan_images, get_ref]
needs: [run_upgrade_tests_on_release_version, get_ref]
if: ${{ always() && needs.run_upgrade_tests_on_release_version.result == 'failure' && needs.get_ref.outputs.skip_create_pr == 'false' }}
steps:
- name: echo
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build-image-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ on:
push:
required: true
type: string
imageTarName:
required: false
type: string
default: "image-tar"
outputs:
imageTag:
description: "tag of image ci"
Expand Down Expand Up @@ -256,7 +260,7 @@ jobs:
- name: Upload artifact race image tar
uses: actions/[email protected]
with:
name: image-tar-${{ matrix.name }}
name: ${{ inputs.imageTarName }}-${{ matrix.name }}
path: /tmp/${{ matrix.name }}-race.tar
retention-days: 1

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ clean: clean_e2e
clean_e2e_spiderpool:
-$(QUIET) make -C test uninstall_spiderpool

.PHONY: upgrade_e2e_spiderpool
upgrade_e2e_spiderpool:
-$(QUIET) make -C test upgrade_spiderpool

.PHONY: codegen
codegen:
@echo "Generate k8s SDK with code-generator."
Expand Down
2 changes: 1 addition & 1 deletion Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CONTAINER_ENGINE?=docker

#----------build-image--------
SPIDERPOOL_REGISTER ?= ghcr.io
GIT_REPO ?= spidernet-io/spiderpool
GIT_REPO ?= ty-dc/spiderpool
SPIDERPOOL_AGENT_IMAGE_NAME := ${SPIDERPOOL_REGISTER}/${GIT_REPO}/spiderpool-agent
SPIDERPOOL_CONTROLLER_IMAGE_NAME := ${SPIDERPOOL_REGISTER}/${GIT_REPO}/spiderpool-controller
SPIDERPOOL_IMAGES := $(SPIDERPOOL_AGENT_IMAGE_NAME) ${SPIDERPOOL_CONTROLLER_IMAGE_NAME}
Expand Down
1 change: 0 additions & 1 deletion test/e2e/spidermultus/spidermultus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var _ = Describe("test spidermultus", Label("SpiderMultusConfig", "overlay"), fu
GinkgoWriter.Println("If the use case fails, the cleanup step will be skipped")
return
}

err := frame.DeleteNamespace(namespace)
Expect(err).NotTo(HaveOccurred(), "Failed to delete namespace %v")
})
Expand Down
Loading