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

Remove leftover e2e resouces due to test failure #1034

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

HaoYang0000
Copy link
Collaborator

@HaoYang0000 HaoYang0000 commented Jan 15, 2025

@roypaulin @cchen-vertica @qindotguan @LiboYu2
In my local env, when kuttl test failed, there are leftover resources left in my cluster.
Create a make target "cleanup-e2e-env" to remove those resources and namespace.
Create a make target "cleanup-prometheus-leftover" to remove leftover resources for Prometheus.

@HaoYang0000 HaoYang0000 changed the title Undeploy leftover resouces Remove leftover e2e resouces due to test failure Jan 15, 2025
@HaoYang0000
Copy link
Collaborator Author

Also there is Prometheus resources maybe leftover, wondering if we should add another make target or use the same one "cleanup-e2e-env":
NAMESPACE=$1
kubectl delete clusterrole prometheus-kube-prometheus-operator -n $NAMESPACE
kubectl delete clusterrole prometheus-kube-prometheus-prometheus -n $NAMESPACE
kubectl delete clusterrolebinding prometheus-kube-prometheus-operator -n $NAMESPACE
kubectl delete clusterrolebinding prometheus-kube-prometheus-prometheus -n $NAMESPACE
kubectl delete svc prometheus-kube-prometheus-kube-proxy -n kube-system
kubectl delete svc prometheus-kube-prometheus-kubelet -n kube-system
kubectl delete MutatingWebhookConfiguration prometheus-kube-prometheus-admission -n $NAMESPACE
kubectl delete ValidatingWebhookConfiguration prometheus-kube-prometheus-admission -n $NAMESPACE

@LiboYu2
Copy link
Collaborator

LiboYu2 commented Jan 15, 2025

Also there is Prometheus resources maybe leftover, wondering if we should add another make target or use the same one "cleanup-e2e-env": NAMESPACE=$1 kubectl delete clusterrole prometheus-kube-prometheus-operator -n $NAMESPACE kubectl delete clusterrole prometheus-kube-prometheus-prometheus -n $NAMESPACE kubectl delete clusterrolebinding prometheus-kube-prometheus-operator -n $NAMESPACE kubectl delete clusterrolebinding prometheus-kube-prometheus-prometheus -n $NAMESPACE kubectl delete svc prometheus-kube-prometheus-kube-proxy -n kube-system kubectl delete svc prometheus-kube-prometheus-kubelet -n kube-system kubectl delete MutatingWebhookConfiguration prometheus-kube-prometheus-admission -n $NAMESPACE kubectl delete ValidatingWebhookConfiguration prometheus-kube-prometheus-admission -n $NAMESPACE

We can make it a target for makefile. Here are the commands I used on the top of the ones you posted. Some are duplicates.


# Fetch leftover kuttl resources and remove the namespace
for ns in $(kubectl get ns | grep kuttl-test | cut -d' ' -f1); do
kubectl delete all --all -n $ns
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't clean up prometheus-kube-prometheus-kube-proxy which is in kube-system.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, here I intend to remove only kuttl-test namespace leftover resources. For the other kinds I may add another target.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a separate PR, just do it here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I didn't mean another PR, I mean another make target. Deleting non-namespace scoped resources can be very destructive, for example: kubectl delete clusterrole. It will impact the Prometheus instance.

Makefile Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants