terraform-provider-oci
terraform-provider-oci copied to clipboard
oci_database_db_home is force replaced when older databases are moved into the home
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.1.5 on linux_amd64
- provider registry.terraform.io/hashicorp/oci v4.63.0
Affected Resource(s)
oci_database_db_home (I'm using ExaCS)
Output
Just including a sample. See steps to reproduce.
# oci_database_db_home.test must be replaced
-/+ resource "oci_database_db_home" "test" {
...
~ database {
....
~ db_name = "XYZ" -> "ABC" # forces replacement
~ pdb_name = "XYZ1" -> "ABC1" # forces replacement
}
...
}
Expected Behavior
When we create a oci_database_db_home, and then move older databases into that home (upgrade CDBs), then the provider should not force recreate the db home.
Actual Behavior
When we create a oci_database_db_home, and then move older databases into that home (upgrade CDBs), then the provider is force recreating the db home.
Steps to Reproduce
Example:
We have an existing 19.12 db home:
- db_name: ABC
- pdb_name: ABC1
Then create a 19.14 home using the provider
- db_name: XYZ
- pdb_name: XYZ1
So ABC is the oldest CDB, while XYZ. We now want to upgrade ABC to 19.14, so we move the database to the 19.14 home. XYZ is the CDB associated with the home in the provider. ABC is the oldest CDB of the two.
When we then run plan, the db home must be replaced.
Important Factoids
The root of this problem is found in the getDatabaseInfo() function.
The current logic: list all databases in the home and assume that the oldest database is related to the resource. This logic fails when we move older databases into the home.
References
For us, the best fix for this bug would be to to introduce a new resource that allows us to create a home without any database or make the database bits of oci_database_db_home optional as suggested in #1219 .