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 redact_client_log_data in mongodbatlas_cluster #2601

Merged
merged 17 commits into from
Sep 19, 2024

Conversation

lantoli
Copy link
Member

@lantoli lantoli commented Sep 16, 2024

Description

Supports redact_client_log_data in mongodbatlas_cluster.

Link to any related issue(s): CLOUDP-273790

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

@lantoli lantoli marked this pull request as ready for review September 16, 2024 16:06
@lantoli lantoli requested a review from a team as a code owner September 16, 2024 16:06
Copy link
Contributor

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

Copy link
Contributor

@carriecwk carriecwk left a comment

Choose a reason for hiding this comment

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

LGTM

@lantoli lantoli requested a review from a team as a code owner September 18, 2024 09:38
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.

minor improvements but overall LGTM

.changelog/2601.txt Outdated Show resolved Hide resolved
.changelog/2601.txt Outdated Show resolved Hide resolved
.changelog/2601.txt Outdated Show resolved Hide resolved
Comment on lines 26 to 33
stateConf := &retry.StateChangeConf{
Pending: []string{"CREATING", "UPDATING", "REPAIRING"},
Target: []string{"IDLE"},
Refresh: ResourceClusterRefreshFunc(ctx, clusterName, projectID, conn),
Timeout: timeout,
MinTimeout: 30 * time.Second,
Delay: 1 * time.Minute,
}
Copy link
Member

Choose a reason for hiding this comment

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

I assume this was copied from existing update code, could we extract to a function just to make sure we have state transitions and timeout is single place?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess we could use the CreateStateChangeConfig from the advancedcluster package?

Copy link
Member Author

Choose a reason for hiding this comment

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

thank you both, I've followed @EspenAlbert suggestion and changed here 16f12f3

internal/service/cluster/new_atlas.go Show resolved Hide resolved
Comment on lines 1367 to 1369
resource.TestCheckResourceAttr(resourceName, "redact_client_log_data", "false"),
resource.TestCheckResourceAttr(dataSourceName, "redact_client_log_data", "false"),
resource.TestCheckResourceAttr(dataSourcePluralName, "results.0.redact_client_log_data", "false"),
Copy link
Member

Choose a reason for hiding this comment

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

acc.CheckRSAndDS can let you define this in a single call

Copy link
Member Author

Choose a reason for hiding this comment

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

nice, thanks! changed in cef542a

Config: configRedactClientLogData(projectID, clusterName, nil),
Check: resource.ComposeAggregateTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "redact_client_log_data", "false"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think if you duplicate this step and put it after step 3 the test will fail. Since it is optional-computed removing the value will see no changes and it will remain true

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I think that's what we're doing in these cases. Removing the field won't be flagged as a change so current value will stay

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, thanks for follow ups

Comment on lines +130 to +131
stateConf := advancedcluster.CreateStateChangeConfig(ctx, connV2, groupID, clusterName, 15*time.Minute)
if _, err := stateConf.WaitForStateContext(ctx); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I know this is unrelated but very strange why we verify cluster state transition as part of creating a backup snapshot

Copy link
Member Author

Choose a reason for hiding this comment

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

true, I can imagine it's to support when a user defines a cluster and a snapshot without depends_on between them

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! Thanks for addressing all the comments!

@lantoli lantoli merged commit 7ae52b0 into CLOUDP-270155-redaction-dev Sep 19, 2024
34 of 35 checks passed
@lantoli lantoli deleted the CLOUDP-273790_redact_cluster branch September 19, 2024 09:46
lantoli added a commit that referenced this pull request Oct 4, 2024
* feat: Supports `redact_client_log_data` in `mongodbatlas_advanced_cluster` (#2600)

* use SDK Preview

* add redact_client_log_data to schema

* plural ds

* resource

* tests

* changelog

* feat: Supports `redact_client_log_data` in `mongodbatlas_cluster` (#2601)

* doc

* changelog

* new atlas functions

* data sources

* resource

* tests

* rename CRUD functions

* wait for cluster changes

* apply feedback for changelog

* use acc.CheckRSAndDS

* fix ret

* additional comment in cluster

* Revert "additional comment in cluster"

This reverts commit ce69fa1.

* additional comment in cluster

* refactor StateChangeConf

* remove ResourceClusterRefreshFunc

* attribute not necessary

* fix update in cluster

* fix plural ds tests
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