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

opensearch_config: only send PATCH on create if values set. #1268

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

andrewsomething
Copy link
Member

As reported in #1266, "creating" a digitalocean_database_opensearch_config without any setting leads to an error. This change protects against that by preventing sending the PATCH on create if no other values beside cluster_id are set.

Additionally, I ran into some issue running the acceptance test. One is a bug. We need to use GetOkExists when checking the value for a bool. If not, it is not correctly detected when being set to false.

There are also a few changes to the test that do not impact functionality which I will note inline.

Comment on lines -29 to +31
Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseOpensearchConfigConfigBasic, dbConfig, false, 1, "9223372036854775807"),
Config: fmt.Sprintf(testAccCheckDigitalOceanDatabaseOpensearchConfigConfigBasic, dbConfig, false, 1, "1000000000000000000"),
Copy link
Member Author

@andrewsomething andrewsomething Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're hitting a bug with upstream Terraform here. I've change this to another value to allow us to test the broader functionality despite this.

hashicorp/terraform-plugin-sdk#1215

Comment on lines +23 to +25
resource.TestCheckResourceAttr("digitalocean_database_opensearch_config.foobar", "enable_security_audit", "true"),
resource.TestCheckResourceAttr("digitalocean_database_opensearch_config.foobar", "ism_enabled", "true"),
resource.TestCheckResourceAttr("digitalocean_database_opensearch_config.foobar", "ism_history_enabled", "true"),
Copy link
Member Author

@andrewsomething andrewsomething Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently both ism_enabled and ism_history_enabled must be true when setting the other ism_history settings or the API returns errors, e.g.

        Error: Error updating Opensearch configuration: PATCH https://api.digitalocean.com/v2/databases/d6b65b4f-954d-4ee0-a29b-29eb2b4d228f/config: 422 (request "7f2461f9-6c49-4291-a304-364f1d5eb740") invalid 'user_config': invalid input for opensearch: 'ism_history_enabled' is a required property

I've added enable_security_audit so that we have another bool value to test changes. This exposed the other bug.

Copy link
Contributor

@loosla loosla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@andrewsomething andrewsomething merged commit 50f8555 into main Nov 18, 2024
3 checks passed
@andrewsomething andrewsomething deleted the asb/issues/1266 branch November 18, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants