Skip to content

Fix error details type on google_database_migration_service_migration_job #9244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

modular-magician
Copy link
Collaborator

In the event that there is an error with a MigrationJob in GCP, the Terraform google provider can not properly create a plan because the schema for google_database_migration_service_migration_job is incorrect.

... expected type 'string', got unconvertible type 'map[string]interface {}' ...

I am not sure if this is the proper way to fix the issue, but based on the details of the error response from Terraform and comparing magic-modules source code with gcloud output, it seems like this code change will fix the issue. magic-modules has a MigrationJob error configured as a KeyValuePairs when it is in fact an Object with arbitrary properties.

Terraform execution error:

Error: Error reading MigrationJob: error.0.details.1.metadata: '' expected type 'string', got unconvertible type 'map[string]interface {}', value: 'map[errorMessage:The migration job is currently running. Restart is not available on a running Migration job. nativeErrorMessage:Cloud SQL replica is already setup and it's replicating from the source database server. severity:ERROR]'
  with google_database_migration_service_migration_job.dms_task,
  on main.tf line 167, in resource "google_database_migration_service_migration_job" "dms_task":
 167: resource "google_database_migration_service_migration_job" "dms_task" {

Data returned from gcloud database-migration migration-jobs describe dms-task:

...
error:
  code: 9
  details:
  - '@type': type.googleapis.com/google.cloud.clouddms.v1.MigrationJobVerificationError
    errorCode: CANT_RESTART_RUNNING_MIGRATION
    errorDetailMessage: Cloud SQL replica is already setup and it's replicating from
      the source database server.
    errorMessage: "The migration job is currently running. Restart is not available\
      \ on a running Migration job. Details: Cloud SQL replica is already setup and\
      \ it's replicating from the source database server."
  - '@type': type.googleapis.com/google.rpc.ErrorInfo
    domain: datamigration.googleapis.com
    metadata:
      errorMessage: The migration job is currently running. Restart is not available
        on a running Migration job.
      nativeErrorMessage: Cloud SQL replica is already setup and it's replicating
        from the source database server.
      severity: ERROR
    reason: CANT_RESTART_RUNNING_MIGRATION
  - '@type': type.googleapis.com/google.rpc.Help
    links:
    - description: 'Learn more:'
      url: https://cloud.google.com/database-migration/docs/diagnose-issues
  message: The migration job is currently running. Restart is not available on a running
    Migration job.
labels:
  goog-terraform-provisioned: 'true'
...
fix: error details type on google_database_migration_service_migration_job

Derived from GoogleCloudPlatform/magic-modules#12858

…_job (#12858)

[upstream:75e910a0c3f7b234c6d68f38f8d20ba0894ed52f]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician requested a review from a team as a code owner February 6, 2025 18:58
@modular-magician modular-magician merged commit f27386f into hashicorp:main Feb 6, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant