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

manage m3db default namespace #761

Merged
merged 8 commits into from
Oct 31, 2024
Merged

Conversation

lpatte
Copy link
Contributor

@lpatte lpatte commented Oct 22, 2024

Description

M3DB is created with a "default" namespace that can be updated. Like we already do for "avnadmin" user, I add a special case when we create a ovh_cloud_project_database_m3db_namespace with the name "default" to map the existing namespace instead of trying to create a new namespace.
With This change, the user can manage the "default" namespace like other and remove the resource will not delete it just unmap it.

Fixes #752

Other fixes :

  • retention_block_size_duration cannot be update, add ForceNew
  • retention_period_durationis not requiredbut optional and computed if not set
  • snapshot_enabled and writes_to_commit_log_enabled are computed if not set
  • snapshot_enabled and writes_to_commit_log_enabled default value is not the same for "default" namespace (false) and other namespace (true). Add some logic to check if the attribute is set or not and let OVH apis return us the computed value if not set instead of set it to "false" when unset
  • Remove legacy env variable OVH_CLOUD_PROJECT_DATABASE_M3DB_FLAVOR_TEST in m3db test

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Improvement (improve existing resource(s) or datasource(s))
  • Documentation update

How Has This Been Tested?

Test Configuration:

  • Existing HCL configuration you used:
resource "ovh_cloud_project_database" "m3db" {
    service_name = "XXXXXXXXX"
    engine       = "m3db"
    version      = "1.5"
    plan         = "essential"
    nodes {
        region     = "GRA"
    }
    flavor = "db1-7"
}

resource "ovh_cloud_project_database_m3db_namespace" "namespace" {
  service_name              = ovh_cloud_project_database.m3db.service_name
  cluster_id                = ovh_cloud_project_database.m3db.id
  name                      = "testns"
  resolution                = "P2D"
  retention_period_duration = "PT48H"
}

resource "ovh_cloud_project_database_m3db_namespace" "defaultns" {
  service_name              = ovh_cloud_project_database.m3db.service_name
  cluster_id                = ovh_cloud_project_database.m3db.id
  name                      = "default"
  resolution                = "PT1H"
  retention_period_duration = "P5D"

d.Set("service_name", serviceName)

results := make([]*schema.ResourceData, 1)
results[0] = d
return results, nil
}

func toMap(d *schema.ResourceData) map[string]interface{} {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you rename this func to something like m3dbNamespaceToMap or equivalent ? toMap seems very generic while the function isn't.

@lpatte
Copy link
Contributor Author

lpatte commented Oct 23, 2024

We do some rework of our API for M3DB namespace because several issues.
That will change some things in this resource for sure.
I will add it to this PR when our API is ready

@lpatte lpatte marked this pull request as draft October 25, 2024 15:36
@lpatte lpatte marked this pull request as ready for review October 28, 2024 16:20
@amstuta
Copy link
Contributor

amstuta commented Oct 30, 2024

@lpatte the PR itself is ok for me, but could you also update the associated tests ? It seems that all m3db-related tests are failing because the required config is not available anymore:

Error: calling Post /cloud/project/xxx/database/m3db with params &{Backups:<nil> Description:testacc-terraform-5142068301122074370 Disk:{Type: Size:0} IPRestrictions:[] MaintenanceTime: NetworkId: NodesPattern:{Flavor:db1-4 Number:1 Region:WAW} Plan:essential SubnetId: Version:1.5}:
        	 "OVHcloud API error (status code 404): Client::NotFound::NoMatchingCompute: \"no compute matches your expectations, please refer to the availability endpoint\"

@amstuta amstuta merged commit ac0dca5 into master Oct 31, 2024
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.

[FEATURE] make default namespace of m3db configurable
2 participants