Skip to content

Commit

Permalink
fix: cannot uninstall spiderpool when sriovOperatorConfig is installed
Browse files Browse the repository at this point in the history
Signed-off-by: tao.yang <[email protected]>
  • Loading branch information
ty-dc committed Sep 5, 2024
1 parent a0a9f87 commit 5b6de77
Show file tree
Hide file tree
Showing 8 changed files with 419 additions and 23 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/auto-upgrade-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,17 @@ jobs:
id: upgrade
continue-on-error: true
run: |
RESULT=0
make upgrade_e2e_spiderpool -e E2E_CLUSTER_NAME=${{ env.E2E_CLUSTER_NAME }} \
-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
-e SPIDERPOOL_CONTROLLER_IMAGE_NAME=spiderpool-controller-race || RESULT=1
if ((RESULT==0)) ; then
echo "succeeded to upgrade spiderpool from ${{ needs.get_ref.outputs.old_version }} to ${{ needs.get_ref.outputs.new_version }}"
else
echo "failed to upgrade spiderpool from ${{ needs.get_ref.outputs.old_version }} to ${{ needs.get_ref.outputs.new_version }}"
exit 1
fi
- name: Run e2e Test on ${{ needs.get_ref.outputs.new_version }}
id: run_e2e
Expand Down
33 changes: 14 additions & 19 deletions .github/workflows/e2e-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ jobs:
with:
go-version: 1.21.4

# https://github.com/helm/kind-action
- name: Install Kind Bin
uses: helm/[email protected]
with:
install_only: true

- name: Install Tools
run: |
# install kind/p2ctl/helm/ginkgo
Expand Down Expand Up @@ -204,22 +198,10 @@ jobs:
path: e2ereport.json
retention-days: 1

- name: helm uninstalls spiderpool and cleans spiderpool CRD
id: clean
if: ${{ inputs.run_e2e == 'true' }}
run: |
RESULT=0
make clean_e2e_spiderpool || RESULT=1
if ((RESULT==0)) ; then
echo "CLEAN_E2E_PASS=true" >> $GITHUB_ENV
else
echo "CLEAN_E2E_PASS=false" >> $GITHUB_ENV
fi
- name: Show e2e Result
if: ${{ inputs.run_e2e == 'true' }}
run: |
if ${{ env.RUN_E2E_PASS == 'true' && env.CLEAN_E2E_PASS == 'true' }} ;then
if ${{ env.RUN_E2E_PASS == 'true' }} ;then
exit 0
else
exit 1
Expand Down Expand Up @@ -248,3 +230,16 @@ jobs:
label: performance
message: ${{ env.PERFORMANCE_RESULT }}
color: lightgrey

- name: helm uninstalls spiderpool and cleans spiderpool CRD
id: clean
if: ${{ inputs.run_e2e == 'true' }}
run: |
RESULT=0
make clean_e2e_spiderpool || RESULT=1
if ((RESULT==0)) ; then
echo "succeeded to uninstall spiderpool"
else
echo "failed to uninstall spiderpool"
fi
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,11 @@ clean: clean_e2e

.PHONY: clean_e2e_spiderpool
clean_e2e_spiderpool:
-$(QUIET) make -C test uninstall_spiderpool
$(QUIET) make -C test uninstall_spiderpool

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

.PHONY: codegen
codegen:
Expand Down
39 changes: 39 additions & 0 deletions charts/spiderpool/templates/deleteHook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- if .Values.spiderpoolController.cleanup.enable }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Values.spiderpoolController.name | trunc 48 | trimSuffix "-" }}-hook-pre-delete
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
template:
spec:
hostNetwork: true
serviceAccountName: {{ .Values.spiderpoolController.name | trunc 63 | trimSuffix "-" }}
containers:
- name: pre-delete
image: {{ include "spiderpool.spiderpoolController.image" . | quote }}
command:
- {{ .Values.spiderpoolController.binName }}
- clean
- --validate
- {{ .Values.spiderpoolController.name | trunc 63 | trimSuffix "-" }}
- --mutating
- {{ .Values.spiderpoolController.name | trunc 63 | trimSuffix "-" }}
env:
- name: SPIDERPOOL_POD_NAMESPACE
value: {{ .Release.Namespace | quote }}
- name: SPIDERPOOL_INIT_NAME
value: {{ .Values.spiderpoolInit.name | trunc 63 | trimSuffix "-" | quote }}
- name: SPIDERPOOL_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SPIDERPOOL_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
restartPolicy: Never
backoffLimit: 2
{{- end }}
1 change: 1 addition & 0 deletions charts/spiderpool/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ rules:
- cronjobs
- jobs
verbs:
- delete
- get
- list
- update
Expand Down
Loading

0 comments on commit 5b6de77

Please sign in to comment.