From ead56a2cfc5c3963acf3ea8f2c5309fc26a74279 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 26 Nov 2024 10:29:46 +0000 Subject: [PATCH 01/17] add default max time attr --- docs/data-sources/advanced_cluster.md | 1 + docs/data-sources/advanced_clusters.md | 1 + docs/resources/advanced_cluster.md | 1 + .../advancedcluster/model_advanced_cluster.go | 28 ++++++++++ .../resource_advanced_cluster.go | 3 +- .../resource_advanced_cluster_test.go | 51 +++++++++++++------ 6 files changed, 68 insertions(+), 17 deletions(-) diff --git a/docs/data-sources/advanced_cluster.md b/docs/data-sources/advanced_cluster.md index 0b69cd8796..a03d54bc6d 100644 --- a/docs/data-sources/advanced_cluster.md +++ b/docs/data-sources/advanced_cluster.md @@ -200,6 +200,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). ## Attributes Reference diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index c1d26b12e3..57696debad 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -202,6 +202,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `oplog_min_retention_hours` - Minimum retention window for cluster's oplog expressed in hours. A value of null indicates that the cluster uses the default minimum oplog window that MongoDB Cloud calculates. * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index a69410b922..baa3e3d73e 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -460,6 +460,7 @@ Include **desired options** within advanced_configuration: * `sample_refresh_interval_bi_connector` - (Optional) Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This option corresponds to the `changeStreamOptions.preAndPostImages.expireAfterSeconds` cluster parameter. Defaults to `-1`(off). This setting controls the retention policy of change stream pre- and post-images. Pre- and post-images are the versions of a document before and after document modification, respectively. `expireAfterSeconds` controls how long MongoDB retains pre- and post-images. When set to -1 (off), MongoDB uses the default retention policy: pre- and post-images are retained until the corresponding change stream events are removed from the oplog. To set the minimum pre- and post-image retention time, specify an integer value greater than zero. Setting this too low could increase the risk of interrupting Realm sync or triggers processing. This parameter is only supported for MongoDB version 6.0 and above. +* `default_max_time_ms` - (Optional) Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. ### Tags diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 5ccd0b284a..2a93687576 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -117,6 +117,10 @@ func SchemaAdvancedConfigDS() *schema.Schema { Type: schema.TypeInt, Computed: true, }, + "default_max_time_ms": { + Type: schema.TypeInt, + Computed: true, + }, }, }, } @@ -262,6 +266,11 @@ func SchemaAdvancedConfig() *schema.Schema { Optional: true, Default: -1, }, + "default_max_time_ms": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + }, }, }, } @@ -511,7 +520,17 @@ func flattenProcessArgs(p20240530 *admin20240530.ClusterDescriptionProcessArgs, } else { flattenedProcessArgs[0]["change_stream_options_pre_and_post_images_expire_after_seconds"] = p.GetChangeStreamOptionsPreAndPostImagesExpireAfterSeconds() } + + // if v := p.DefaultMaxTimeMS; v == nil { + // flattenedProcessArgs[0]["default_max_time_ms"] = -1 // default in schema, otherwise user gets drift detection + // } else { + // flattenedProcessArgs[0]["default_max_time_ms"] = p.GetDefaultMaxTimeMS() + // } + if v := p.DefaultMaxTimeMS; v != nil { + flattenedProcessArgs[0]["default_max_time_ms"] = p.GetDefaultMaxTimeMS() + } } + return flattenedProcessArgs } @@ -852,6 +871,15 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer res.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.IntPtr(tmpInt) } + + if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { + if defaultMaxTime := cast.ToInt64(p["default_max_time_ms"]); defaultMaxTime != 0 { + res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) + } else { + log.Printf(ErrorClusterSetting, `default_max_time_ms`, "", cast.ToString(defaultMaxTime)) + } + } + return res20240530, res } diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index bf3d005551..d8ce6186b6 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -502,7 +502,8 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. if err != nil { return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) } - _, _, err = connV2.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms).Execute() + tmp, _, err := connV2.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms).Execute() + log.Println(tmp) if err != nil { return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) } diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index a6ee09b030..d65aa16a91 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -248,10 +248,10 @@ func TestAccClusterAdvancedCluster_pausedToUnpaused(t *testing.T) { func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { acc.SkipIfTPFAdvancedCluster(t) var ( - projectID = acc.ProjectIDExecution(t) - clusterName = acc.RandomClusterName() - clusterNameUpdated = acc.RandomClusterName() - processArgs = &admin20240530.ClusterDescriptionProcessArgs{ + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + clusterNameUpdated = acc.RandomClusterName() + processArgs20240530 = &admin20240530.ClusterDescriptionProcessArgs{ DefaultReadConcern: conversion.StringPtr("available"), DefaultWriteConcern: conversion.StringPtr("1"), FailIndexKeyTooLong: conversion.Pointer(false), @@ -263,7 +263,12 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { SampleSizeBIConnector: conversion.Pointer(110), TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), } - processArgsUpdated = &admin20240530.ClusterDescriptionProcessArgs{ + processArgs = &admin.ClusterDescriptionProcessArgs20240805{ + DefaultMaxTimeMS: conversion.IntPtr(60), + ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the config + } + + processArgs20240530Updated = &admin20240530.ClusterDescriptionProcessArgs{ DefaultReadConcern: conversion.StringPtr("available"), DefaultWriteConcern: conversion.StringPtr("0"), FailIndexKeyTooLong: conversion.Pointer(false), @@ -275,6 +280,10 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { SampleSizeBIConnector: conversion.Pointer(110), TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), } + processArgsUpdated = &admin.ClusterDescriptionProcessArgs20240805{ + DefaultMaxTimeMS: conversion.IntPtr(65), + ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(100), + } ) resource.ParallelTest(t, resource.TestCase{ @@ -283,12 +292,12 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configAdvanced(projectID, clusterName, processArgs, nil), - Check: checkAdvanced(clusterName, "TLS1_1", "-1"), + Config: configAdvanced(projectID, clusterName, processArgs20240530, processArgs), + Check: checkAdvanced(clusterName, "TLS1_1", processArgs), }, { - Config: configAdvanced(projectID, clusterNameUpdated, processArgsUpdated, conversion.IntPtr(100)), - Check: checkAdvanced(clusterNameUpdated, "TLS1_2", "100"), + Config: configAdvanced(projectID, clusterNameUpdated, processArgs20240530Updated, processArgsUpdated), + Check: checkAdvanced(clusterNameUpdated, "TLS1_2", processArgs), }, }, }) @@ -1320,10 +1329,16 @@ func checkSingleProviderPaused(name string, paused bool) resource.TestCheckFunc "paused": strconv.FormatBool(paused)}) } -func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescriptionProcessArgs, changeStreamOptions *int) string { +func configAdvanced(projectID, clusterName string, p20240530 *admin20240530.ClusterDescriptionProcessArgs, p *admin.ClusterDescriptionProcessArgs20240805) string { changeStreamOptionsString := "" - if changeStreamOptions != nil { - changeStreamOptionsString = fmt.Sprintf(`change_stream_options_pre_and_post_images_expire_after_seconds = %[1]d`, *changeStreamOptions) + defaultMaxTimeString := "" + if p != nil { + if p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != conversion.IntPtr(-1) { + changeStreamOptionsString = fmt.Sprintf(`change_stream_options_pre_and_post_images_expire_after_seconds = %[1]d`, *p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds) + } + if p.DefaultMaxTimeMS != nil { + defaultMaxTimeString = fmt.Sprintf(`default_max_time_ms = %[1]d`, *p.DefaultMaxTimeMS) + } } return fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { @@ -1357,6 +1372,7 @@ func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescr sample_refresh_interval_bi_connector = %[9]d transaction_lifetime_limit_seconds = %[10]d %[11]s + %[12]s } } @@ -1369,11 +1385,12 @@ func configAdvanced(projectID, clusterName string, p *admin20240530.ClusterDescr project_id = mongodbatlas_advanced_cluster.test.project_id } `, projectID, clusterName, - p.GetFailIndexKeyTooLong(), p.GetJavascriptEnabled(), p.GetMinimumEnabledTlsProtocol(), p.GetNoTableScan(), - p.GetOplogSizeMB(), p.GetSampleSizeBIConnector(), p.GetSampleRefreshIntervalBIConnector(), p.GetTransactionLifetimeLimitSeconds(), changeStreamOptionsString) + p20240530.GetFailIndexKeyTooLong(), p20240530.GetJavascriptEnabled(), p20240530.GetMinimumEnabledTlsProtocol(), p20240530.GetNoTableScan(), + p20240530.GetOplogSizeMB(), p20240530.GetSampleSizeBIConnector(), p20240530.GetSampleRefreshIntervalBIConnector(), p20240530.GetTransactionLifetimeLimitSeconds(), + changeStreamOptionsString, defaultMaxTimeString) } -func checkAdvanced(name, tls, changeStreamOptions string) resource.TestCheckFunc { +func checkAdvanced(name, tls string, processArgs *admin.ClusterDescriptionProcessArgs20240805) resource.TestCheckFunc { return checkAggr( []string{"project_id", "replication_specs.#", "replication_specs.0.region_configs.#"}, map[string]string{ @@ -1386,7 +1403,9 @@ func checkAdvanced(name, tls, changeStreamOptions string) resource.TestCheckFunc "advanced_configuration.0.sample_refresh_interval_bi_connector": "310", "advanced_configuration.0.sample_size_bi_connector": "110", "advanced_configuration.0.transaction_lifetime_limit_seconds": "300", - "advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds": changeStreamOptions}, + "advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds": strconv.Itoa(*processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds), + "advanced_configuration.0.default_max_time_ms": strconv.Itoa(*processArgs.DefaultMaxTimeMS), + }, resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.#"), resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.replication_specs.#"), resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.name")) From 224e10a8ec693f6502d6c3331484691fefa40384 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 26 Nov 2024 10:44:57 +0000 Subject: [PATCH 02/17] update test --- .../advancedcluster/model_advanced_cluster.go | 12 +++++++----- .../advancedcluster/resource_advanced_cluster.go | 4 ++-- .../resource_advanced_cluster_test.go | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 2a93687576..14593ebadb 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -873,11 +873,13 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer } if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { - if defaultMaxTime := cast.ToInt64(p["default_max_time_ms"]); defaultMaxTime != 0 { - res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) - } else { - log.Printf(ErrorClusterSetting, `default_max_time_ms`, "", cast.ToString(defaultMaxTime)) - } + res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) + + // if defaultMaxTime := cast.ToInt64(p["default_max_time_ms"]); defaultMaxTime != 0 { + // res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) + // } else { + // log.Printf(ErrorClusterSetting, `default_max_time_ms`, "", cast.ToString(defaultMaxTime)) + // } } return res20240530, res diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index d8ce6186b6..91d03f9d1f 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -502,8 +502,8 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. if err != nil { return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) } - tmp, _, err := connV2.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms).Execute() - log.Println(tmp) + _, _, err = connV2.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms).Execute() + // log.Println(tmp) if err != nil { return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) } diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index d65aa16a91..a0b62f3e50 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -264,7 +264,7 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), } processArgs = &admin.ClusterDescriptionProcessArgs20240805{ - DefaultMaxTimeMS: conversion.IntPtr(60), + // DefaultMaxTimeMS: conversion.IntPtr(60), ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the config } @@ -297,7 +297,7 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { }, { Config: configAdvanced(projectID, clusterNameUpdated, processArgs20240530Updated, processArgsUpdated), - Check: checkAdvanced(clusterNameUpdated, "TLS1_2", processArgs), + Check: checkAdvanced(clusterNameUpdated, "TLS1_2", processArgsUpdated), }, }, }) From 78e7a5fd12fdeabc4e1a1f24b7c3c8c456f0d78c Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 26 Nov 2024 12:34:33 +0000 Subject: [PATCH 03/17] make optional --- internal/service/advancedcluster/model_advanced_cluster.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 14593ebadb..cadb2569e7 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -269,7 +269,6 @@ func SchemaAdvancedConfig() *schema.Schema { "default_max_time_ms": { Type: schema.TypeInt, Optional: true, - Computed: true, }, }, }, From 646dd78d16e11c0b7a6939b56a45ee4571a97fc3 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 26 Nov 2024 14:40:42 +0000 Subject: [PATCH 04/17] minor --- .../resource_advanced_cluster_test.go | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index a0b62f3e50..12cf5969df 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -1391,24 +1391,30 @@ func configAdvanced(projectID, clusterName string, p20240530 *admin20240530.Clus } func checkAdvanced(name, tls string, processArgs *admin.ClusterDescriptionProcessArgs20240805) resource.TestCheckFunc { + advancedConfig := map[string]string{ + "name": name, + "advanced_configuration.0.minimum_enabled_tls_protocol": tls, + "advanced_configuration.0.fail_index_key_too_long": "false", + "advanced_configuration.0.javascript_enabled": "true", + "advanced_configuration.0.no_table_scan": "false", + "advanced_configuration.0.oplog_size_mb": "1000", + "advanced_configuration.0.sample_refresh_interval_bi_connector": "310", + "advanced_configuration.0.sample_size_bi_connector": "110", + "advanced_configuration.0.transaction_lifetime_limit_seconds": "300", + "advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds": strconv.Itoa(*processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds), + } + + if processArgs.DefaultMaxTimeMS != nil { + advancedConfig["advanced_configuration.0.default_max_time_ms"] = strconv.Itoa(*processArgs.DefaultMaxTimeMS) + } + return checkAggr( []string{"project_id", "replication_specs.#", "replication_specs.0.region_configs.#"}, - map[string]string{ - "name": name, - "advanced_configuration.0.minimum_enabled_tls_protocol": tls, - "advanced_configuration.0.fail_index_key_too_long": "false", - "advanced_configuration.0.javascript_enabled": "true", - "advanced_configuration.0.no_table_scan": "false", - "advanced_configuration.0.oplog_size_mb": "1000", - "advanced_configuration.0.sample_refresh_interval_bi_connector": "310", - "advanced_configuration.0.sample_size_bi_connector": "110", - "advanced_configuration.0.transaction_lifetime_limit_seconds": "300", - "advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds": strconv.Itoa(*processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds), - "advanced_configuration.0.default_max_time_ms": strconv.Itoa(*processArgs.DefaultMaxTimeMS), - }, + advancedConfig, resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.#"), resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.replication_specs.#"), - resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.name")) + resource.TestCheckResourceAttrSet(dataSourcePluralName, "results.0.name"), + ) } func configAdvancedDefaultWrite(projectID, clusterName string, p *admin20240530.ClusterDescriptionProcessArgs) string { From f7d31005bc741d74743e573ab569aa0f7ddc17a9 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 26 Nov 2024 15:04:22 +0000 Subject: [PATCH 05/17] migration --- .../resource_advanced_cluster_migration_test.go | 6 ++++-- .../advancedcluster/resource_advanced_cluster_test.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go index 5b8afe8189..ffe82fcda4 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_migration_test.go @@ -149,7 +149,7 @@ func TestMigAdvancedCluster_geoShardedMigrationFromOldToNewSchema(t *testing.T) func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { acc.SkipIfTPFAdvancedCluster(t) - mig.SkipIfVersionBelow(t, "1.19.0") // version where change_stream_options_pre_and_post_images_expire_after_seconds was introduced + mig.SkipIfVersionBelow(t, "1.22.1") // version where default_max_time_ms was introduced var ( projectID = acc.ProjectIDExecution(t) clusterName = acc.RandomClusterName() @@ -179,7 +179,8 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { no_table_scan = false default_read_concern = "available" sample_size_bi_connector = 110 - sample_refresh_interval_bi_connector = 310 + sample_refresh_interval_bi_connector = 310 + default_max_time_ms = 65 } bi_connector_config { @@ -219,6 +220,7 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.no_table_scan", "false"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.sample_refresh_interval_bi_connector", "310"), resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.sample_size_bi_connector", "110"), + resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.default_max_time_ms", "65"), resource.TestCheckResourceAttr(resourceName, "bi_connector_config.0.enabled", "false"), resource.TestCheckResourceAttr(resourceName, "bi_connector_config.0.read_preference", "secondary"), ), diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index 12cf5969df..e521a2e66f 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -265,7 +265,7 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { } processArgs = &admin.ClusterDescriptionProcessArgs20240805{ // DefaultMaxTimeMS: conversion.IntPtr(60), - ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the config + ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the TF configuration } processArgs20240530Updated = &admin20240530.ClusterDescriptionProcessArgs{ From 667b347131d3147d028900a78212618b5dd11213 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 26 Nov 2024 15:17:11 +0000 Subject: [PATCH 06/17] cleanup --- .../service/advancedcluster/model_advanced_cluster.go | 11 ----------- .../advancedcluster/resource_advanced_cluster.go | 1 - .../advancedcluster/resource_advanced_cluster_test.go | 1 - 3 files changed, 13 deletions(-) diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index cadb2569e7..350db4c158 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -520,11 +520,6 @@ func flattenProcessArgs(p20240530 *admin20240530.ClusterDescriptionProcessArgs, flattenedProcessArgs[0]["change_stream_options_pre_and_post_images_expire_after_seconds"] = p.GetChangeStreamOptionsPreAndPostImagesExpireAfterSeconds() } - // if v := p.DefaultMaxTimeMS; v == nil { - // flattenedProcessArgs[0]["default_max_time_ms"] = -1 // default in schema, otherwise user gets drift detection - // } else { - // flattenedProcessArgs[0]["default_max_time_ms"] = p.GetDefaultMaxTimeMS() - // } if v := p.DefaultMaxTimeMS; v != nil { flattenedProcessArgs[0]["default_max_time_ms"] = p.GetDefaultMaxTimeMS() } @@ -873,12 +868,6 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) - - // if defaultMaxTime := cast.ToInt64(p["default_max_time_ms"]); defaultMaxTime != 0 { - // res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) - // } else { - // log.Printf(ErrorClusterSetting, `default_max_time_ms`, "", cast.ToString(defaultMaxTime)) - // } } return res20240530, res diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 91d03f9d1f..bf3d005551 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -503,7 +503,6 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) } _, _, err = connV2.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms).Execute() - // log.Println(tmp) if err != nil { return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) } diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index e521a2e66f..6ca9b81dca 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -264,7 +264,6 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), } processArgs = &admin.ClusterDescriptionProcessArgs20240805{ - // DefaultMaxTimeMS: conversion.IntPtr(60), ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the TF configuration } From b4b44d7874999650b071d98376c916e19d02d78b Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 26 Nov 2024 16:12:18 +0000 Subject: [PATCH 07/17] add changelog --- .changelog/2825.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changelog/2825.txt diff --git a/.changelog/2825.txt b/.changelog/2825.txt new file mode 100644 index 0000000000..42e2f3cdcd --- /dev/null +++ b/.changelog/2825.txt @@ -0,0 +1,11 @@ +```release-note:note +resource/mongodbatlas_advanced_cluster: Adds new `advanced_configuration.0.default_max_time_ms` attribute +``` + +```release-note:note +data-source/mongodbatlas_advanced_cluster: Adds new `advanced_configuration.0.default_max_time_ms` attribute +``` + +```release-note:note +data-source/mongodbatlas_advanced_clusters: Adds new `advanced_configuration.0.default_max_time_ms` attribute +``` From 6ff282f63518067f3a36083ccf263f65260e6d0b Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Wed, 27 Nov 2024 09:54:36 +0000 Subject: [PATCH 08/17] update readme --- internal/service/advancedclustertpf/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/service/advancedclustertpf/README.md b/internal/service/advancedclustertpf/README.md index 8275f6fd58..35da6d6ca8 100644 --- a/internal/service/advancedclustertpf/README.md +++ b/internal/service/advancedclustertpf/README.md @@ -6,4 +6,6 @@ This package contains the WIP for `mongodbatlas_advanced_cluster` in TPF. Curren ## Changes in advancedcluster that needs to be added here (list changes done in advancedcluster which couldn't also be done here at that moment) +- [PR #2825](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2825) Add new `advanced_configuration.0.default_max_time_ms` attribute to mongodbatlas_advanced_cluster resource and data sources + From 1be1abaa72abbdd45f1e534da399408a918d7533 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Thu, 28 Nov 2024 13:42:29 +0000 Subject: [PATCH 09/17] mdb version check --- docs/data-sources/advanced_cluster.md | 2 +- docs/data-sources/advanced_clusters.md | 2 +- docs/resources/advanced_cluster.md | 2 +- .../advancedcluster/model_advanced_cluster.go | 19 ++++++++++++++----- .../resource_advanced_cluster.go | 19 +++++++++++++++---- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/docs/data-sources/advanced_cluster.md b/docs/data-sources/advanced_cluster.md index a03d54bc6d..faaaf24253 100644 --- a/docs/data-sources/advanced_cluster.md +++ b/docs/data-sources/advanced_cluster.md @@ -200,7 +200,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. -* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. Available in MongoDB version 8.0 and above. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). ## Attributes Reference diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index 57696debad..9f357c07f7 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -202,7 +202,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `oplog_min_retention_hours` - Minimum retention window for cluster's oplog expressed in hours. A value of null indicates that the cluster uses the default minimum oplog window that MongoDB Cloud calculates. * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. -* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. Available in MongoDB version 8.0 and above. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index baa3e3d73e..fb3abf58b9 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -460,7 +460,7 @@ Include **desired options** within advanced_configuration: * `sample_refresh_interval_bi_connector` - (Optional) Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This option corresponds to the `changeStreamOptions.preAndPostImages.expireAfterSeconds` cluster parameter. Defaults to `-1`(off). This setting controls the retention policy of change stream pre- and post-images. Pre- and post-images are the versions of a document before and after document modification, respectively. `expireAfterSeconds` controls how long MongoDB retains pre- and post-images. When set to -1 (off), MongoDB uses the default retention policy: pre- and post-images are retained until the corresponding change stream events are removed from the oplog. To set the minimum pre- and post-image retention time, specify an integer value greater than zero. Setting this too low could increase the risk of interrupting Realm sync or triggers processing. This parameter is only supported for MongoDB version 6.0 and above. -* `default_max_time_ms` - (Optional) Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. +* `default_max_time_ms` - (Optional) Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. Available in MongoDB version 8.0 and above. ### Tags diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 350db4c158..5b6a543008 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -25,6 +25,7 @@ import ( ) const minVersionForChangeStreamOptions = 6.0 +const minVersionForDefaultMaxTimeMS = 8.0 var ( DSTagsSchema = schema.Schema{ @@ -799,7 +800,7 @@ func getAdvancedClusterContainerID(containers []admin.CloudProviderContainer, cl return "" } -func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVersion *string) (admin20240530.ClusterDescriptionProcessArgs, admin.ClusterDescriptionProcessArgs20240805) { +func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVersion *string) (admin20240530.ClusterDescriptionProcessArgs, admin.ClusterDescriptionProcessArgs20240805, error) { res20240530 := admin20240530.ClusterDescriptionProcessArgs{} res := admin.ClusterDescriptionProcessArgs20240805{} @@ -866,14 +867,14 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer res.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.IntPtr(tmpInt) } - if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { + if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok && IsDefaultMaxTimeMinRequiredMajorVersion(mongodbMajorVersion){ res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) } - return res20240530, res + return res20240530, res, nil } -func IsChangeStreamOptionsMinRequiredMajorVersion(input *string) bool { +func isMinRequiredMajorVersion(input *string, minVersion float64) bool { if input == nil || *input == "" { return true } @@ -887,7 +888,15 @@ func IsChangeStreamOptionsMinRequiredMajorVersion(input *string) bool { return false } - return value >= minVersionForChangeStreamOptions + return value >= minVersion +} + +func IsChangeStreamOptionsMinRequiredMajorVersion(input *string) bool { + return isMinRequiredMajorVersion(input, minVersionForChangeStreamOptions) +} + +func IsDefaultMaxTimeMinRequiredMajorVersion(input *string) bool { + return isMinRequiredMajorVersion(input, minVersionForDefaultMaxTimeMS) } func expandLabelSliceFromSetSchema(d *schema.ResourceData) ([]admin20240805.ComponentLabel, diag.Diagnostics) { diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index bf3d005551..5e4ddc2300 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -472,12 +472,17 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. params.ConfigServerManagementMode = conversion.StringPtr(v.(string)) } - // Validate oplog_size_mb to show the error before the cluster is created. + // Validate advanced configuration params to show the error before the cluster is created. if oplogSizeMB, ok := d.GetOkExists("advanced_configuration.0.oplog_size_mb"); ok { if cast.ToInt64(oplogSizeMB) < 0 { return diag.FromErr(fmt.Errorf("`advanced_configuration.oplog_size_mb` cannot be < 0")) } } + if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { + if !IsDefaultMaxTimeMinRequiredMajorVersion(params.MongoDBMajorVersion) { + return diag.FromErr(fmt.Errorf("default_max_time_ms can not be set for mongo_db_major_version lower than 8.0")) + } + } if err := CheckRegionConfigsPriorityOrder(params.GetReplicationSpecs()); err != nil { return diag.FromErr(err) @@ -497,8 +502,11 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. if ac, ok := d.GetOk("advanced_configuration"); ok { if aclist, ok := ac.([]any); ok && len(aclist) > 0 { - params20240530, params := expandProcessArgs(d, aclist[0].(map[string]any), params.MongoDBMajorVersion) - _, _, err := connV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms20240530).Execute() + params20240530, params, err := expandProcessArgs(d, aclist[0].(map[string]any), params.MongoDBMajorVersion) + if err != nil { + return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) + } + _, _, err = connV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms20240530).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) } @@ -899,7 +907,10 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. ac := d.Get("advanced_configuration") if aclist, ok := ac.([]any); ok && len(aclist) > 0 { - params20240530, params := expandProcessArgs(d, aclist[0].(map[string]any), &mongoDBMajorVersion) + params20240530, params, err := expandProcessArgs(d, aclist[0].(map[string]any), &mongoDBMajorVersion) + if err != nil { + return diag.FromErr(fmt.Errorf(errorConfigUpdate, clusterName, err)) + } if !reflect.DeepEqual(params20240530, admin20240530.ClusterDescriptionProcessArgs{}) { _, _, err := connV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, ¶ms20240530).Execute() if err != nil { From 87ec3711b3a2297184528d75727d3a7553901c96 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Thu, 28 Nov 2024 13:45:16 +0000 Subject: [PATCH 10/17] fmt --- internal/service/advancedcluster/model_advanced_cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index 5b6a543008..e299f72cc1 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -867,7 +867,7 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer res.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.IntPtr(tmpInt) } - if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok && IsDefaultMaxTimeMinRequiredMajorVersion(mongodbMajorVersion){ + if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok && IsDefaultMaxTimeMinRequiredMajorVersion(mongodbMajorVersion) { res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) } From 21d9cf0ae27fb79e43ddac9f3679497be6aa62be Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Fri, 29 Nov 2024 06:22:42 +0000 Subject: [PATCH 11/17] add validation --- .../service/advancedcluster/model_advanced_cluster.go | 8 ++++++-- .../service/advancedcluster/resource_advanced_cluster.go | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index e299f72cc1..bf9be6b214 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -867,8 +867,12 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer res.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.IntPtr(tmpInt) } - if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok && IsDefaultMaxTimeMinRequiredMajorVersion(mongodbMajorVersion) { - res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) + if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { + if IsDefaultMaxTimeMinRequiredMajorVersion(mongodbMajorVersion) { + res.DefaultMaxTimeMS = conversion.Pointer(cast.ToInt(p["default_max_time_ms"])) + } else { + log.Print(ErrorDefaultMaxTimeMinVersion) + } } return res20240530, res, nil diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 5e4ddc2300..7baeb6d190 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -40,6 +40,7 @@ const ( ErrorClusterAdvancedSetting = "error setting `%s` for MongoDB ClusterAdvanced (%s): %s" ErrorAdvancedClusterListStatus = "error awaiting MongoDB ClusterAdvanced List IDLE: %s" ErrorOperationNotPermitted = "error operation not permitted" + ErrorDefaultMaxTimeMinVersion = "default_max_time_ms can not be set for mongo_db_major_version lower than 8.0" ignoreLabel = "Infrastructure Tool" DeprecationOldSchemaAction = "Please refer to our examples, documentation, and 1.18.0 migration guide for more details at https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/1.18.0-upgrade-guide.html.markdown" ) @@ -480,7 +481,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { if !IsDefaultMaxTimeMinRequiredMajorVersion(params.MongoDBMajorVersion) { - return diag.FromErr(fmt.Errorf("default_max_time_ms can not be set for mongo_db_major_version lower than 8.0")) + return diag.FromErr(fmt.Errorf(ErrorDefaultMaxTimeMinVersion)) } } From 78c5b230e03626e0a4c046061b6db54dd03ce2b6 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Fri, 29 Nov 2024 06:27:54 +0000 Subject: [PATCH 12/17] minor --- internal/service/advancedcluster/resource_advanced_cluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 7baeb6d190..56a09a5cdd 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -481,7 +481,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. } if _, ok := d.GetOkExists("advanced_configuration.0.default_max_time_ms"); ok { if !IsDefaultMaxTimeMinRequiredMajorVersion(params.MongoDBMajorVersion) { - return diag.FromErr(fmt.Errorf(ErrorDefaultMaxTimeMinVersion)) + return diag.FromErr(errors.New(ErrorDefaultMaxTimeMinVersion)) } } From a3d6327d7b69645540cefa412c096c99989357fc Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Fri, 29 Nov 2024 06:30:30 +0000 Subject: [PATCH 13/17] doc --- docs/data-sources/advanced_cluster.md | 2 +- docs/data-sources/advanced_clusters.md | 2 +- docs/resources/advanced_cluster.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/data-sources/advanced_cluster.md b/docs/data-sources/advanced_cluster.md index faaaf24253..44491ba1cd 100644 --- a/docs/data-sources/advanced_cluster.md +++ b/docs/data-sources/advanced_cluster.md @@ -200,7 +200,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. -* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. Available in MongoDB version 8.0 and above. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is only supported for MongoDB version 8.0 and above. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). ## Attributes Reference diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index 9f357c07f7..594bf1a805 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -202,7 +202,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `oplog_min_retention_hours` - Minimum retention window for cluster's oplog expressed in hours. A value of null indicates that the cluster uses the default minimum oplog window that MongoDB Cloud calculates. * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. -* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. Available in MongoDB version 8.0 and above. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is only supported for MongoDB version 8.0 and above. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index fb3abf58b9..be56053214 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -460,7 +460,7 @@ Include **desired options** within advanced_configuration: * `sample_refresh_interval_bi_connector` - (Optional) Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This option corresponds to the `changeStreamOptions.preAndPostImages.expireAfterSeconds` cluster parameter. Defaults to `-1`(off). This setting controls the retention policy of change stream pre- and post-images. Pre- and post-images are the versions of a document before and after document modification, respectively. `expireAfterSeconds` controls how long MongoDB retains pre- and post-images. When set to -1 (off), MongoDB uses the default retention policy: pre- and post-images are retained until the corresponding change stream events are removed from the oplog. To set the minimum pre- and post-image retention time, specify an integer value greater than zero. Setting this too low could increase the risk of interrupting Realm sync or triggers processing. This parameter is only supported for MongoDB version 6.0 and above. -* `default_max_time_ms` - (Optional) Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. Available in MongoDB version 8.0 and above. +* `default_max_time_ms` - (Optional) Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is only supported for MongoDB version 8.0 and above. ### Tags From 51b99387aef37c9c1581383db3b1984520aaa7fa Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Fri, 29 Nov 2024 07:03:56 +0000 Subject: [PATCH 14/17] min --- .../advancedcluster/model_advanced_cluster.go | 4 +- .../resource_advanced_cluster.go | 10 +-- .../resource_advanced_cluster_test.go | 79 +++++++++++++++---- 3 files changed, 69 insertions(+), 24 deletions(-) diff --git a/internal/service/advancedcluster/model_advanced_cluster.go b/internal/service/advancedcluster/model_advanced_cluster.go index bf9be6b214..716d4c4f47 100644 --- a/internal/service/advancedcluster/model_advanced_cluster.go +++ b/internal/service/advancedcluster/model_advanced_cluster.go @@ -800,7 +800,7 @@ func getAdvancedClusterContainerID(containers []admin.CloudProviderContainer, cl return "" } -func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVersion *string) (admin20240530.ClusterDescriptionProcessArgs, admin.ClusterDescriptionProcessArgs20240805, error) { +func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVersion *string) (admin20240530.ClusterDescriptionProcessArgs, admin.ClusterDescriptionProcessArgs20240805) { res20240530 := admin20240530.ClusterDescriptionProcessArgs{} res := admin.ClusterDescriptionProcessArgs20240805{} @@ -875,7 +875,7 @@ func expandProcessArgs(d *schema.ResourceData, p map[string]any, mongodbMajorVer } } - return res20240530, res, nil + return res20240530, res } func isMinRequiredMajorVersion(input *string, minVersion float64) bool { diff --git a/internal/service/advancedcluster/resource_advanced_cluster.go b/internal/service/advancedcluster/resource_advanced_cluster.go index 56a09a5cdd..389363d94f 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster.go +++ b/internal/service/advancedcluster/resource_advanced_cluster.go @@ -503,10 +503,7 @@ func resourceCreate(ctx context.Context, d *schema.ResourceData, meta any) diag. if ac, ok := d.GetOk("advanced_configuration"); ok { if aclist, ok := ac.([]any); ok && len(aclist) > 0 { - params20240530, params, err := expandProcessArgs(d, aclist[0].(map[string]any), params.MongoDBMajorVersion) - if err != nil { - return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) - } + params20240530, params := expandProcessArgs(d, aclist[0].(map[string]any), params.MongoDBMajorVersion) _, _, err = connV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, cluster.GetName(), ¶ms20240530).Execute() if err != nil { return diag.FromErr(fmt.Errorf(errorConfigUpdate, cluster.GetName(), err)) @@ -908,10 +905,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. ac := d.Get("advanced_configuration") if aclist, ok := ac.([]any); ok && len(aclist) > 0 { - params20240530, params, err := expandProcessArgs(d, aclist[0].(map[string]any), &mongoDBMajorVersion) - if err != nil { - return diag.FromErr(fmt.Errorf(errorConfigUpdate, clusterName, err)) - } + params20240530, params := expandProcessArgs(d, aclist[0].(map[string]any), &mongoDBMajorVersion) if !reflect.DeepEqual(params20240530, admin20240530.ClusterDescriptionProcessArgs{}) { _, _, err := connV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, ¶ms20240530).Execute() if err != nil { diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index 6ca9b81dca..be46c4edcf 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -245,6 +245,47 @@ func TestAccClusterAdvancedCluster_pausedToUnpaused(t *testing.T) { }) } +func TestAccClusterAdvancedCluster_advancedConfig_oldMongoDBVersion(t *testing.T) { + acc.SkipIfTPFAdvancedCluster(t) + var ( + projectID = acc.ProjectIDExecution(t) + clusterName = acc.RandomClusterName() + + processArgs20240530 = &admin20240530.ClusterDescriptionProcessArgs{ + DefaultReadConcern: conversion.StringPtr("available"), + DefaultWriteConcern: conversion.StringPtr("1"), + FailIndexKeyTooLong: conversion.Pointer(false), + JavascriptEnabled: conversion.Pointer(true), + MinimumEnabledTlsProtocol: conversion.StringPtr("TLS1_1"), + NoTableScan: conversion.Pointer(false), + OplogSizeMB: conversion.Pointer(1000), + SampleRefreshIntervalBIConnector: conversion.Pointer(310), + SampleSizeBIConnector: conversion.Pointer(110), + TransactionLifetimeLimitSeconds: conversion.Pointer[int64](300), + } + processArgs = &admin.ClusterDescriptionProcessArgs20240805{ + ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: conversion.IntPtr(-1), // this will not be set in the TF configuration + DefaultMaxTimeMS: conversion.IntPtr(65), + } + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName), + ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, + CheckDestroy: acc.CheckDestroyCluster, + Steps: []resource.TestStep{ + { + Config: configAdvanced(projectID, clusterName, "7.0", processArgs20240530, processArgs), + ExpectError: regexp.MustCompile(advancedcluster.ErrorDefaultMaxTimeMinVersion), + }, + { + Config: configAdvanced(projectID, clusterName, "7.0", processArgs20240530, &admin.ClusterDescriptionProcessArgs20240805{}), + Check: checkAdvanced(clusterName, "TLS1_1", &admin.ClusterDescriptionProcessArgs20240805{}), + }, + }, + }) +} + func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { acc.SkipIfTPFAdvancedCluster(t) var ( @@ -291,11 +332,11 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) { CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configAdvanced(projectID, clusterName, processArgs20240530, processArgs), + Config: configAdvanced(projectID, clusterName, "", processArgs20240530, processArgs), Check: checkAdvanced(clusterName, "TLS1_1", processArgs), }, { - Config: configAdvanced(projectID, clusterNameUpdated, processArgs20240530Updated, processArgsUpdated), + Config: configAdvanced(projectID, clusterNameUpdated, "", processArgs20240530Updated, processArgsUpdated), Check: checkAdvanced(clusterNameUpdated, "TLS1_2", processArgsUpdated), }, }, @@ -1328,22 +1369,29 @@ func checkSingleProviderPaused(name string, paused bool) resource.TestCheckFunc "paused": strconv.FormatBool(paused)}) } -func configAdvanced(projectID, clusterName string, p20240530 *admin20240530.ClusterDescriptionProcessArgs, p *admin.ClusterDescriptionProcessArgs20240805) string { +func configAdvanced(projectID, clusterName, mongoDBMajorVersion string, p20240530 *admin20240530.ClusterDescriptionProcessArgs, p *admin.ClusterDescriptionProcessArgs20240805) string { changeStreamOptionsString := "" defaultMaxTimeString := "" + mongoDBMajorVersionString := "" + if p != nil { - if p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != conversion.IntPtr(-1) { + if p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != nil && p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != conversion.IntPtr(-1) { changeStreamOptionsString = fmt.Sprintf(`change_stream_options_pre_and_post_images_expire_after_seconds = %[1]d`, *p.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds) } if p.DefaultMaxTimeMS != nil { defaultMaxTimeString = fmt.Sprintf(`default_max_time_ms = %[1]d`, *p.DefaultMaxTimeMS) } } + if mongoDBMajorVersion != "" { + mongoDBMajorVersionString = fmt.Sprintf(`mongo_db_major_version = %[1]q`, mongoDBMajorVersion) + } + return fmt.Sprintf(` resource "mongodbatlas_advanced_cluster" "test" { project_id = %[1]q name = %[2]q cluster_type = "REPLICASET" + %[13]s replication_specs { region_configs { @@ -1386,21 +1434,24 @@ func configAdvanced(projectID, clusterName string, p20240530 *admin20240530.Clus `, projectID, clusterName, p20240530.GetFailIndexKeyTooLong(), p20240530.GetJavascriptEnabled(), p20240530.GetMinimumEnabledTlsProtocol(), p20240530.GetNoTableScan(), p20240530.GetOplogSizeMB(), p20240530.GetSampleSizeBIConnector(), p20240530.GetSampleRefreshIntervalBIConnector(), p20240530.GetTransactionLifetimeLimitSeconds(), - changeStreamOptionsString, defaultMaxTimeString) + changeStreamOptionsString, defaultMaxTimeString, mongoDBMajorVersionString) } func checkAdvanced(name, tls string, processArgs *admin.ClusterDescriptionProcessArgs20240805) resource.TestCheckFunc { advancedConfig := map[string]string{ "name": name, - "advanced_configuration.0.minimum_enabled_tls_protocol": tls, - "advanced_configuration.0.fail_index_key_too_long": "false", - "advanced_configuration.0.javascript_enabled": "true", - "advanced_configuration.0.no_table_scan": "false", - "advanced_configuration.0.oplog_size_mb": "1000", - "advanced_configuration.0.sample_refresh_interval_bi_connector": "310", - "advanced_configuration.0.sample_size_bi_connector": "110", - "advanced_configuration.0.transaction_lifetime_limit_seconds": "300", - "advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds": strconv.Itoa(*processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds), + "advanced_configuration.0.minimum_enabled_tls_protocol": tls, + "advanced_configuration.0.fail_index_key_too_long": "false", + "advanced_configuration.0.javascript_enabled": "true", + "advanced_configuration.0.no_table_scan": "false", + "advanced_configuration.0.oplog_size_mb": "1000", + "advanced_configuration.0.sample_refresh_interval_bi_connector": "310", + "advanced_configuration.0.sample_size_bi_connector": "110", + "advanced_configuration.0.transaction_lifetime_limit_seconds": "300", + } + + if processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds != nil { + advancedConfig["advanced_configuration.0.change_stream_options_pre_and_post_images_expire_after_seconds"] = strconv.Itoa(*processArgs.ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds) } if processArgs.DefaultMaxTimeMS != nil { From 2586a98ca1c7ddccfb97799936d132fc3eb45439 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Fri, 29 Nov 2024 11:04:32 +0000 Subject: [PATCH 15/17] minor --- .../service/advancedcluster/resource_advanced_cluster_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/advancedcluster/resource_advanced_cluster_test.go b/internal/service/advancedcluster/resource_advanced_cluster_test.go index be46c4edcf..0176c74153 100644 --- a/internal/service/advancedcluster/resource_advanced_cluster_test.go +++ b/internal/service/advancedcluster/resource_advanced_cluster_test.go @@ -275,11 +275,11 @@ func TestAccClusterAdvancedCluster_advancedConfig_oldMongoDBVersion(t *testing.T CheckDestroy: acc.CheckDestroyCluster, Steps: []resource.TestStep{ { - Config: configAdvanced(projectID, clusterName, "7.0", processArgs20240530, processArgs), + Config: configAdvanced(projectID, clusterName, "6.0", processArgs20240530, processArgs), ExpectError: regexp.MustCompile(advancedcluster.ErrorDefaultMaxTimeMinVersion), }, { - Config: configAdvanced(projectID, clusterName, "7.0", processArgs20240530, &admin.ClusterDescriptionProcessArgs20240805{}), + Config: configAdvanced(projectID, clusterName, "6.0", processArgs20240530, &admin.ClusterDescriptionProcessArgs20240805{}), Check: checkAdvanced(clusterName, "TLS1_1", &admin.ClusterDescriptionProcessArgs20240805{}), }, }, From 638c4bf68079924b5b996e7bb1b6567417762d97 Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 10 Dec 2024 11:09:52 +0000 Subject: [PATCH 16/17] doc --- docs/data-sources/advanced_cluster.md | 2 +- docs/data-sources/advanced_clusters.md | 2 +- docs/resources/advanced_cluster.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/data-sources/advanced_cluster.md b/docs/data-sources/advanced_cluster.md index 4e0c0e4833..e72e1993e4 100644 --- a/docs/data-sources/advanced_cluster.md +++ b/docs/data-sources/advanced_cluster.md @@ -202,7 +202,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. -* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is only supported for MongoDB version 8.0 and above. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is supported only for MongoDB version 8.0 and above. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). ## Attributes Reference diff --git a/docs/data-sources/advanced_clusters.md b/docs/data-sources/advanced_clusters.md index fc6c919364..8b9d5773a5 100644 --- a/docs/data-sources/advanced_clusters.md +++ b/docs/data-sources/advanced_clusters.md @@ -204,7 +204,7 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le * `oplog_min_retention_hours` - Minimum retention window for cluster's oplog expressed in hours. A value of null indicates that the cluster uses the default minimum oplog window that MongoDB Cloud calculates. * `sample_size_bi_connector` - Number of documents per database to sample when gathering schema information. Defaults to 100. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `sample_refresh_interval_bi_connector` - Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. -* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is only supported for MongoDB version 8.0 and above. +* `default_max_time_ms` - Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is supported only for MongoDB version 8.0 and above. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This parameter is only supported for MongoDB version 6.0 and above. Defaults to `-1`(off). diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index 8d19c9f1e8..7cf42df989 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -462,7 +462,7 @@ Include **desired options** within advanced_configuration: * `sample_refresh_interval_bi_connector` - (Optional) Interval in seconds at which the mongosqld process re-samples data to create its relational schema. The default value is 300. The specified value must be a positive integer. Available only for Atlas deployments in which BI Connector for Atlas is enabled. * `transaction_lifetime_limit_seconds` - (Optional) Lifetime, in seconds, of multi-document transactions. Defaults to 60 seconds. * `change_stream_options_pre_and_post_images_expire_after_seconds` - (Optional) The minimum pre- and post-image retention time in seconds. This option corresponds to the `changeStreamOptions.preAndPostImages.expireAfterSeconds` cluster parameter. Defaults to `-1`(off). This setting controls the retention policy of change stream pre- and post-images. Pre- and post-images are the versions of a document before and after document modification, respectively. `expireAfterSeconds` controls how long MongoDB retains pre- and post-images. When set to -1 (off), MongoDB uses the default retention policy: pre- and post-images are retained until the corresponding change stream events are removed from the oplog. To set the minimum pre- and post-image retention time, specify an integer value greater than zero. Setting this too low could increase the risk of interrupting Realm sync or triggers processing. This parameter is only supported for MongoDB version 6.0 and above. -* `default_max_time_ms` - (Optional) Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is only supported for MongoDB version 8.0 and above. +* `default_max_time_ms` - (Optional) Default time limit in milliseconds for individual read operations to complete. This option corresponds to the [defaultMaxTimeMS(https://www.mongodb.com/docs/upcoming/reference/cluster-parameters/defaultMaxTimeMS/) cluster parameter. This parameter is supported only for MongoDB version 8.0 and above. ### Tags From eb961e5d089e9ea836fc495e55d0a7b26229e4ae Mon Sep 17 00:00:00 2001 From: Aastha Mahendru Date: Tue, 10 Dec 2024 11:18:51 +0000 Subject: [PATCH 17/17] minor --- internal/service/advancedclustertpf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/advancedclustertpf/README.md b/internal/service/advancedclustertpf/README.md index 35da6d6ca8..5a997ed387 100644 --- a/internal/service/advancedclustertpf/README.md +++ b/internal/service/advancedclustertpf/README.md @@ -6,6 +6,6 @@ This package contains the WIP for `mongodbatlas_advanced_cluster` in TPF. Curren ## Changes in advancedcluster that needs to be added here (list changes done in advancedcluster which couldn't also be done here at that moment) -- [PR #2825](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2825) Add new `advanced_configuration.0.default_max_time_ms` attribute to mongodbatlas_advanced_cluster resource and data sources +- [PR #2825](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/2825) Add new `advanced_configuration.0.default_max_time_ms` attribute to mongodbatlas_advanced_cluster resource and data sources.