Skip to content

Commit

Permalink
optimizate upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: tao.yang <[email protected]>
Signed-off-by: ty-dc <[email protected]>
  • Loading branch information
ty-dc committed May 27, 2024
1 parent b103d38 commit 30c54e5
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 16 deletions.
65 changes: 52 additions & 13 deletions .github/workflows/auto-upgrade-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ env:
on:
schedule:
- cron: "0 20 * * *"
pull_request_target:
types:
- opened
- synchronize
- reopened
workflow_call:
inputs:
dest_tag:
Expand Down Expand Up @@ -74,28 +79,53 @@ jobs:
echo "LATEST_RELEASE_VERISON: ${LATEST_RELEASE_VERISON} "
echo "OLD_VERSION=${LATEST_RELEASE_VERISON}" >> $GITHUB_ENV
fi
elif ${{ github.event_name == 'push' }} ; then
echo "trigger by push"
echo "RUN_TAG=${{ github.sha }}" >> $GITHUB_ENV
elif ${{ github.event_name == 'pull_request_target' }} ; then
echo "trigger by pull_request_target"
echo "RUN_TAG=${{ github.sha }}" >> $GITHUB_ENV
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
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})
if [ -z ${rc_version} ]; then
echo "the latest released version is not an 'rc: ${LATEST_RELEASE_VERISON}' version."
echo "OLD_VERSION=$(grep -Eo "v([0-9]+\.[0-9]+\.[0-9])" <<< ${LATEST_RELEASE_VERISON})" >> $GITHUB_ENV
else
echo "The latest released version is an 'rc: ${LATEST_RELEASE_VERISON}' version."
echo "OLD_VERSION=${rc_version}" >> $GITHUB_ENV
fi
echo "RUN_E2E_ENABLED=true" >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ env.RUN_TAG }}

- name: Result Ref
id: result
run: |
ref=$( git show -s --format='format:%H')
echo "RUN_REF=${ref}" >> $GITHUB_ENV
if ${{ github.event_name == 'push' }} ; then
echo "trigger by push"
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
elif ${{ github.event_name == 'pull_request_target' }} ; then
echo "trigger by pull_request_target"
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
fi
call_build_ci_image:
needs: [get_ref]
Expand Down Expand Up @@ -146,7 +176,11 @@ jobs:
run: |
echo "ref: ${{ inputs.ref }} "
echo "===== image "
echo "ci image tag: ghcr.io/${{ github.repository }}/spiderpool-controller:${{ needs.get_ref.outputs.old_version }}"
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
Expand Down Expand Up @@ -177,9 +211,20 @@ 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 }}
fi
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=""
-e E2E_SPIDERPOOL_TAG=${E2E_SPIDERPOOL_TAG} \
-e PYROSCOPE_LOCAL_PORT="" \
-e INSTALL_KUBEVIRT=true \
-e INSTALL_KRUISE=true \
-e INSTALL_KDOCTOR=true \
-e INSTALL_RDMA=true \
-e INSTALL_SRIOV=true
- name: backup kubeconfig from olderVersion ${{ needs.get_ref.outputs.old_version }}
run: |
Expand Down Expand Up @@ -225,14 +270,8 @@ jobs:
run: |
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
-e SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race
- name: Run e2e Test on ${{ needs.get_ref.outputs.ref }}
id: run_e2e
continue-on-error: true
Expand Down
13 changes: 13 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ helm_upgrade_spiderpool:
kubectl delete po -n $(RELEASE_NAMESPACE) spiderpool-init --kubeconfig $(E2E_KUBECONFIG) || true ;\
HELM_OPTION="";\
HELM_OPTION+=" --set spiderpoolController.replicas=1 " ; \
if [ "$(INSTALL_OVERLAY_CNI)" == "true" ]; then \
HELM_OPTION+=" --set multus.multusCNI.defaultCniCRName= " ; \
else \
HELM_OPTION+=" --set multus.multusCNI.defaultCniCRName=$(MULTUS_DEFAULT_CNI_VLAN0) " ; \
fi ; \
HELM_OPTION+=" --set spiderpoolAgent.image.registry="" \
--set spiderpoolAgent.image.repository=$(SPIDERPOOL_AGENT_IMAGE_NAME) \
--set spiderpoolAgent.image.tag=$(E2E_SPIDERPOOL_TAG) \
Expand All @@ -412,11 +417,19 @@ helm_upgrade_spiderpool:
--set spiderpoolInit.image.registry="" \
--set spiderpoolInit.image.repository=$(SPIDERPOOL_CONTROLLER_IMAGE_NAME) \
--set spiderpoolInit.image.tag=$(E2E_SPIDERPOOL_TAG) " \
--set multus.multusCNI.uninstall=false \
helm --kubeconfig $(E2E_KUBECONFIG) upgrade $(RELEASE_NAME) $(ROOT_DIR)/charts/spiderpool $${HELM_OPTION} \
-n $(RELEASE_NAMESPACE) ; \
cd $(ROOT_DIR)/charts/spiderpool/crds ; \
ls | grep '\.yaml$$' | xargs -I {} kubectl apply -f {} --kubeconfig $(E2E_KUBECONFIG) ; \
kubectl wait --for=condition=ready -l app.kubernetes.io/instance=spiderpool --timeout=300s pod -n kube-system --kubeconfig $(E2E_KUBECONFIG) || true; \
NODE_LIST=`docker ps | egrep "kindest/node.* $(E2E_CLUSTER_NAME)-(control|worker)" | awk '{print $$NF}'` ; \
for NODE in $${NODE_LIST} ; do \
docker exec $${NODE} rm -rf /etc/cni/net.d/00-multus.conf || true; \
docker exec $${NODE} rm -rf /etc/cni/net.d/multus.d || true; \
done; \
kubectl delete po -l app.kubernetes.io/component=spiderpool-agent -n kube-system --kubeconfig $(E2E_KUBECONFIG) || true; \
kubectl wait --for=condition=ready -l app.kubernetes.io/component=spiderpool-agent --timeout=300s pod -n kube-system --kubeconfig $(E2E_KUBECONFIG) || true;

.PHONY: clean
clean:
Expand Down
6 changes: 3 additions & 3 deletions test/scripts/debugEnv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,16 @@ elif [ "$TYPE"x == "detail"x ] ; then
kubectl get spidermultusconfig -A -o wide --kubeconfig ${E2E_KUBECONFIG}

echo ""
echo "--------- kubectl get spidermultusconfig -o json"
kubectl get spidermultusconfig -o json --kubeconfig ${E2E_KUBECONFIG}
echo "--------- kubectl get spidermultusconfig -A -o json"
kubectl get spidermultusconfig -A -o json --kubeconfig ${E2E_KUBECONFIG}

echo ""
echo "--------- kubectl get network-attachment-definitions.k8s.cni.cncf.io -A -o wide"
kubectl get network-attachment-definitions.k8s.cni.cncf.io -A -o wide --kubeconfig ${E2E_KUBECONFIG}

echo ""
echo "--------- kubectl get network-attachment-definitions.k8s.cni.cncf.io -A -o json"
kubectl get network-attachment-definitions.k8s.cni.cncf.io -o json --kubeconfig ${E2E_KUBECONFIG}
kubectl get network-attachment-definitions.k8s.cni.cncf.io -A -o json --kubeconfig ${E2E_KUBECONFIG}

echo ""
echo "--------- kubectl get configmaps -n kube-system spiderpool-conf -ojson"
Expand Down

0 comments on commit 30c54e5

Please sign in to comment.