From 616e2f8550608d191f365c1752582004bfebca55 Mon Sep 17 00:00:00 2001 From: Peter Braun Date: Tue, 23 Apr 2024 12:02:14 +0200 Subject: [PATCH] fix: do not delete non-existing dashboard --- controllers/dashboard_controller.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/controllers/dashboard_controller.go b/controllers/dashboard_controller.go index 48ce16eee..efb091918 100644 --- a/controllers/dashboard_controller.go +++ b/controllers/dashboard_controller.go @@ -305,10 +305,14 @@ func (r *GrafanaDashboardReconciler) onDashboardDeleted(ctx context.Context, nam resp, err := grafanaClient.Dashboards.GetDashboardByUID(*uid) if err != nil { var notFound *dashboards.GetDashboardByUIDNotFound - if !errors.As(err, ¬Found) { - return err + if errors.As(err, ¬Found) { + // nothing to do if the dashboard doesn't exist + return nil } + + return err } + dash := resp.GetPayload() _, err = grafanaClient.Dashboards.DeleteDashboardByUID(*uid) //nolint:errcheck