CloudMigrations: handle more error codes from GMS backend (#95257)

* CloudMigrations: remove unnecessary if feature toggle gating

* CloudMigrations: handle new error codes from backend
This commit is contained in:
Matheus Macabu 2024-10-24 15:55:02 +02:00 committed by GitHub
parent 77b8b505ad
commit 152b83b3fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 27 additions and 1 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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"

View File

@ -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",

View File

@ -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",

View File

@ -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'

View File

@ -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',

View File

@ -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.",

View File

@ -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.",

View File

@ -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",