oracle / terraform-provider-oci

Terraform Oracle Cloud Infrastructure provider
https://www.terraform.io/docs/providers/oci/
Mozilla Public License 2.0
755 stars 672 forks source link

can't destory resouce oci_mysql_mysql_backup cross-region copy in destination #2170

Open jansonkwo opened 1 month ago

jansonkwo commented 1 month ago

Terraform Version and Provider Version

Terraform v1.9.0 on windows_amd64

Affected Resource(s)

resource "oci_mysql_mysql_backup"

Terraform Configuration Files

data "oci_mysql_mysql_backups" "test_mysql_backups" { provider = oci.iad

Required

compartment_id = var.origin_compartment_id

#Optional
#backup_id = oci_mysql_mysql_backup.test_backup.id
#creation_type = var.mysql_backup_creation_type
#db_system_id = oci_mysql_mysql_db_system.test_db_system.id
display_name = var.mysql_backup_display_name
#state = var.mysql_backup_state

}

output "mysql_backup_id" { value = data.oci_mysql_mysql_backups.test_mysql_backups.backups[0].id }

output "mysql_db_id" { value = data.oci_mysql_mysql_backups.test_mysql_backups.backups[0].db_system_id }

resource "oci_mysql_mysql_backup" "copy_mysql_backup" {

provider = oci.phx

#Required
#db_system_id = data.oci_mysql_mysql_backups.test_mysql_backups.backups[0].db_system_id

compartment_id = var.origin_compartment_id

#Optional
#backup_type = var.mysql_backup_backup_type
#defined_tags = {"foo-namespace.bar-key"= "value"}
#description = var.mysql_backup_description
display_name = "copy-from-backup-ashburn"
#freeform_tags = {"bar-key"= "value"}
#retention_in_days = var.mysql_backup_retention_in_days

source_details {
    region  = var.region
    backup_id = data.oci_mysql_mysql_backups.test_mysql_backups.backups[0].id
    compartment_id  = var.target_compartment_id
}

}

Debug Output

