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

feat: Supports change_stream_options_pre_and_post_images_expire_after_seconds in mongodbatlas_cluster and mongodbatlas_advanced_cluster #2528

Merged
merged 27 commits into from
Sep 10, 2024

Conversation

oarbusi
Copy link
Collaborator

@oarbusi oarbusi commented Aug 27, 2024

Description

Supports change_stream_options_pre_and_post_images_expire_after_seconds in mongodbatlas_cluster
Link to any related issue(s): CLOUDP-262696

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

overall approach LGTM, had some small doubts

@@ -206,6 +208,7 @@ func TestAccCluster_basic_DefaultWriteRead_AdvancedConf(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "advanced_configuration.0.oplog_size_mb", "1000"),
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.change_stream_options_pre_and_post_images_expire_after_seconds", "-1"),
Copy link
Member

Choose a reason for hiding this comment

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

nice test scenario

@oarbusi oarbusi changed the title feat: Supports change_stream_options_pre_and_post_images_expire_after_seconds in mongodbatlas_cluster feat: Supports change_stream_options_pre_and_post_images_expire_after_seconds in mongodbatlas_cluster and mongodbatlas_advanced_cluster Sep 6, 2024
@oarbusi oarbusi marked this pull request as ready for review September 6, 2024 16:05
@oarbusi oarbusi requested review from a team as code owners September 6, 2024 16:05
Copy link
Contributor

github-actions bot commented Sep 6, 2024

APIx bot: a message has been sent to Docs Slack channel

