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

chore: Uses use_replication_spec_per_shard in data sources #2896

Merged
merged 13 commits into from
Dec 16, 2024

Conversation

lantoli
Copy link
Member

@lantoli lantoli commented Dec 15, 2024

Description

Uses use_replication_spec_per_shard in data sources

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

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 force-pushed the CLOUDP-290307_data_source_legacy_view branch from a88025a to 5d80ddc Compare December 16, 2024 11:47
@lantoli lantoli marked this pull request as ready for review December 16, 2024 14:03
@lantoli lantoli requested a review from a team as a code owner December 16, 2024 14:03
)
if overrideUsingLegacySchema {
legacySchema = true
zoneNameNumShards = numShardsMapFromOldAPI(clusterRespOld)
Copy link
Member Author

Choose a reason for hiding this comment

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

plan is empty in Read when overriding legacy, so we get it from the old API

Copy link
Collaborator

Choose a reason for hiding this comment

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

Add this comment to the code?

Copy link
Member Author

Choose a reason for hiding this comment

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

added in: d39cf2f

@@ -37,13 +39,21 @@ func findNumShardsUpdates(ctx context.Context, state, plan *TFModel, diags *diag
return planCounts
}

func resolveAPIInfo(ctx context.Context, plan *TFModel, diags *diag.Diagnostics, clusterLatest *admin.ClusterDescription20240805, client *config.MongoDBClient) *ExtraAPIInfo {
func resolveAPIInfo(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, plan *TFModel, clusterLatest *admin.ClusterDescription20240805, overrideUsingLegacySchema bool) *ExtraAPIInfo {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] forceLegacySchema less verbose?

Copy link
Member Author

Choose a reason for hiding this comment

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

changed in: d39cf2f

asymmetricShardUnsupported := false

api20240530 := client.AtlasV220240530.ClustersApi
clusterRespOld, _, err := api20240530.GetCluster(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.

Nice refactor!

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. If we merge this now, we don't have to undo changes later here in this PR, we'll have to merge master to that branch

* master:
  chore: Refactors fail_index_key_too_long to be compatible with old implementation and use zero values in advanced_configuration (#2893)
  chore: Fixes converting to TPF by including all attributes in replication_specs (#2894)
AsymmetricShardUnsupported: asymmetricShardUnsupported,
}
if forceLegacySchema {
info.UsingLegacySchema = true
info.ZoneNameNumShards = numShardsMapFromOldAPI(clusterRespOld) // plan is empty in data source Read when forcing legacy, so we get num_shards from the old API
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q] can you elaborate on what you mean by "plan is empty" here? Simply that num_shards won't have a value or something else?

Copy link
Member Author

@lantoli lantoli Dec 16, 2024

Choose a reason for hiding this comment

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

in a data source the plan is empty, it only has the attributes provided by the user in the TF files. for example replication_specs will be empty

@lantoli lantoli merged commit 61eda15 into master Dec 16, 2024
41 checks passed
@lantoli lantoli deleted the CLOUDP-290307_data_source_legacy_view branch December 16, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants