Skip to content
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

oci_database_pluggable_database should be considered delete success when state is TERMINATED (as handled by RELOCATE_PDB) #2277

Open
chanstev opened this issue Jan 18, 2025 · 1 comment
Labels
bug In-Progress Terraform Team is working on the reproduce & fix

Comments

@chanstev
Copy link
Member

chanstev commented Jan 18, 2025

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version and Provider Version

Terraform v1.9.8
Oracle/oci 6.21.0

Affected Resource(s)

oci_database_pluggable_database

Terraform Configuration Files

1a. create new PDB2 in CDB1 first.

resource "oci_database_pluggable_database" "this" {
  container_database_id = "YOUR-CDB1-OCID-HERE" // CDB1
  pdb_name              = "PDB2" 
  pdb_admin_password    = "YOUR-OWN-PW-HERE"
  tde_wallet_password   = "YOUR-OWN-PW-HERE"
}

variable "pluggable_database_id" {
  type = string
  default = ""
}

output "pluggable_database_id" {
  value = oci_database_pluggable_database.this.id
}

1b. save ocid of pdb2 as tfvar

terraform output > pdb_id.tfvars
  1. then relocate PDB2 to CDB2 with updated terraform as below, terraform apply -var-file="pdb_id.tfvars"
resource "oci_database_pluggable_database" "this" {
  container_database_id = "YOUR-CDB2-OCID-HERE" // will trigger force replacement: create new pdb by relocating, then destroy to remove state of old pdb
  pdb_name              = "PDB2" 
  pdb_admin_password    = "YOUR-OWN-PW-HERE"
  tde_wallet_password   = "YOUR-OWN-PW-HERE"

  pdb_creation_type_details {
    creation_type = "RELOCATE_PDB"
    source_container_database_admin_password  = "YOUR-OWN-PW-HERE"
    source_pluggable_database_id = var.pluggable_database_id
  }
  lifecycle {
    create_before_destroy = true // create new pdb from source pdb before destory
    ignore_changes = [ pdb_creation_type_details ] // for idempotency 
  }
}

variable "pluggable_database_id" {
  type = string
  default = ""
}

output "pluggable_database_id" {
  value = oci_database_pluggable_database.this.id
}

Debug Output

https://gist.github.com/chanstev/c073ff4a3ecbca5602ba3a4476a3caa1

Panic Output

n/a

Expected Behavior

The destroy of old pdb should be considered success as the state is already TERMINATED, which is handled by the PDB relocation.

Actual Behavior

New PDB is created in new CDB successfully by relocation and old PDB in old CDB is terminated in OCI. However, terraform return Error 409 when clearing the state of old pdb.

│ Error: 409-IncorrectState, The operation cannot be performed because the Pluggable Database with ID ocid1.pluggabledatabase.oc1.eu-milan-1.xxxxx is in the TERMINATED state.

Steps to Reproduce

1a. terraform apply
1b. terraform output > pdb_id.tfvars
2a. update the script with relocation part
2b. terraform apply -var-file="pdb_id.tfvars"

Important Factoids

References

https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/database_pluggable_database

@chanstev chanstev added the bug label Jan 18, 2025
@tf-oci-pub tf-oci-pub added the In-Progress Terraform Team is working on the reproduce & fix label Jan 19, 2025
@tf-oci-pub
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug In-Progress Terraform Team is working on the reproduce & fix
Projects
None yet
Development

No branches or pull requests

2 participants