func flattenProcessArgs(p *admin20240530.ClusterDescriptionProcessArgs) []map[string]any {
if p == nil {
func flattenProcessArgs(p20240530 *admin20240530.ClusterDescriptionProcessArgs, p *admin.ClusterDescriptionProcessArgs20240805) []map[string]any {
if p20240530 == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

names looks strange to me. I would go for a more generic: pOld and pNew

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did it like this to be consistent on how we handle different SDK version and also thinking in the future where we might only use the "new", so the refactor would be cleaner and we would only keep the p (there wouldn't be a need to change from pNew to p)

if err != nil {
return diag.FromErr(fmt.Errorf(errorConfigRead, clusterName, err))
}
processArgs, _, err := connV2.ClustersApi.GetClusterAdvancedConfiguration(ctx, projectID, clusterName).Execute()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need both processArgs20240530 and processArgs? Will the GetClusterAdvancedConfiguration ever return nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds is only available in processArgs which is from the latest SDK versrion

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we not remove the processArgs20240530?

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM, just a final doubt on my end

"change_stream_options_pre_and_post_images_expire_after_seconds": {
Type: schema.TypeInt,
Optional: true,
Default: -1,
Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm, was the final agreement with the API team that we send the default of -1 if attribute is not defined?

Copy link
Collaborator Author

@oarbusi oarbusi Sep 10, 2024

Choose a reason for hiding this comment

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

-1 and null(not set) is equivalent in this case for the API. Setting the default value to -1 in the schema is necessary for the case of the user wanting to go back to the default value(which might not always be the same) after having set a different value. This would means that the user would remove the attribute from the TF config, and if there's not default value, it wouldn't be updated in the server because if the value is null in a PATCH, it's not sent

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

Nice. Some small nits. Also, got a bit confused about the schema for advanced configuration only lives in the advanced_cluster.

@oarbusi
Copy link
Collaborator Author

oarbusi commented Sep 10, 2024

Merging. I ran the local build of the provider and advanced_cluster and cluster works as expected

@oarbusi oarbusi merged commit 03c37f3 into master Sep 10, 2024
33 of 35 checks passed
@oarbusi oarbusi deleted the CLOUDP-262696 branch September 10, 2024 09:43
svc-apix-Bot added a commit that referenced this pull request Sep 10, 2024
lantoli added a commit that referenced this pull request Sep 10, 2024
* master:
  doc: Adds 1.19.0 release upgrade guide (#2564)
  chore: Updates CHANGELOG.md for #2528
  feat: Supports change_stream_options_pre_and_post_images_expire_after_seconds in `mongodbatlas_cluster` and `mongodbatlas_advanced_cluster` (#2528)
  chore: Disables preview mode for EAR private endpoint so it may be normally accessible (#2571)
  doc: Adds support for SDK_BRANCH in schema generation (#2562)
  update git workflow (#2572)
  chore: Updates CHANGELOG.md for #2566
  feat: Adds `mongodbatlas_stream_processor` resource and data sources (#2566)
  chore: Updates CHANGELOG.md for #2569
  chore: Merges Azure KMS Encryption at Rest Private Endpoint feature to master (#2569)
  chore: Updates CHANGELOG.md for #2568
  doc: Includes sync_creation into mongodbatlas_online_archive resource documentation (#2567)
  fix: Sets correct `zone_id` when `use_replication_spec_per_shard` is false and refactors `replica_set_scaling_strategy` handling with old schema of advanced cluster (#2568)
  chore: Updates CHANGELOG.md for #2539
  feat: Support `replica_set_scaling_strategy` in `mongodbatlas_advanced_cluster` (#2539)
  adding changelog entry for 1.18.1 to avoid confusion (#2561)

# Conflicts:
#	internal/provider/provider.go
lantoli added a commit that referenced this pull request Sep 10, 2024
* master:
  doc: Adds 1.19.0 release upgrade guide (#2564)
  chore: Updates CHANGELOG.md for #2528
  feat: Supports change_stream_options_pre_and_post_images_expire_after_seconds in `mongodbatlas_cluster` and `mongodbatlas_advanced_cluster` (#2528)
  chore: Disables preview mode for EAR private endpoint so it may be normally accessible (#2571)
  doc: Adds support for SDK_BRANCH in schema generation (#2562)
  update git workflow (#2572)
  chore: Updates CHANGELOG.md for #2566
  feat: Adds `mongodbatlas_stream_processor` resource and data sources (#2566)
  chore: Updates CHANGELOG.md for #2569
  chore: Merges Azure KMS Encryption at Rest Private Endpoint feature to master (#2569)
  chore: Updates CHANGELOG.md for #2568
  doc: Includes sync_creation into mongodbatlas_online_archive resource documentation (#2567)
  fix: Sets correct `zone_id` when `use_replication_spec_per_shard` is false and refactors `replica_set_scaling_strategy` handling with old schema of advanced cluster (#2568)
  chore: Updates CHANGELOG.md for #2539
  feat: Support `replica_set_scaling_strategy` in `mongodbatlas_advanced_cluster` (#2539)
  adding changelog entry for 1.18.1 to avoid confusion (#2561)

# Conflicts:
#	internal/provider/provider.go
lantoli added a commit that referenced this pull request Sep 10, 2024
* master:
  doc: Adds 1.19.0 release upgrade guide (#2564)
  chore: Updates CHANGELOG.md for #2528
  feat: Supports change_stream_options_pre_and_post_images_expire_after_seconds in `mongodbatlas_cluster` and `mongodbatlas_advanced_cluster` (#2528)
  chore: Disables preview mode for EAR private endpoint so it may be normally accessible (#2571)
  doc: Adds support for SDK_BRANCH in schema generation (#2562)
  update git workflow (#2572)
  chore: Updates CHANGELOG.md for #2566
  feat: Adds `mongodbatlas_stream_processor` resource and data sources (#2566)
  chore: Updates CHANGELOG.md for #2569
  chore: Merges Azure KMS Encryption at Rest Private Endpoint feature to master (#2569)
  chore: Updates CHANGELOG.md for #2568
  doc: Includes sync_creation into mongodbatlas_online_archive resource documentation (#2567)
  fix: Sets correct `zone_id` when `use_replication_spec_per_shard` is false and refactors `replica_set_scaling_strategy` handling with old schema of advanced cluster (#2568)
  chore: Updates CHANGELOG.md for #2539
  feat: Support `replica_set_scaling_strategy` in `mongodbatlas_advanced_cluster` (#2539)
  adding changelog entry for 1.18.1 to avoid confusion (#2561)

# Conflicts:
#	internal/provider/provider.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants