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

Issues with advanced_configuration section on mongodbatlas_cluster #210

Closed
michelzanini opened this issue Apr 28, 2020 · 3 comments · Fixed by #238
Closed

Issues with advanced_configuration section on mongodbatlas_cluster #210

michelzanini opened this issue Apr 28, 2020 · 3 comments · Fixed by #238
Labels

Comments

@michelzanini
Copy link

Hi,

There are a few issues with the advanced_configuration section of mongodbatlas_cluster resource.

First, if I create a new cluster with this configuration:

advanced_configuration = {
    minimum_enabled_tls_protocol = "TLS1_2"
}

I would expect all settings to have default values expect the one I have defined. That means when calling /clusters/{name}/processArgs I should get this as a result:

{
    "failIndexKeyTooLong": true,
    "javascriptEnabled": true,
    "minimumEnabledTlsProtocol": "TLS1_2",
    "noTableScan": false,
    "oplogSizeMB": null,
    "sampleRefreshIntervalBIConnector": null,
    "sampleSizeBIConnector": null
}

But this is what I get instead:

{
    "failIndexKeyTooLong": false,
    "javascriptEnabled": false,
    "minimumEnabledTlsProtocol": "TLS1_2",
    "noTableScan": false,
    "oplogSizeMB": null,
    "sampleRefreshIntervalBIConnector": 0,
    "sampleSizeBIConnector": 0
}

The most important part here is that failIndexKeyTooLong and javascriptEnabled are true by default but they are false, even my configuration have not stated that I wanted to change those properties. I believe they should stay with default values. Also you can see that sampleRefreshIntervalBIConnector and sampleSizeBIConnector have values as 0 instead of null.

The next issue is the fact that even if I go and add the other flags such as:

advanced_configuration = {
    fail_index_key_too_long      = true
    javascript_enabled           = true
    minimum_enabled_tls_protocol = "TLS1_2"
}

Every time I run terraform plan the cluster resource always comes back with 1 change required. This is what appears on the change diff:


advanced_configuration       = {
         "fail_index_key_too_long"              = "true"
         "javascript_enabled"                   = "true"
         "minimum_enabled_tls_protocol"         = "TLS1_2"
       - "no_table_scan"                        = "false" -> null
       - "oplog_size_mb"                        = "" -> null
       - "sample_refresh_interval_bi_connector" = "0" -> null
       - "sample_size_bi_connector"             = "0" -> null
}

As you can see the properties that were omitted are always coming back as a difference. I think should not be the case. The only real option here is to have to define ALL variables such as:

advanced_configuration = {
    fail_index_key_too_long              = true
    javascript_enabled                   = true
    minimum_enabled_tls_protocol         = "TLS1_2"
    no_table_scan                        = false
    oplog_size_mb                        = ""
    sample_refresh_interval_bi_connector = "0"
    sample_size_bi_connector             = "0"
  }

But is not what the documentation says... besides, what would happen and a new property is created? The issues with ""/ 0 versus null are also worth looking into fixing...

Thanks.

@michelzanini
Copy link
Author

michelzanini commented Apr 28, 2020

I am using version 0.5.1 of the provider, Terraform version 0.12.16

@themantissa
Copy link
Collaborator

@michelzanini thank you for this one as well - confirmed as a bug, it should not modify any other options but does.

Workaround for now, as found, was to not send individual options but the entire block.

For developers, from my own tests:

State file attributes from general cluster creation:
            "advanced_configuration": {
              "fail_index_key_too_long": "true",
              "javascript_enabled": "true",
              "minimum_enabled_tls_protocol": "TLS1_1",
              "no_table_scan": "false",
              "oplog_size_mb": "",
              "sample_refresh_interval_bi_connector": "",
              "sample_size_bi_connector": ""
            },

Add single advanced_config option:
 advanced_configuration = {
    minimum_enabled_tls_protocol = "TLS1_2"
 }

attributes in diff w/ terraform plan

   advanced_configuration       = {
          - "fail_index_key_too_long"              = "true" -> null
          - "javascript_enabled"                   = "true" -> null
          ~ "minimum_enabled_tls_protocol"         = "TLS1_1" -> "TLS1_2"
          - "no_table_scan"                        = "false" -> null
          - "oplog_size_mb"                        = "" -> null
          - "sample_refresh_interval_bi_connector" = "" -> null
          - "sample_size_bi_connector"             = "" -> null
        }

Terraform state file after terraform apply:
           "advanced_configuration": {
              **"fail_index_key_too_long": "false",**
              **"javascript_enabled": "false",**
              "minimum_enabled_tls_protocol": "TLS1_2",
              **"no_table_scan": "false",**
              **"oplog_size_mb": "",**
              **"sample_refresh_interval_bi_connector": "0",**
              **"sample_size_bi_connector": "0"**

gmlp added a commit to gmlp/terraform-provider-mongodbatlas that referenced this issue May 7, 2020
gmlp pushed a commit that referenced this issue May 16, 2020
fix: fixes #210 Issue with advanced_configuration section on mongodbatlas_cluster
gmlp added a commit that referenced this issue May 18, 2020
@themantissa
Copy link
Collaborator

@michelzanini we have an improved PR w/ the fix if you happen to have time to check it out. Thank you so much for all your input on this one as we ensure we get it right!

gmlp added a commit that referenced this issue Jun 5, 2020
gmlp added a commit that referenced this issue Jun 8, 2020
@gmlp gmlp closed this as completed in #238 Jun 8, 2020
gmlp added a commit that referenced this issue Jun 8, 2020
…h-advanced_configuration-mongodbatlas_cluster_opt2

fixes #210: Issues with advanced_configuration section on mongodbatlas_cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment