Skip to content

Commit d68dca0

Browse files
committed
cleanup all
1 parent 4d3463d commit d68dca0

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

scripts/evergreen/e2e/e2e.sh

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,37 @@ dump_cluster_information() {
4646
fi
4747
}
4848

49-
delete_operator() {
49+
cleanup_operator() {
5050
local context="${1}"
51-
timeout 5s helm uninstall --kube-context="${context}" mongodb-kubernetes-operator || true
51+
if ! timeout 5s helm uninstall --wait --kube-context="${context}" mongodb-kubernetes-operator; then
52+
echo "Warning: Helm uninstall failed or timed out. Continuing anyway."
53+
fi
5254
}
5355

5456
cleanup_openshift_cluster(){
55-
if [[ "${TEST_RESULTS}" -ne 0 ]]; then
56-
# Mark namespace as failed to be cleaned later
57-
kubectl label "namespace/${NAMESPACE}" "evg/state=failed" --overwrite=true
58-
59-
if [ "${ALWAYS_REMOVE_TESTING_NAMESPACE-}" = "true" ]; then
60-
# Failed namespaces might cascade into more failures if the namespaces
61-
# are not being removed soon enough.
62-
reset_namespace "$(kubectl config current-context)" "${NAMESPACE}" || true
63-
fi
57+
if [[ "${TEST_RESULTS}" -ne 0 ]]; then
58+
# Mark namespace as failed to be cleaned later
59+
kubectl label "namespace/${NAMESPACE}" "evg/state=failed" --overwrite=true
60+
61+
if [ "${ALWAYS_REMOVE_TESTING_NAMESPACE-}" = "true" ]; then
62+
# Failed namespaces might cascade into more failures if the namespaces
63+
# are not being removed soon enough.
64+
reset_namespace "$(kubectl config current-context)" "${NAMESPACE}" || true
65+
fi
66+
else
67+
if [[ "${KUBE_ENVIRONMENT_NAME}" = "multi" ]]; then
68+
echo "Tearing down cluster ${CENTRAL_CLUSTER}"
69+
reset_namespace "${CENTRAL_CLUSTER}" "${NAMESPACE}" || true
70+
71+
for member_cluster in ${MEMBER_CLUSTERS}; do
72+
echo "Tearing down cluster ${member_cluster}"
73+
reset_namespace "${member_cluster}" "${NAMESPACE}" || true
74+
done
75+
else
76+
# If the test pass, then the namespace is removed
77+
reset_namespace "$(kubectl config current-context)" "${NAMESPACE}" || true
6478
fi
79+
fi
6580
}
6681

6782
if [[ -n "${KUBECONFIG:-}" && ! -f "${KUBECONFIG}" ]]; then
@@ -145,16 +160,11 @@ if [[ "${CLUSTER_TYPE}" == "openshift" ]]; then
145160
cleanup_openshift_cluster
146161
else
147162
if [[ "${KUBE_ENVIRONMENT_NAME}" == "multi" ]]; then
148-
echo "Tearing down cluster ${CENTRAL_CLUSTER}"
149-
reset_namespace "${CENTRAL_CLUSTER}" "${NAMESPACE}" || true
150-
151-
for member_cluster in ${MEMBER_CLUSTERS}; do
152-
echo "Tearing down cluster ${member_cluster}"
153-
reset_namespace "${member_cluster}" "${NAMESPACE}" || true
154-
done
163+
echo "Tearing down operator on ${CENTRAL_CLUSTER}"
164+
cleanup_operator "${CENTRAL_CLUSTER}"
155165
else
156166
# If the test passed, then the namespace is removed
157-
reset_namespace "$(kubectl config current-context)" "${NAMESPACE}" || true
167+
cleanup_operator "$(kubectl config current-context)"
158168
fi
159169
fi
160170

0 commit comments

Comments
 (0)