Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat: adding dashboard delete unsafe v2 method (#12876)

Swapnil Nakadee1acfc94ba6b
diff --git a/ee/modules/cloudintegration/implcloudintegration/module.go b/ee/modules/cloudintegration/implcloudintegration/module.go
index 1f3b8acee7..da1bc366b6 100644
--- a/ee/modules/cloudintegration/implcloudintegration/module.go
+++ b/ee/modules/cloudintegration/implcloudintegration/module.go
@@ -583,7 +583,7 @@ func (module *module) deprovisionDashboards(ctx context.Context, orgID valuer.UU
return err
}
- if err := module.dashboardModule.DeleteUnsafe(ctx, orgID, dashID); err != nil {
+ if err := module.dashboardModule.DeleteUnsafeV2(ctx, orgID, dashID); err != nil {
return err
}
}
diff --git a/ee/modules/dashboard/impldashboard/module.go b/ee/modules/dashboard/impldashboard/module.go
index 15025de986..613262ed40 100644
--- a/ee/modules/dashboard/impldashboard/module.go
+++ b/ee/modules/dashboard/impldashboard/module.go
@@ -297,6 +297,15 @@ func (module *module) DeleteV2(ctx context.Context, orgID valuer.UUID, id valuer
})
}
+func (module *module) DeleteUnsafeV2(ctx context.Context, orgID valuer.UUID, id valuer.UUID) error {
+ return module.store.RunInTx(ctx, func(ctx context.Context) error {
+ if err := module.store.DeletePublic(ctx, id.String()); err != nil && !errors.Ast(err, errors.TypeNotFound) {
+ return err
+ }
+ return module.pkgDashboardModule.DeleteUnsafeV2(ctx, orgID, id)
+ })
+}
+
func (module *module) LockUnlockV2(ctx context.Context, orgID valuer.UUID, id valuer.UUID, updatedBy string, isAdmin bool, lock bool) error {
return module.pkgDashboardModule.LockUnlockV2(ctx, orgID, id, updatedBy, isAdmin, lock)
}
diff --git a/pkg/modules/dashboard/dashboard.go b/pkg/modules/dashboard/dashboard.go
index f8c33e0f0b..8efec9387f 100644
--- a/pkg/modules/dashboard/dashboard.go
+++ b/pkg/modules/dashboard/dashboard.go
@@ -82,6 +82,10 @@ type Module interface {
DeleteV2(ctx context.Context, orgID valuer.UUID, id valuer.UUID) error
+ // DeleteUnsafeV2 deletes a v2 dashboard and its related state without applying deletion guards.
+ // Intended for internal system callers.
+ DeleteUnsafeV2(ctx context.Context, orgID valuer.UUID, id valuer.UUID) error
+
DeletePreferencesForUser(ctx context.Context, orgID valuer.UUID, userID valuer.UUID) error
// get the v2 dashboard data by public dashboard id
diff --git a/pkg/modules/dashboard/impldashboard/v2_module.go b/pkg/modules/dashboard/impldashboard/v2_module.go
index 74b43be514..74522fb3bd 100644
--- a/pkg/modules/dashboard/impldashboard/v2_module.go
+++ b/pkg/modules/dashboard/impldashboard/v2_module.go
@@ -294,6 +294,15 @@ func (module *module) DeleteV2(ctx context.Context, orgID valuer.UUID, id valuer
return err
}
+ return module.deleteV2(ctx, orgID, id)
+}
+
+// DeleteUnsafeV2 deletes a v2 dashboard bypassing the guards. Intended for internal system callers.
+func (module *module) DeleteUnsafeV2(ctx context.Context, orgID valuer.UUID, id valuer.UUID) error {
+ return module.deleteV2(ctx, orgID, id)
+}
+
+func (module *module) deleteV2(ctx context.Context, orgID valuer.UUID, id valuer.UUID) error {
return module.store.RunInTx(ctx, func(ctx context.Context) error {
// Syncing to an empty tag set drops every tag link for the dashboard.
if _, err := module.tagModule.SyncTags(ctx, orgID, coretypes.KindDashboard, id, nil); err != nil {
diff --git a/pkg/query-service/app/integrations/manager.go b/pkg/query-service/app/integrations/manager.go
index ca09b2655a..dda64c112a 100644
--- a/pkg/query-service/app/integrations/manager.go
+++ b/pkg/query-service/app/integrations/manager.go
@@ -470,7 +470,7 @@ func (m *Manager) deprovisionDashboards(
if err != nil {
return err
}
- if err := m.dashboardModule.DeleteUnsafe(ctx, orgID, dashID); err != nil {
+ if err := m.dashboardModule.DeleteUnsafeV2(ctx, orgID, dashID); err != nil {
return err
}
}