-
Notifications
You must be signed in to change notification settings - Fork 190
fix: 'computed' and 'default' usage based on the documentation #1564
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
Conversation
@@ -308,19 +308,16 @@ func resourceMongoDBAtlasCluster() *schema.Resource { | |||
Type: schema.TypeSet, | |||
Optional: true, | |||
Set: HashFunctionForKeyValuePair, | |||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a fix for the error "attribute representing nested block must not be unknown itself"? Or simply an improvement seeing Atlas API does not respond with labels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's both basically - as per documentation nothing is returned and as you said it's deprecated.
I am really not sure why we used Computed here originally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes agree that computed is not accurate in this case.
I am curious if the same scenario is happening with bi_connector_config
and advanced_configuration
which were bringing a similar issue, no need to adjust in this PR but more for my understanding in case you looked into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AgustinBettati that's what I thought, but then something more complex happens there.
Why? What is the difference? The difference is that for labels we don't return anything, while for advanced_configuration
the backend does return default value like:
# advanced_configuration {
# # default_read_concern = ""
# # default_write_concern = ""
# fail_index_key_too_long = false
# javascript_enabled = true
# minimum_enabled_tls_protocol = "TLS1_2"
# no_table_scan = false
# oplog_min_retention_hours = 0
# # oplog_size_mb = 0
# sample_refresh_interval_bi_connector = 0
# sample_size_bi_connector = 0
# transaction_lifetime_limit_seconds = 0
# }
hence when I do the terraform apply
and it does a refresh and comparison it returns the error saying that it was expecting advanced_configuration count to be 0 but the read returned count 1
(which basically mean that when we read the backend we load that configuration because its values are default).
What I've just said should apply also for bi_connector_config
but I haven't tested that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Customer is complaining that using TF 1.0.8 certain fields are returning error because the provider (Atlas) is returning values but fields are not marked as "Computed". In other cases fields are marked as "Computed" but as per documentation these fields don't return values defined from the backend itself.
Documentation: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v1/#tag/Clusters/operation/updateClusterAdvancedConfiguration
Definition of "Computed":
Computed indicates whether the provider may return its own value for this attribute or not. Computed cannot be used with Required. If Required and Optional are both false, the attribute will be considered "read only" for the practitioner, with only the provider able to set its value.
This needs to go after #1548
Link to any related issue(s): https://jira.mongodb.org/browse/HELP-51509
Customer cannot upgrade TF version
Type of change:
Required Checklist:
Further comments