oracle / terraform-provider-oci

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

database_management_status "NOT_ENABLED" state is not storing tf state file #2169

Open kk-hiraskar opened 3 months ago

kk-hiraskar commented 3 months ago

Community Note

Terraform Version and Provider Version

Terraform version: 1.2.x (HashiCorp)

Affected Resource(s)

resource "oci_database_autonomous_database" "atp_db"
database_management_status

affected_resources = oci_database_autonomous_database

Issue

Document is not giving information on valid values that can be assigned to database_management_status https://registry.terraform.io/providers/oracle/oci/latest/docs/data-sources/database_autonomous_database#database_management_status

However using empty string "" and "ENABLED" is working.
But the issue is observed when we wanted to disable DB Management.
And setting it to empty string "" was deleting the resource oci_database_management_managed_database_group but however inside ATP it's status was still shown as enabled.

So when setting value to "NOT_ENABLED" cleared this problem and inside ATP, database management status is also shown good. means "ENABLED" -> "NOT_ENABLED" worked good, no issue.

But the another issue is observed, when we were applying some other change where the unexpected ATP changes are shown

 ~ resource "oci_database_autonomous_database" "atp_db" {
        ~ database_management_status             = "" -> "NOT_ENABLED"

means on the 1st apply instead actual NOT_ENABLED state it is storing as empty and in next plans it is trying to set unintended change from empty to NOT_ENABLED again!

and also this next apply is failing with error..

Error: failed to add Managed Database, error: Error returned by DbManagement Service. Http Status Code: 404. Error Code: NotAuthorizedOrNotFound. Opc request id: 069ad890a3b406a0f9b81406c8ea55b4/xxxxx/xxxx. Message: Authorization failed or requested resource ocid1.autonomousdatabase.oc1.iad.aaaaaaaaaaaxxxxxxxx not found.
Operation Name: AddManagedDatabaseToManagedDatabaseGroup
Timestamp: 2024-07-24 20:18:13 +0000 GMT
Client Version: Oracle-GoSDK/65.47.0
Request Endpoint: POST https://dbmgmt.us-ashburn-1.oci.oraclecloud.com/20201101/managedDatabaseGroups/ocid1.dbmgmtmanageddatabasegroup.oc1.iad.aaaaaaaaaaaxxxxxxxx /actions/addManagedDatabase
Troubleshooting Tips: See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_404__404_notauthorizedornotfound for more information about resolving this error.
Also see https://docs.oracle.com/iaas/api/#/en/database-management/20201101/ManagedDatabaseGroup/AddManagedDatabaseToManagedDatabaseGroup for details on this operation's requirements.
To get more info on the failing request, you can set OCI_GO_SDK_DEBUG env var to info or higher level to log the request/response details.
If you are unable to resolve this DbManagement issue, please contact Oracle support and provide them this full error message.

  with oci_database_management_managed_database_group.atp_managed_database_group[0],
  on atp.tf line 277, in resource "oci_database_management_managed_database_group" "atp_managed_database_group":
 277: resource "oci_database_management_managed_database_group" "atp_managed_database_group" {

Expected Behavior

  1. Please document the valid values to database_management_status
  2. NOT_ENABLED state is not stored, and causing issues in successive plan/apply.

Actual Behavior

after setting database management to NOT_ENABLED, any successive plan/apply should not show ATP change, even when nothing changed on ATP

Steps to Reproduce

  1. Create a resource "oci_database_autonomous_database" with "database_management_status" ENABLED
  2. change "database_management_status" to empty and apply, database management resource will be removed but not inside ATP it's status set to disabled on OCI web console.
  3. retry changing "database_management_status" to "NOT_ENABLED" and apply, with this resource will be removed (if not yet) and also ATP status will be set to disabled. ๐Ÿ‘
  4. Now without changing anything, just plan/apply again.. issue will be reproduced!! ๐Ÿ‘Ž

Important Factoids

OCI stack resource is used for all terraform actions

References

-

tf-oci-pub commented 3 months ago

Thank you for reporting the issue. We observed the affected resources are not provided in the description or it's incorrect. We request you to add it in issue description as mentioned in below format. Example: affected_resources = oci_core_instance , oci_core_instances

If it's not related to any particular resource then mention affected resource as terraform. Example: affected_resources = terraform

As this works through automation, request you to follow exact syntax.

kk-hiraskar commented 3 months ago

Updated,

affected_resources = oci_database_autonomous_database