2024-08-07T10:01:54.337+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.337630 client.go:237: Setting the default refresh interval 30 for custom certs oci_mysql_mysql_backup.copy_mysql_backup: Destroying... [id=ocid1.mysqlbackup.oc1.phx.aaaaaaaa5hmzjyv2fdw6xvwsan5hfqv52u273m4t2g7uyglbyqxibfyeey3a] 2024-08-07T10:01:54.344+0800 [INFO] Starting apply for oci_mysql_mysql_backup.copy_mysql_backup 2024-08-07T10:01:54.344+0800 [DEBUG] oci_mysql_mysql_backup.copy_mysql_backup: applying the planned Delete change 2024-08-07T10:01:54.347+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.347449 mysql_dbbackups_client.go:70: region named: , is not recognized from hard-coded region list, will check Region metadata info 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 common.go:323: No Developer Tool Config File provided. 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 common.go:300: No Region Metadata Config File provided. 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 common.go:227: The Region Metadata Schema wasn't set in env variable - OCI_REGION_METADATA. 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 common.go:228: check from IMDS is disabled or IMDS had already been successfully visited, no need to check again. 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 common.go:108: cannot find realm for region : , return default realm value. 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 eventual_consistency.go:332: (pid=21812, gid=38) EcContext.GetEndOfWindow returns 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 asm_amd64.s:1650: Retry policy to use: {MaximumNumberAttempts=0, MinSleepBetween=0, MaxSleepBetween=0, ExponentialBackoffBase=0, NonEventuallyConsistentPolicy=} 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 asm_amd64.s:1650: operation attempt #1 2024-08-07T10:01:54.348+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348058 http.go:725: Marshaling to Request: DeleteBackupRequest 2024-08-07T10:01:54.349+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348595 http.go:643: Marshaling to path from field: BackupId in template: /backups/{backupId} 2024-08-07T10:01:54.349+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348595 http.go:639: Marshaling to header from field: IfMatch 2024-08-07T10:01:54.349+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348595 http.go:639: Header value is not mandatory and is nil pointer in field: IfMatch. Skipping header 2024-08-07T10:01:54.349+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348595 http.go:639: Marshaling to header from field: OpcRequestId 2024-08-07T10:01:54.349+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348595 http.go:520: add request id for header: opc-request-id, with value: 60fde197c5b40ad607acb81d7d78bdab 2024-08-07T10:01:54.349+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348595 http.go:698: RequestMetadata does not contain contributes tag. Skipping. 2024-08-07T10:01:54.349+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.348595 client.go:617: Attempting to call downstream service 2024-08-07T10:01:54.352+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: DEBUG 2024/08/07 10:01:54.352478 client.go:696: Dump Request DELETE /20190415/backups/ocid1.mysqlbackup.oc1.phx.aaaaaaaa5hmzjyv2fdw6xvwsan5hfqv52u273m4t2g7uyglbyqxibfyeey3a HTTP/1.1 2024-08-07T10:01:54.352+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Host: mysql..ocp.oraclecloud.com 2024-08-07T10:01:54.352+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: User-Agent: Oracle-GoSDK/65.70.0 (go/go1.21.8; windows/amd64; terraform/2.33.0; terraform-cli/1.9.0) Oracle-TerraformProvider/6.5.0 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Accept: / 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Authorization: Signature version="1",headers="date (request-target) host",keyId="ocid1.tenancy.oc1..aaaaaaaavnk4luuiasjkuhiizwnwust2xx3td7b4cbj5vhiccb47hra26p4q/ocid1.user.oc1..aaaaaaaafawx54qczcs5w6dtpfzjlcbewrczky3vixnds5tcsd5vlvfl3via/3b:36:ab:e9:71:e0:9f:70:4c:ad:4e:5a:3f:b1:dd:c0",algorithm="rsa-sha256",signature="jXipidXJIND22vHgn8SVT1K2XWtK/CHp5Odin8O0De1YYW/+R9K6u72Qasq6PyaoW21LBHEEQLJHizmSsCgKyZb8a6UOV3pcRUBwkg2GxgmUR72t0U6TQ8W9/GDRtBhHQ1VuqpCU82oXQR6j8LBpUAxsnXz1WQEyfayW++z6a5f+Dn+UE84zPxpG0fn+eApLA3SOCQvRcFNiyxOKPV6FyrmOSo4XnaWbmH4WnXF8+LE9nMXUy2arncxiYR4p1fLdZsigwMeuWGelZq9sIyTGXvnR/TQqX9FiuzMIMXodvTCQxT1teQkvpyE+K6AnhYLHpUKyJfYNrUgXrmWc05eX0A==" 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Content-Type: application/json 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Date: Wed, 07 Aug 2024 02:01:54 GMT 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Opc-Client-Info: Oracle-GoSDK/65.70.0 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Opc-Client-Retries: true 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Opc-Request-Id: 60fde197c5b40ad607acb81d7d78bdab 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: Accept-Encoding: gzip 2024-08-07T10:01:54.353+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe 2024-08-07T10:01:54.408+0800 [DEBUG] provider.terraform-provider-oci_v6.5.0.exe: INFO 2024/08/07 10:01:54.407955 log.go:229: Delete "https://mysql..ocp.oraclecloud.com/20190415/backups/ocid1.mysqlbackup.oc1.phx.aaaaaaaa5hmzjyv2fdw6xvwsan5hfqv52u273m4t2g7uyglbyqxibfyeey3a": dial tcp: lookup mysql..ocp.oraclecloud.com: no such host 2024-08-07T10:01:54.410+0800 [ERROR] provider.terraform-provider-oci_v6.5.0.exe: Response contains error diagnostic: @module=sdk.proto diagnostic_detail="" diagnostic_summary="Delete \"https://mysql..ocp.oraclecloud.com/20190415/backups/ocid1.mysqlbackup.oc1.phx.aaaaaaaa5hmzjyv2fdw6xvwsan5hfqv52u273m4t2g7uyglbyqxibfyeey3a\": dial tcp: lookup mysql..ocp.oraclecloud.com: no such host" tf_provider_addr=provider tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.22.0/tfprotov5/internal/diag/diagnostics.go:58 diagnostic_severity=ERROR tf_proto_version=5.4 tf_req_id=5cac2dbb-c91d-df58-72e2-9be74a23deb6 tf_resource_type=oci_mysql_mysql_backup timestamp="2024-08-07T10:01:54.409+0800" 2024-08-07T10:01:54.414+0800 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot 2024-08-07T10:01:54.415+0800 [ERROR] vertex "oci_mysql_mysql_backup.copy_mysql_backup (destroy)" error: Delete "https://mysql..ocp.oraclecloud.com/20190415/backups/ocid1.mysqlbackup.oc1.phx.aaaaaaaa5hmzjyv2fdw6xvwsan5hfqv52u273m4t2g7uyglbyqxibfyeey3a": dial tcp: lookup mysql..ocp.oraclecloud.com: no such host ╷ │ Error: Delete "https://mysql..ocp.oraclecloud.com/20190415/backups/ocid1.mysqlbackup.oc1.phx.aaaaaaaa5hmzjyv2fdw6xvwsan5hfqv52u273m4t2g7uyglbyqxibfyeey3a": dial tcp: lookup mysql..ocp.oraclecloud.com: no such host │ │ ╵ 2024-08-07T10:01:54.425+0800 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF" 2024-08-07T10:01:54.447+0800 [INFO] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/hashicorp/oci/6.5.0/windows_amd64/terraform-provider-oci_v6.5.0.exe id=21812 2024-08-07T10:01:54.447+0800 [DEBUG] provider: plugin exited

