From 58e0c0515095856ce9b11f442ef86405c1de711a Mon Sep 17 00:00:00 2001 From: Lucy Chen <140550297+lucychen-grafana@users.noreply.github.com> Date: Wed, 9 Jul 2025 15:25:20 -0400 Subject: [PATCH] E2C: Add new error for alert rule quota (#107225) * add new error for alert rule quota * add alert rule group quota error * make openapi3-gen * revert message * update translation * prettier * update text per review suggestion --- pkg/services/cloudmigration/api/dtos.go | 24 ++++++++++--------- pkg/services/cloudmigration/model.go | 24 ++++++++++--------- public/api-enterprise-spec.json | 2 ++ public/api-merged.json | 2 ++ .../migrate-to-cloud/api/endpoints.gen.ts | 2 ++ .../onprem/ResourceDetailsModal.tsx | 18 +++++++++++--- public/locales/en-US/grafana.json | 2 ++ public/openapi3.json | 2 ++ 8 files changed, 51 insertions(+), 25 deletions(-) diff --git a/pkg/services/cloudmigration/api/dtos.go b/pkg/services/cloudmigration/api/dtos.go index a9fe7ce855b..801480b910b 100644 --- a/pkg/services/cloudmigration/api/dtos.go +++ b/pkg/services/cloudmigration/api/dtos.go @@ -150,17 +150,19 @@ const ( type ItemErrorCode string const ( - ErrDatasourceNameConflict ItemErrorCode = "DATASOURCE_NAME_CONFLICT" - ErrDatasourceInvalidURL ItemErrorCode = "DATASOURCE_INVALID_URL" - ErrDatasourceAlreadyManaged ItemErrorCode = "DATASOURCE_ALREADY_MANAGED" - ErrFolderNameConflict ItemErrorCode = "FOLDER_NAME_CONFLICT" - ErrDashboardAlreadyManaged ItemErrorCode = "DASHBOARD_ALREADY_MANAGED" - ErrLibraryElementNameConflict ItemErrorCode = "LIBRARY_ELEMENT_NAME_CONFLICT" - ErrUnsupportedDataType ItemErrorCode = "UNSUPPORTED_DATA_TYPE" - ErrResourceConflict ItemErrorCode = "RESOURCE_CONFLICT" - ErrUnexpectedStatus ItemErrorCode = "UNEXPECTED_STATUS_CODE" - ErrInternalServiceError ItemErrorCode = "INTERNAL_SERVICE_ERROR" - ErrGeneric ItemErrorCode = "GENERIC_ERROR" + ErrAlertRulesQuotaReached ItemErrorCode = "ALERT_RULES_QUOTA_REACHED" + ErrAlertRulesGroupQuotaReached ItemErrorCode = "ALERT_RULES_GROUP_QUOTA_REACHED" + ErrDatasourceNameConflict ItemErrorCode = "DATASOURCE_NAME_CONFLICT" + ErrDatasourceInvalidURL ItemErrorCode = "DATASOURCE_INVALID_URL" + ErrDatasourceAlreadyManaged ItemErrorCode = "DATASOURCE_ALREADY_MANAGED" + ErrFolderNameConflict ItemErrorCode = "FOLDER_NAME_CONFLICT" + ErrDashboardAlreadyManaged ItemErrorCode = "DASHBOARD_ALREADY_MANAGED" + ErrLibraryElementNameConflict ItemErrorCode = "LIBRARY_ELEMENT_NAME_CONFLICT" + ErrUnsupportedDataType ItemErrorCode = "UNSUPPORTED_DATA_TYPE" + ErrResourceConflict ItemErrorCode = "RESOURCE_CONFLICT" + ErrUnexpectedStatus ItemErrorCode = "UNEXPECTED_STATUS_CODE" + ErrInternalServiceError ItemErrorCode = "INTERNAL_SERVICE_ERROR" + ErrGeneric ItemErrorCode = "GENERIC_ERROR" ) // swagger:parameters getCloudMigrationRun diff --git a/pkg/services/cloudmigration/model.go b/pkg/services/cloudmigration/model.go index 41d27e02f94..a01a33c62d4 100644 --- a/pkg/services/cloudmigration/model.go +++ b/pkg/services/cloudmigration/model.go @@ -110,17 +110,19 @@ const ( type ResourceErrorCode string const ( - ErrDatasourceNameConflict ResourceErrorCode = "DATASOURCE_NAME_CONFLICT" - ErrDatasourceInvalidURL ResourceErrorCode = "DATASOURCE_INVALID_URL" - ErrDatasourceAlreadyManaged ResourceErrorCode = "DATASOURCE_ALREADY_MANAGED" - ErrFolderNameConflict ResourceErrorCode = "FOLDER_NAME_CONFLICT" - ErrDashboardAlreadyManaged ResourceErrorCode = "DASHBOARD_ALREADY_MANAGED" - ErrLibraryElementNameConflict ResourceErrorCode = "LIBRARY_ELEMENT_NAME_CONFLICT" - ErrUnsupportedDataType ResourceErrorCode = "UNSUPPORTED_DATA_TYPE" - ErrResourceConflict ResourceErrorCode = "RESOURCE_CONFLICT" - ErrUnexpectedStatus ResourceErrorCode = "UNEXPECTED_STATUS_CODE" - ErrInternalServiceError ResourceErrorCode = "INTERNAL_SERVICE_ERROR" - ErrGeneric ResourceErrorCode = "GENERIC_ERROR" + ErrAlertRulesQuotaReached ResourceErrorCode = "ALERT_RULES_QUOTA_REACHED" + ErrAlertRulesGroupQuotaReached ResourceErrorCode = "ALERT_RULES_GROUP_QUOTA_REACHED" + ErrDatasourceNameConflict ResourceErrorCode = "DATASOURCE_NAME_CONFLICT" + ErrDatasourceInvalidURL ResourceErrorCode = "DATASOURCE_INVALID_URL" + ErrDatasourceAlreadyManaged ResourceErrorCode = "DATASOURCE_ALREADY_MANAGED" + ErrFolderNameConflict ResourceErrorCode = "FOLDER_NAME_CONFLICT" + ErrDashboardAlreadyManaged ResourceErrorCode = "DASHBOARD_ALREADY_MANAGED" + ErrLibraryElementNameConflict ResourceErrorCode = "LIBRARY_ELEMENT_NAME_CONFLICT" + ErrUnsupportedDataType ResourceErrorCode = "UNSUPPORTED_DATA_TYPE" + ErrResourceConflict ResourceErrorCode = "RESOURCE_CONFLICT" + ErrUnexpectedStatus ResourceErrorCode = "UNEXPECTED_STATUS_CODE" + ErrInternalServiceError ResourceErrorCode = "INTERNAL_SERVICE_ERROR" + ErrGeneric ResourceErrorCode = "GENERIC_ERROR" ) type SnapshotResourceStats struct { diff --git a/public/api-enterprise-spec.json b/public/api-enterprise-spec.json index d431451f492..6d5885e3bdd 100644 --- a/public/api-enterprise-spec.json +++ b/public/api-enterprise-spec.json @@ -5764,6 +5764,8 @@ "errorCode": { "type": "string", "enum": [ + "ALERT_RULES_QUOTA_REACHED", + "ALERT_RULES_GROUP_QUOTA_REACHED", "DATASOURCE_NAME_CONFLICT", "DATASOURCE_INVALID_URL", "DATASOURCE_ALREADY_MANAGED", diff --git a/public/api-merged.json b/public/api-merged.json index 0706252d551..0778d9d6d3d 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -17319,6 +17319,8 @@ "errorCode": { "type": "string", "enum": [ + "ALERT_RULES_QUOTA_REACHED", + "ALERT_RULES_GROUP_QUOTA_REACHED", "DATASOURCE_NAME_CONFLICT", "DATASOURCE_INVALID_URL", "DATASOURCE_ALREADY_MANAGED", 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 c6a3bae02da..339184f1635 100644 --- a/public/app/features/migrate-to-cloud/api/endpoints.gen.ts +++ b/public/app/features/migrate-to-cloud/api/endpoints.gen.ts @@ -206,6 +206,8 @@ export type CreateSnapshotRequestDto = { }; export type MigrateDataResponseItemDto = { errorCode?: + | 'ALERT_RULES_QUOTA_REACHED' + | 'ALERT_RULES_GROUP_QUOTA_REACHED' | 'DATASOURCE_NAME_CONFLICT' | 'DATASOURCE_INVALID_URL' | 'DATASOURCE_ALREADY_MANAGED' diff --git a/public/app/features/migrate-to-cloud/onprem/ResourceDetailsModal.tsx b/public/app/features/migrate-to-cloud/onprem/ResourceDetailsModal.tsx index a47efe48d43..63c194fbf73 100644 --- a/public/app/features/migrate-to-cloud/onprem/ResourceDetailsModal.tsx +++ b/public/app/features/migrate-to-cloud/onprem/ResourceDetailsModal.tsx @@ -13,6 +13,16 @@ interface ResourceDetailsModalProps { function getTMessage(errorCode: MigrateDataResponseItemDto['errorCode']): string { switch (errorCode) { + case 'ALERT_RULES_QUOTA_REACHED': + return t( + 'migrate-to-cloud.resource-details.error-messages.alert-rules-quota-reached', + 'Maximum number of alert rules reached: Delete some alert rules or upgrade your plan and try again.' + ); + case 'ALERT_RULES_GROUP_QUOTA_REACHED': + return t( + 'migrate-to-cloud.resource-details.error-messages.alert-rules-group-quota-reached', + 'Maximum number of alert rule groups reached: Delete some alert rule groups or upgrade your plan and try again.' + ); case 'DATASOURCE_NAME_CONFLICT': return t( 'migrate-to-cloud.resource-details.error-messages.datasource-name-conflict', @@ -106,9 +116,11 @@ export function ResourceDetailsModal(props: ResourceDetailsModalProps) { <> {msgTitle} - {getTMessage(resource?.errorCode) || - resource?.message || - 'There has been an error while migrating. Please check the cloud migration logs for more information.'} + {getTMessage(resource?.errorCode) || resource?.message || ( + + There has been an error while migrating. Please check the cloud migration logs for more information. + + )} ) : ( diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 34de246aaba..07558dd8558 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -9121,6 +9121,8 @@ "resource-details": { "dismiss-button": "OK", "error-messages": { + "alert-rules-group-quota-reached": "Maximum number of alert rule groups reached: Delete some alert rule groups or upgrade your plan and try again.", + "alert-rules-quota-reached": "Maximum number of alert rules reached: Delete some alert rules or upgrade your plan and try again.", "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-already-managed": "Data source is already provisioned and managed by Grafana in the cloud instance. If this is a different resource, set another UID and try again.", "datasource-invalid-url": "There is a data source which has an invalid URL. Provide a valid URL and try again.", diff --git a/public/openapi3.json b/public/openapi3.json index f44e48250d6..f6a8589a689 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -7360,6 +7360,8 @@ "properties": { "errorCode": { "enum": [ + "ALERT_RULES_QUOTA_REACHED", + "ALERT_RULES_GROUP_QUOTA_REACHED", "DATASOURCE_NAME_CONFLICT", "DATASOURCE_INVALID_URL", "DATASOURCE_ALREADY_MANAGED",