From a65743e41d2bd68f541bf4518125423b4711bcf6 Mon Sep 17 00:00:00 2001 From: Matheus Macabu Date: Fri, 13 Jun 2025 11:09:27 +0200 Subject: [PATCH] CloudMigrations: Skip default contact point from snapshot (#106600) * CloudMigrations: Skip default contact point from snapshot * Update cloud-migration-assistant.md * Update cloud-migration-assistant.md --------- Co-authored-by: Jacob Valdez --- .../migration-guide/cloud-migration-assistant.md | 4 ++++ .../cloudmigrationimpl/snapshot_mgmt_alerts.go | 6 ++++++ .../cloudmigrationimpl/snapshot_mgmt_alerts_test.go | 4 +--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/sources/administration/migration-guide/cloud-migration-assistant.md b/docs/sources/administration/migration-guide/cloud-migration-assistant.md index 8f009fad5d0..7d2d8d71ed5 100644 --- a/docs/sources/administration/migration-guide/cloud-migration-assistant.md +++ b/docs/sources/administration/migration-guide/cloud-migration-assistant.md @@ -186,6 +186,10 @@ The migration assistant can migrate the majority of Grafana Alerting resources t - Notification policy tree - Notification templates +{{< admonition type="note">}} +The `grafana-default-email` contact point that's provisioned with every new Grafana instance doesn't have a UID by default and won't be migrated unless you edit or update and save it. You do not need to change the contact point for a UID to be generated when saved. +{{< /admonition >}} + This is sufficient to have your Alerting configuration up and running in Grafana Cloud with minimal effort. Migration of Silences is not supported by the migration assistant and needs to be configured manually. Alert History is also not available for migration. diff --git a/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts.go b/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts.go index 570676e7c3f..a279c09d9db 100644 --- a/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts.go +++ b/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts.go @@ -92,6 +92,12 @@ func (s *Service) getContactPoints(ctx context.Context, signedInUser *user.Signe contactPoints := make([]contactPoint, 0, len(embeddedContactPoints)) for _, embeddedContactPoint := range embeddedContactPoints { + // This happens in the default contact point, and would otherwise fail to migrate because it has no UID. + // If that contact point is edited in any way, an UID is generated. + if embeddedContactPoint.UID == "" { + continue + } + contactPoints = append(contactPoints, contactPoint{ UID: embeddedContactPoint.UID, Name: embeddedContactPoint.Name, diff --git a/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts_test.go b/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts_test.go index 3ab80d6838e..f6c43b28196 100644 --- a/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts_test.go +++ b/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts_test.go @@ -102,14 +102,12 @@ func TestGetContactPoints(t *testing.T) { }, } - defaultEmailContactPointCount := 1 - createdContactPoints := createContactPoints(t, ctx, s, user) contactPoints, err := s.getContactPoints(ctx, user) require.NoError(t, err) require.NotNil(t, contactPoints) - require.Len(t, contactPoints, len(createdContactPoints)+defaultEmailContactPointCount) + require.Len(t, contactPoints, len(createdContactPoints)) }) t.Run("it returns an error when user lacks permission to read contact point secrets", func(t *testing.T) {