Skip to content

Commit a818b38

Browse files
committed
move delete CRD step into the cleanup func
1 parent 1af9a40 commit a818b38

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

scripts/run-e2e-test.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ ROLE_NAME="aws-load-balancer-controller-$TEST_ID"
3232
POLICY_NAME="AWSLoadBalancerControllerIAMPolicy-$TEST_ID"
3333

3434
function cleanUp(){
35-
# IAM role and polcies are AWS Account specific, so need to clean them up if any from previous run
35+
echo "delete serviceaccount"
36+
kubectl delete serviceaccount aws-load-balancer-controller -n kube-system --timeout 60s || true
37+
3638
echo "detach IAM policy"
3739
aws iam detach-role-policy --role-name $ROLE_NAME --policy-arn arn:${AWS_PARTITION}:iam::$ACCOUNT_ID:policy/$POLICY_NAME || true
3840

@@ -42,9 +44,15 @@ function cleanUp(){
4244
echo "delete $ROLE_NAME"
4345
aws iam delete-role --role-name $ROLE_NAME || true
4446

45-
# Need to do this as last step
4647
echo "delete $POLICY_NAME"
4748
aws iam delete-policy --policy-arn arn:${AWS_PARTITION}:iam::$ACCOUNT_ID:policy/$POLICY_NAME || true
49+
50+
echo "Delete CRDs if exists"
51+
if [[ $ADC_REGIONS == *"$REGION"* ]]; then
52+
kubectl delete -k "../helm/aws-load-balancer-controller/crds" --timeout=30s || true
53+
else
54+
kubectl delete -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master" --timeout=30s || true
55+
fi
4856
}
4957

5058
echo "cordon off windows nodes"
@@ -218,13 +226,6 @@ fi
218226
echo "clean up resources from current run"
219227
cleanUp
220228

221-
echo "Delete CRDs if exists"
222-
if [[ $ADC_REGIONS == *"$REGION"* ]]; then
223-
kubectl delete -k "../helm/aws-load-balancer-controller/crds" --timeout=30s || true
224-
else
225-
kubectl delete -k "github.com/aws/eks-charts/stable/aws-load-balancer-controller//crds?ref=master" --timeout=30s || true
226-
fi
227-
228229
if [[ "$TEST_RESULT" == fail ]]; then
229230
echo "e2e tests failed."
230231
exit 1

0 commit comments

Comments
 (0)