Expected Behavior

oci_mysql_mysql_backup.copy_mysql_backup deteled

Actual Behavior

return Error: Delete "https://mysql..ocp.oraclecloud.com/20190415/backups

Steps to Reproduce

terraform apply

terraform destroy

jansonkwo commented 1 month ago

it must set Environment Variables"TF_VAR_destination_region=us-phoenix-1", it is OK in terraform cli. Another issue: how to set this OS Environment Variable when use these terraform scripts in OCI Resource Manager?

tf-oci-pub commented 1 month ago

Thank you for reporting the issue. We have raised an internal ticket to track this. Our service engineers will get back to you.

aid23-tech commented 1 month ago
  1. The cross region backup copy does not support TF_VAR_destination_region, please refer this example configuration where source_region needs to be set as TF_VAR_source_region and the configuration needs to be applied at the destination region where the region value should point to the region where backup gets copied to (destination region)

  2. How to set the env variable in resource manager, please see https://docs.oracle.com/en-us/iaas/Content/ResourceManager/Concepts/terraformconfigresourcemanager.htm “When you run a job, the stack’s variable values are added as environment variables in the Resource Manager Terraform host.”

  3. Also, please confirm below details 3.1. The resource "oci_mysql_mysql_backup" "copy_mysql_backup" this was executed against the PHX region? 3.2. Did the copy backup complete successfully in PHX region?

jansonkwo commented 1 month ago

3.1. The resource "oci_mysql_mysql_backup" "copy_mysql_backup" this was executed against the PHX region? Had tried both PHX region as default provider region and alias provider. 3.2. Did the copy backup complete successfully in PHX region? Yes, ccopy backup complete successfully in PHX region.

aid23-tech commented 3 weeks ago

Could you please retry the copy backup again with Terraform config region as the destination region you want to create copy in? Could you also share complete configurations used in this process and if the copy deletion fails again, please share the OPC request id for the failed delete operation?

jansonkwo commented 3 weeks ago

Terraform config: provider "oci" { region = "us-phoenix-1" } resource "oci_mysql_mysql_backup" "copy_mysql_backup" {

Required

    compartment_id = "ocid1.compartment.oc1..aaaaaaaaXXXXXX"

#Optional
display_name = "copy-from-backup-ashburn"
source_details {
    region  = "us-ashburn-1"
    backup_id = "ocid1.mysqlbackup.oc1.iad.aaaaaaaaXXXXXXXXXXXXX"
    compartment_id  = "ocid1.compartment.oc1..aaaaaaaaXXXXXXXXXXXXX"
}

}

terraform apply result: mds backup from source region:ashburn create copy in destination region:phoenix.

terraform destroy result: Error: Delete "https://mysql..ocp.oraclecloud.com/20190415/backups/ocid1.mysqlbackup.oc1.phx.aaaaaaaaj2cxxvuxpwl7wgxybzggqwrurstofo2sj2h4sfxvmuycmpxo2doa": dial tcp: lookup mysql..ocp.oraclecloud.com: no such host

Opc-Request-Id: 1f91938971ccc4e1aca2fef24acd47dd

aid23-tech commented 2 weeks ago

Could you please share the complete log file by enabling below debug flags, if possible?

export TF_LOG=DEBUG
export OCI_GO_SDK_DEBUG=v
jansonkwo commented 3 days ago

destroy-log.txt terraform destroy attachment is debug log file.