Skip to content

Commit 6515a26

Browse files
authored
remove: Removes mongodbatlas_advanced_cluster deprecated params (#3635)
1 parent d3949bc commit 6515a26

File tree

48 files changed

+2223
-3167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2223
-3167
lines changed

.changelog/3635.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
```release-note:breaking-change
2+
resource/mongodbatlas_advanced_cluster: Removes deprecated attributes `id`, `disk_size_gb`, `replication_specs.#.id`, `replication_specs.#.num_shards`
3+
```
4+
5+
```release-note:breaking-change
6+
data-source/mongodbatlas_advanced_cluster: Removes deprecated attributes `use_replication_spec_per_shard`, `id`, `disk_size_gb`, `replication_specs.#.id`, `replication_specs.#.num_shards`
7+
```
8+
9+
```release-note:breaking-change
10+
data-source/mongodbatlas_advanced_clusters: Removes deprecated attributes `use_replication_spec_per_shard`, `results.#.id`, `results.#.disk_size_gb`, `results.#.replication_specs.#.id`, `results.#.replication_specs.#.num_shards`
11+
```
12+
13+
```release-note:breaking-change
14+
resource/mongodbatlas_advanced_cluster: Removes deprecated attributes `advanced_configuration.default_read_concern` and `advanced_configuration.fail_index_key_too_long`
15+
```
16+
17+
```release-note:breaking-change
18+
data-source/mongodbatlas_advanced_cluster: Removes deprecated attributes `advanced_configuration.default_read_concern` and `advanced_configuration.fail_index_key_too_long`
19+
```
20+
21+
```release-note:breaking-change
22+
data-source/mongodbatlas_advanced_clusters: Removes deprecated attributes `results.#.advanced_configuration.default_read_concern` and `results.#.advanced_configuration.fail_index_key_too_long`
23+
```

.github/workflows/acceptance-tests-runner.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ jobs:
398398
- name: Acceptance Tests
399399
env:
400400
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
401-
MONGODB_ATLAS_LAST_1X_VERSION: ${{ inputs.mongodb_atlas_last_1x_version }}
402401
HTTP_MOCKER_CAPTURE: 'true'
403402
ACCTEST_REGEX_RUN: ${{ inputs.reduced_tests && '^TestAccMockable' || env.ACCTEST_REGEX_RUN }}
404403
ACCTEST_PACKAGES: |
@@ -408,8 +407,6 @@ jobs:
408407
advanced_cluster_tpf_mig_from_sdkv2:
409408
needs: [ change-detection, get-provider-version ]
410409
if: ${{ inputs.reduced_tests == false && (needs.change-detection.outputs.advanced_cluster == 'true' || inputs.test_group == 'advanced_cluster') }}
411-
env:
412-
MONGODB_ATLAS_TEST_SDKV2_TO_TPF: 'true'
413410
runs-on: ubuntu-latest
414411
permissions: {}
415412
steps:
@@ -427,7 +424,35 @@ jobs:
427424
env:
428425
MONGODB_ATLAS_LAST_VERSION: ${{ inputs.mongodb_atlas_last_1x_version }}
429426
MONGODB_ATLAS_LAST_1X_VERSION: ${{ inputs.mongodb_atlas_last_1x_version }}
430-
ACCTEST_REGEX_RUN: '^TestMig'
427+
MONGODB_ATLAS_TEST_SDKV2_TO_TPF: 'true'
428+
ACCTEST_REGEX_RUN: '^TestV1xMig'
429+
ACCTEST_PACKAGES: |
430+
./internal/service/advancedclustertpf
431+
run: make testacc
432+
433+
advanced_cluster_tpf_mig_from_tpf_preview:
434+
needs: [ change-detection, get-provider-version ]
435+
if: ${{ inputs.reduced_tests == false && (needs.change-detection.outputs.advanced_cluster == 'true' || inputs.test_group == 'advanced_cluster') }}
436+
runs-on: ubuntu-latest
437+
permissions: {}
438+
steps:
439+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
440+
with:
441+
ref: ${{ inputs.ref || github.ref }}
442+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
443+
with:
444+
go-version-file: 'go.mod'
445+
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
446+
with:
447+
terraform_version: ${{ inputs.terraform_version }}
448+
terraform_wrapper: false
449+
- name: Acceptance Tests
450+
env:
451+
MONGODB_ATLAS_LAST_VERSION: ${{ inputs.mongodb_atlas_last_1x_version }}
452+
MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER: 'true' # required for migration tests that use provider version < 2.0.0
453+
MONGODB_ATLAS_LAST_1X_VERSION: ${{ inputs.mongodb_atlas_last_1x_version }}
454+
MONGODB_ATLAS_TEST_SDKV2_TO_TPF: 'false'
455+
ACCTEST_REGEX_RUN: '^TestV1xMig'
431456
ACCTEST_PACKAGES: |
432457
./internal/service/advancedclustertpf
433458
run: make testacc

.github/workflows/code-health.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ jobs:
9191
secrets: inherit
9292
uses: ./.github/workflows/acceptance-tests.yml
9393
with:
94-
reduced_tests: true
94+
reduced_tests: false

docs/resources/advanced_cluster.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ Key-value pairs that categorize the cluster. Each key and value has a maximum le
612612

613613
### replication_specs
614614

615+
~> **NOTE:** We recommend reviewing our [Best Practices](#remove-or-disable-functionality) before disabling or removing any elements of replication_specs.
616+
615617
```terraform
616618
//Example Multicloud
617619
replication_specs = [
@@ -655,6 +657,8 @@ If you are upgrading a replica set to a sharded cluster, you cannot increase the
655657

656658
### region_configs
657659

660+
~> **NOTE:** We recommend reviewing our [Best Practices](#remove-or-disable-functionality) before disabling or removing any elements of region_configs.
661+
658662
* `analytics_specs` - (Optional) Hardware specifications for [analytics nodes](https://docs.atlas.mongodb.com/reference/faq/deployment/#std-label-analytics-nodes-overview) needed in the region. Analytics nodes handle analytic data such as reporting queries from BI Connector for Atlas. Analytics nodes are read-only and can never become the [primary](https://docs.atlas.mongodb.com/reference/glossary/#std-term-primary). If you don't specify this parameter, no analytics nodes deploy to this region. See [below](#specs).
659663
* `auto_scaling` - (Optional) Configuration for the collection of settings that configures auto-scaling information for the cluster. The values for the `auto_scaling` attribute must be the same for all `region_configs` of a cluster. See [below](#auto_scaling).
660664
* `analytics_auto_scaling` - (Optional) Configuration for the Collection of settings that configures analytics-auto-scaling information for the cluster. The values for the `analytics_auto_scaling` attribute must be the same for all `region_configs` of a cluster. See [below](#analytics_auto_scaling).

internal/service/advancedclustertpf/common_admin_sdk.go

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"fmt"
66
"net/http"
77

8-
admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin"
9-
admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin"
108
"go.mongodb.org/atlas-sdk/v20250312006/admin"
119

1210
"github.com/hashicorp/terraform-plugin-framework/diag"
@@ -18,20 +16,15 @@ import (
1816
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/flexcluster"
1917
)
2018

21-
func CreateCluster(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, req *admin.ClusterDescription20240805, waitParams *ClusterWaitParams, usingNewShardingConfig bool) *admin.ClusterDescription20240805 {
19+
func CreateCluster(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, req *admin.ClusterDescription20240805, waitParams *ClusterWaitParams) *admin.ClusterDescription20240805 {
2220
var (
2321
pauseAfter = req.GetPaused()
2422
clusterResp *admin.ClusterDescription20240805
2523
)
2624
if pauseAfter {
2725
req.Paused = nil
2826
}
29-
if usingNewShardingConfig {
30-
clusterResp = createClusterLatest(ctx, diags, client, req, waitParams)
31-
} else {
32-
oldReq := ConvertClusterDescription20241023to20240805(req)
33-
clusterResp = createCluster20240805(ctx, diags, client, oldReq, waitParams)
34-
}
27+
clusterResp = createClusterLatest(ctx, diags, client, req, waitParams)
3528
if diags.HasError() {
3629
return nil
3730
}
@@ -41,15 +34,6 @@ func CreateCluster(ctx context.Context, diags *diag.Diagnostics, client *config.
4134
return clusterResp
4235
}
4336

44-
func createCluster20240805(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, req *admin20240805.ClusterDescription20240805, waitParams *ClusterWaitParams) *admin.ClusterDescription20240805 {
45-
_, _, err := client.AtlasV220240805.ClustersApi.CreateCluster(ctx, waitParams.ProjectID, req).Execute()
46-
if err != nil {
47-
addErrorDiag(diags, operationCreate20240805, defaultAPIErrorDetails(waitParams.ClusterName, err))
48-
return nil
49-
}
50-
return AwaitChanges(ctx, client, waitParams, operationCreate20240805, diags)
51-
}
52-
5337
func createClusterLatest(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, req *admin.ClusterDescription20240805, waitParams *ClusterWaitParams) *admin.ClusterDescription20240805 {
5438
_, _, err := client.AtlasV2.ClustersApi.CreateCluster(ctx, waitParams.ProjectID, req).Execute()
5539
if err != nil {
@@ -70,62 +54,41 @@ func updateCluster(ctx context.Context, diags *diag.Diagnostics, client *config.
7054

7155
// ProcessArgs.ClusterAdvancedConfig is managed through create/updateCluster APIs instead of /processArgs APIs but since corresponding TF attributes
7256
// belong in the advanced_configuration attribute we still need to check for any changes
73-
func UpdateAdvancedConfiguration(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, p *ProcessArgs, waitParams *ClusterWaitParams) (legacy *admin20240530.ClusterDescriptionProcessArgs, latest *admin.ClusterDescriptionProcessArgs20240805, changed bool) {
57+
func UpdateAdvancedConfiguration(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, p *ProcessArgs, waitParams *ClusterWaitParams) (latest *admin.ClusterDescriptionProcessArgs20240805, changed bool) {
7458
var (
75-
err error
76-
advConfig *admin.ClusterDescriptionProcessArgs20240805
77-
legacyAdvConfig *admin20240530.ClusterDescriptionProcessArgs
78-
projectID = waitParams.ProjectID
79-
clusterName = waitParams.ClusterName
59+
err error
60+
advConfig *admin.ClusterDescriptionProcessArgs20240805
61+
projectID = waitParams.ProjectID
62+
clusterName = waitParams.ClusterName
8063
)
8164
if !update.IsZeroValues(p.ArgsDefault) {
8265
changed = true
8366
advConfig, _, err = client.AtlasV2.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, p.ArgsDefault).Execute()
8467
if err != nil {
8568
addErrorDiag(diags, operationAdvancedConfigurationUpdate, defaultAPIErrorDetails(clusterName, err))
86-
return nil, nil, false
69+
return nil, false
8770
}
8871
_ = AwaitChanges(ctx, client, waitParams, operationAdvancedConfigurationUpdate, diags)
8972
if diags.HasError() {
90-
return nil, nil, false
91-
}
92-
}
93-
if !update.IsZeroValues(p.ArgsLegacy) {
94-
changed = true
95-
legacyAdvConfig, _, err = client.AtlasV220240530.ClustersApi.UpdateClusterAdvancedConfiguration(ctx, projectID, clusterName, p.ArgsLegacy).Execute()
96-
if err != nil {
97-
addErrorDiag(diags, operationAdvancedConfigurationUpdate20240530, defaultAPIErrorDetails(clusterName, err))
98-
diags.AddError(errorAdvancedConfUpdateLegacy, defaultAPIErrorDetails(clusterName, err))
99-
return nil, nil, false
100-
}
101-
_ = AwaitChanges(ctx, client, waitParams, operationAdvancedConfigurationUpdate20240530, diags)
102-
if diags.HasError() {
103-
return nil, nil, false
73+
return nil, false
10474
}
10575
}
10676
if !update.IsZeroValues(p.ClusterAdvancedConfig) {
10777
changed = true
10878
}
109-
return legacyAdvConfig, advConfig, changed
79+
return advConfig, changed
11080
}
11181

112-
func ReadIfUnsetAdvancedConfiguration(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, projectID, clusterName string, configLegacy *admin20240530.ClusterDescriptionProcessArgs, configNew *admin.ClusterDescriptionProcessArgs20240805) (legacy *admin20240530.ClusterDescriptionProcessArgs, latest *admin.ClusterDescriptionProcessArgs20240805) {
82+
func ReadIfUnsetAdvancedConfiguration(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, projectID, clusterName string, configNew *admin.ClusterDescriptionProcessArgs20240805) (latest *admin.ClusterDescriptionProcessArgs20240805) {
11383
var err error
114-
if configLegacy == nil {
115-
configLegacy, _, err = client.AtlasV220240530.ClustersApi.GetClusterAdvancedConfiguration(ctx, projectID, clusterName).Execute()
116-
if err != nil {
117-
diags.AddError(errorAdvancedConfReadLegacy, defaultAPIErrorDetails(clusterName, err))
118-
return
119-
}
120-
}
12184
if configNew == nil {
12285
configNew, _, err = client.AtlasV2.ClustersApi.GetClusterAdvancedConfiguration(ctx, projectID, clusterName).Execute()
12386
if err != nil {
12487
diags.AddError(errorAdvancedConfRead, defaultAPIErrorDetails(clusterName, err))
12588
return
12689
}
12790
}
128-
return configLegacy, configNew
91+
return configNew
12992
}
13093

13194
func UpgradeTenant(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, waitParams *ClusterWaitParams, req *admin.LegacyAtlasTenantClusterUpgradeRequest) *admin.ClusterDescription20240805 {

internal/service/advancedclustertpf/data_source.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package advancedclustertpf
22

33
import (
44
"context"
5-
"fmt"
65

76
"github.com/hashicorp/terraform-plugin-framework/datasource"
87
"github.com/hashicorp/terraform-plugin-framework/diag"
@@ -14,12 +13,6 @@ import (
1413
var _ datasource.DataSource = &ds{}
1514
var _ datasource.DataSourceWithConfigure = &ds{}
1615

17-
const (
18-
errorReadDatasource = "Error reading advanced cluster datasource"
19-
errorReadDatasourceForceAsymmetric = "Error reading advanced cluster datasource, was expecting symmetric shards but found asymmetric shards"
20-
errorReadDatasourceForceAsymmetricDetail = "Cluster name %s. Please add `use_replication_spec_per_shard = true` to your data source configuration to enable asymmetric shard support. %s"
21-
)
22-
2316
func DataSource() datasource.DataSource {
2417
return &ds{
2518
DSCommon: config.DSCommon{
@@ -52,7 +45,6 @@ func (d *ds) Read(ctx context.Context, req datasource.ReadRequest, resp *datasou
5245
func (d *ds) readCluster(ctx context.Context, diags *diag.Diagnostics, modelDS *TFModelDS) *TFModelDS {
5346
clusterName := modelDS.Name.ValueString()
5447
projectID := modelDS.ProjectID.ValueString()
55-
useReplicationSpecPerShard := modelDS.UseReplicationSpecPerShard.ValueBool()
5648
clusterResp, flexClusterResp := GetClusterDetails(ctx, diags, projectID, clusterName, d.Client, false)
5749
if diags.HasError() {
5850
return nil
@@ -67,23 +59,17 @@ func (d *ds) readCluster(ctx context.Context, diags *diag.Diagnostics, modelDS *
6759
}
6860
return conversion.CopyModel[TFModelDS](modelOut)
6961
}
70-
modelOut, extraInfo := getBasicClusterModel(ctx, diags, d.Client, clusterResp, useReplicationSpecPerShard)
62+
modelOut := getBasicClusterModel(ctx, diags, d.Client, clusterResp)
7163
if diags.HasError() {
7264
return nil
7365
}
74-
if extraInfo.UseOldShardingConfigFailed {
75-
diags.AddError(errorReadDatasourceForceAsymmetric, fmt.Sprintf(errorReadDatasourceForceAsymmetricDetail, clusterName, DeprecationOldSchemaAction))
76-
return nil
77-
}
7866
updateModelAdvancedConfig(ctx, diags, d.Client, modelOut, &ProcessArgs{
79-
ArgsLegacy: nil,
8067
ArgsDefault: nil,
8168
ClusterAdvancedConfig: clusterResp.AdvancedConfiguration,
8269
})
8370
if diags.HasError() {
8471
return nil
8572
}
8673
modelOutDS := conversion.CopyModel[TFModelDS](modelOut)
87-
modelOutDS.UseReplicationSpecPerShard = modelDS.UseReplicationSpecPerShard // attrs not in resource model
8874
return modelOutDS
8975
}

0 commit comments

Comments
 (0)