oracle / terraform-provider-oci

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

oci_data_safe_target_database failed to handle staled database registration #1856

Closed luckeyca closed 1 year ago

luckeyca commented 1 year ago

Community Note

Terraform Version and Provider Version

Terraform v1.4.5 on linux_amd64

provider registry.terraform.io/oracle/oci v4.117.0

Affected Resource(s)

oci_data_safe_target_database

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. 
# Please remove any sensitive information from configuration files before sharing them. 
use the sample code in the resource documentation

Expected Behavior

oci_data_safe_target_database should check and handle if the database is in standby mode before creating new registration or destroying the existing registration

Actual Behavior

terraform plan always works even if the target database is actually in standby mode which means there is NO proper validation code in place. As a result, if a previously registered database fails over to remote standby, and run "terraform destroy" to destroy the existing registration, the destroy will work. Then after the database fails back to be primary, it still shows as registered in data safe. In this case, when re-running terraform apply to register, even though terraform plan works, terraform apply will failed with only timeout error which again shows there is no error handling whatsoever which is very bad coding.

Steps to Reproduce

  1. terraform apply to register autonomous database primary
  2. failover the database to remote standby
  3. terraform destroy to destroy the registration
  4. failback the database to primary
  5. terraform apply to register. this will fail with timeout error only. no extra info given
  6. on oci console, manually de-register the data safe registration
  7. terraform apply again. this will succeed.

Important Factoids

References

tf-oci-pub commented 1 year ago

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

ManjunathGoudar88 commented 1 year ago

Now we added a fix to validate the autonomous database if it is on standby and tried to register it with data safe. Please note that, terraform plan will not do validations such as state, provider APIs, etc. After apply, we validate the ADB role and return the error messages.

ManjunathGoudar88 commented 1 year ago

Fix will be available by jun 15th.

ManjunathGoudar88 commented 1 year ago

@luckeyca Please let us know if any assistance from the Oracle side on this issue, or else request to close this issue.