From 152b83b3fb4343d84672dd79e7b0f8058f4c1931 Mon Sep 17 00:00:00 2001 From: Matheus Macabu Date: Thu, 24 Oct 2024 15:55:02 +0200 Subject: [PATCH] CloudMigrations: handle more error codes from GMS backend (#95257) * CloudMigrations: remove unnecessary if feature toggle gating * CloudMigrations: handle new error codes from backend --- pkg/services/cloudmigration/api/dtos.go | 2 ++ .../cloudmigration/cloudmigrationimpl/snapshot_mgmt.go | 2 +- pkg/services/cloudmigration/model.go | 2 ++ public/api-enterprise-spec.json | 2 ++ public/api-merged.json | 2 ++ .../app/features/migrate-to-cloud/api/endpoints.gen.ts | 2 ++ .../migrate-to-cloud/onprem/ResourceDetailsModal.tsx | 10 ++++++++++ public/locales/en-US/grafana.json | 2 ++ public/locales/pseudo-LOCALE/grafana.json | 2 ++ public/openapi3.json | 2 ++ 10 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pkg/services/cloudmigration/api/dtos.go b/pkg/services/cloudmigration/api/dtos.go index b64d7057778..a5756704fde 100644 --- a/pkg/services/cloudmigration/api/dtos.go +++ b/pkg/services/cloudmigration/api/dtos.go @@ -149,6 +149,8 @@ type ItemErrorCode string const ( ErrDatasourceNameConflict ItemErrorCode = "DATASOURCE_NAME_CONFLICT" + ErrDatasourceInvalidURL ItemErrorCode = "DATASOURCE_INVALID_URL" + ErrFolderNameConflict ItemErrorCode = "FOLDER_NAME_CONFLICT" ErrDashboardAlreadyManaged ItemErrorCode = "DASHBOARD_ALREADY_MANAGED" ErrLibraryElementNameConflict ItemErrorCode = "LIBRARY_ELEMENT_NAME_CONFLICT" ErrUnsupportedDataType ItemErrorCode = "UNSUPPORTED_DATA_TYPE" diff --git a/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go b/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go index bc95dbb4b78..7bc87507232 100644 --- a/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go +++ b/pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt.go @@ -167,7 +167,7 @@ func (s *Service) getMigrationDataJSON(ctx context.Context, signedInUser *user.S }) } - if s.features.IsEnabledGlobally(featuremgmt.FlagOnPremToCloudMigrationsAlerts) && len(notificationPolicies.Name) > 0 { + if len(notificationPolicies.Name) > 0 { // Notification Policy can only be managed by updating its entire tree, so we send the whole thing as one item. migrationDataSlice = append(migrationDataSlice, cloudmigration.MigrateDataRequestItem{ Type: cloudmigration.NotificationPolicyType, diff --git a/pkg/services/cloudmigration/model.go b/pkg/services/cloudmigration/model.go index 02ba12ba838..898ebecb8a7 100644 --- a/pkg/services/cloudmigration/model.go +++ b/pkg/services/cloudmigration/model.go @@ -106,6 +106,8 @@ type ResourceErrorCode string const ( ErrDatasourceNameConflict ResourceErrorCode = "DATASOURCE_NAME_CONFLICT" + ErrDatasourceInvalidURL ResourceErrorCode = "DATASOURCE_INVALID_URL" + ErrFolderNameConflict ResourceErrorCode = "FOLDER_NAME_CONFLICT" ErrDashboardAlreadyManaged ResourceErrorCode = "DASHBOARD_ALREADY_MANAGED" ErrLibraryElementNameConflict ResourceErrorCode = "LIBRARY_ELEMENT_NAME_CONFLICT" ErrUnsupportedDataType ResourceErrorCode = "UNSUPPORTED_DATA_TYPE" diff --git a/public/api-enterprise-spec.json b/public/api-enterprise-spec.json index 150fe8fef2f..d04a43e6c86 100644 --- a/public/api-enterprise-spec.json +++ b/public/api-enterprise-spec.json @@ -5773,6 +5773,8 @@ "type": "string", "enum": [ "DATASOURCE_NAME_CONFLICT", + "DATASOURCE_INVALID_URL", + "FOLDER_NAME_CONFLICT", "DASHBOARD_ALREADY_MANAGED", "LIBRARY_ELEMENT_NAME_CONFLICT", "UNSUPPORTED_DATA_TYPE", diff --git a/public/api-merged.json b/public/api-merged.json index 0d173b7db09..2fb766b6014 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -17266,6 +17266,8 @@ "type": "string", "enum": [ "DATASOURCE_NAME_CONFLICT", + "DATASOURCE_INVALID_URL", + "FOLDER_NAME_CONFLICT", "DASHBOARD_ALREADY_MANAGED", "LIBRARY_ELEMENT_NAME_CONFLICT", "UNSUPPORTED_DATA_TYPE", diff --git a/public/app/features/migrate-to-cloud/api/endpoints.gen.ts b/public/app/features/migrate-to-cloud/api/endpoints.gen.ts index bba187c2509..41cf10cd5fe 100644 --- a/public/app/features/migrate-to-cloud/api/endpoints.gen.ts +++ b/public/app/features/migrate-to-cloud/api/endpoints.gen.ts @@ -166,6 +166,8 @@ export type CreateSnapshotResponseDto = { export type MigrateDataResponseItemDto = { errorCode?: | 'DATASOURCE_NAME_CONFLICT' + | 'DATASOURCE_INVALID_URL' + | 'FOLDER_NAME_CONFLICT' | 'DASHBOARD_ALREADY_MANAGED' | 'LIBRARY_ELEMENT_NAME_CONFLICT' | 'UNSUPPORTED_DATA_TYPE' diff --git a/public/app/features/migrate-to-cloud/onprem/ResourceDetailsModal.tsx b/public/app/features/migrate-to-cloud/onprem/ResourceDetailsModal.tsx index d8e57f11835..de9082b4c85 100644 --- a/public/app/features/migrate-to-cloud/onprem/ResourceDetailsModal.tsx +++ b/public/app/features/migrate-to-cloud/onprem/ResourceDetailsModal.tsx @@ -18,6 +18,16 @@ function getTMessage(errorCode: MigrateDataResponseItemDto['errorCode']): string 'migrate-to-cloud.resource-details.error-messages.datasource-name-conflict', 'There is a data source with the same name in the target instance. Rename one of them and try again.' ); + case 'DATASOURCE_INVALID_URL': + return t( + 'migrate-to-cloud.resource-details.error-messages.datasource-invalid-url', + 'There is a data source which has an invalid URL. Provide a valid URL and try again.' + ); + case 'FOLDER_NAME_CONFLICT': + return t( + 'migrate-to-cloud.resource-details.error-messages.folder-name-conflict', + 'There is a folder with the same name in the target instance. Rename one of them and try again.' + ); case 'DASHBOARD_ALREADY_MANAGED': return t( 'migrate-to-cloud.resource-details.error-messages.dashboard-already-managed', diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 75f25db860a..26b3ec0d015 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -1616,7 +1616,9 @@ "dismiss-button": "OK", "error-messages": { "dashboard-already-managed": "Dashboard is already provisioned and managed by Grafana in the cloud instance. We recommend using the provisioned dashboard going forward. If you still wish to copy the dashboard to the cloud instance, then change the dashboard ID in the dashboard JSON, save a new snapshot and upload again.", + "datasource-invalid-url": "There is a data source which has an invalid URL. Provide a valid URL and try again.", "datasource-name-conflict": "There is a data source with the same name in the target instance. Rename one of them and try again.", + "folder-name-conflict": "There is a folder with the same name in the target instance. Rename one of them and try again.", "generic-error": "There has been an error while migrating. Please check the cloud migration logs for more information.", "internal-service-error": "There has been an error while migrating. Please check the Grafana server logs for more details.", "library-element-name-conflict": "There is a library element with the same name in the target instance. Rename one of them and try again.", diff --git a/public/locales/pseudo-LOCALE/grafana.json b/public/locales/pseudo-LOCALE/grafana.json index 8ba13075e66..974b9d910e8 100644 --- a/public/locales/pseudo-LOCALE/grafana.json +++ b/public/locales/pseudo-LOCALE/grafana.json @@ -1616,7 +1616,9 @@ "dismiss-button": "ØĶ", "error-messages": { "dashboard-already-managed": "Đäşĥþőäřđ įş äľřęäđy přővįşįőʼnęđ äʼnđ mäʼnäģęđ þy Ğřäƒäʼnä įʼn ŧĥę čľőūđ įʼnşŧäʼnčę. Ŵę řęčőmmęʼnđ ūşįʼnģ ŧĥę přővįşįőʼnęđ đäşĥþőäřđ ģőįʼnģ ƒőřŵäřđ. Ĩƒ yőū şŧįľľ ŵįşĥ ŧő čőpy ŧĥę đäşĥþőäřđ ŧő ŧĥę čľőūđ įʼnşŧäʼnčę, ŧĥęʼn čĥäʼnģę ŧĥę đäşĥþőäřđ ĨĐ įʼn ŧĥę đäşĥþőäřđ ĴŜØŃ, şävę ä ʼnęŵ şʼnäpşĥőŧ äʼnđ ūpľőäđ äģäįʼn.", + "datasource-invalid-url": "Ŧĥęřę įş ä đäŧä şőūřčę ŵĥįčĥ ĥäş äʼn įʼnväľįđ ŮŖĿ. Přővįđę ä väľįđ ŮŖĿ äʼnđ ŧřy äģäįʼn.", "datasource-name-conflict": "Ŧĥęřę įş ä đäŧä şőūřčę ŵįŧĥ ŧĥę şämę ʼnämę įʼn ŧĥę ŧäřģęŧ įʼnşŧäʼnčę. Ŗęʼnämę őʼnę őƒ ŧĥęm äʼnđ ŧřy äģäįʼn.", + "folder-name-conflict": "Ŧĥęřę įş ä ƒőľđęř ŵįŧĥ ŧĥę şämę ʼnämę įʼn ŧĥę ŧäřģęŧ įʼnşŧäʼnčę. Ŗęʼnämę őʼnę őƒ ŧĥęm äʼnđ ŧřy äģäįʼn.", "generic-error": "Ŧĥęřę ĥäş þęęʼn äʼn ęřřőř ŵĥįľę mįģřäŧįʼnģ. Pľęäşę čĥęčĸ ŧĥę čľőūđ mįģřäŧįőʼn ľőģş ƒőř mőřę įʼnƒőřmäŧįőʼn.", "internal-service-error": "Ŧĥęřę ĥäş þęęʼn äʼn ęřřőř ŵĥįľę mįģřäŧįʼnģ. Pľęäşę čĥęčĸ ŧĥę Ğřäƒäʼnä şęřvęř ľőģş ƒőř mőřę đęŧäįľş.", "library-element-name-conflict": "Ŧĥęřę įş ä ľįþřäřy ęľęmęʼnŧ ŵįŧĥ ŧĥę şämę ʼnämę įʼn ŧĥę ŧäřģęŧ įʼnşŧäʼnčę. Ŗęʼnämę őʼnę őƒ ŧĥęm äʼnđ ŧřy äģäįʼn.", diff --git a/public/openapi3.json b/public/openapi3.json index febd634d8f5..fc1ebcb5d0d 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -7218,6 +7218,8 @@ "errorCode": { "enum": [ "DATASOURCE_NAME_CONFLICT", + "DATASOURCE_INVALID_URL", + "FOLDER_NAME_CONFLICT", "DASHBOARD_ALREADY_MANAGED", "LIBRARY_ELEMENT_NAME_CONFLICT", "UNSUPPORTED_DATA_TYPE",