From 11ccc22fce847217560a95a375d762fc2766e8be Mon Sep 17 00:00:00 2001 From: jiuker <2818723467@qq.com> Date: Sat, 7 Oct 2023 11:13:00 +0800 Subject: [PATCH] fix: delete tenant with prometheus's config been deleted (#1773) feat: delete tenant with prometheus's config delete --- pkg/controller/main-controller.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/controller/main-controller.go b/pkg/controller/main-controller.go index ad66a7e8470..432c3b34518 100644 --- a/pkg/controller/main-controller.go +++ b/pkg/controller/main-controller.go @@ -740,6 +740,18 @@ func (c *Controller) syncHandler(key string) (Result, error) { // The Tenant resource may no longer exist, in which case we stop processing. if k8serrors.IsNotFound(err) { runtime.HandleError(fmt.Errorf("Tenant '%s' in work queue no longer exists", key)) + // Try to delete PrometheusConfig. + // Can't use the tenant. That's nil for sure + err = c.deletePrometheusAddlConfig(ctx, &miniov2.Tenant{ + ObjectMeta: metav1.ObjectMeta{ + Name: tenantName, + Namespace: namespace, + }, + }) + if err != nil { + // Just output the error. Will not retry. + runtime.HandleError(fmt.Errorf("DeletePrometheusAddlConfig '%s/%s' error:%s", namespace, tenantName, err.Error())) + } return WrapResult(Result{}, nil) } // will retry after 5sec