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

Prometheus for database #787

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Prometheus for database #787

wants to merge 2 commits into from

Conversation

lpatte
Copy link
Contributor

@lpatte lpatte commented Dec 17, 2024

Description

Add resource to manage Prometheus for Databases Services

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A: make testacc TESTARGS="-run TestAccCloudProjectDatabaseMongodbPrometheusDataSource_basic"
  • Test B: make testacc TESTARGS="-run TestAccCloudProjectDatabasePrometheusDataSource_basic"
  • Test C: make testacc TESTARGS="-run TestAccCloudProjectDatabasePrometheus_importBasic"
  • Test D: make testacc TESTARGS="-run TestAccCloudProjectDatabaseMongodbPrometheus_basic"
  • Test E: make testacc TESTARGS="-run TestAccCloudProjectDatabasePrometheus_basic"

Test Configuration:

  • Existing HCL configuration you used:
resource "ovh_cloud_project_database_prometheus" "prom2" {
    service_name = "e55487da3ae846d7bd17bae8011fd4f8"
    engine       = "postgresql"
    cluster_id   = "xxxxxxxxxxxx"
    password_reset = "poto5"
} 

output "password2" {
    value = ovh_cloud_project_database_prometheus.prom2.password
    sensitive  = true
}

data "ovh_cloud_project_database_prometheus" "prom2" {
    service_name = "xxxxxxxxxxxx"
    engine       = "postgresql"
    cluster_id   = ovh_cloud_project_database_prometheus.prom2.cluster_id
}

resource "ovh_cloud_project_database_mongodb_prometheus" "prom" {
    service_name = "xxxxxxxxxxxx"
    cluster_id   = "xxxxxxxxxxxx"
    password_reset = "poto3"
}

output "password" {
    value = ovh_cloud_project_database_mongodb_prometheus.prom.password
    sensitive  = true
}

data "ovh_cloud_project_database_mongodb_prometheus" "prom" {
    service_name = "xxxxxxxxxxxx"
    cluster_id   = ovh_cloud_project_database_mongodb_prometheus.prom.cluster_id
}

@lpatte lpatte marked this pull request as draft December 17, 2024 12:00
@lpatte
Copy link
Contributor Author

lpatte commented Dec 18, 2024

Waiting some backend devs on this feature to test with last version of the feature before merge this PR

@lpatte lpatte marked this pull request as ready for review January 7, 2025 14:13
@lpatte
Copy link
Contributor Author

lpatte commented Jan 7, 2025

Backend development finished and resources tested with

@@ -85,6 +85,7 @@ type CloudProjectDatabaseResponse struct {
Version string `json:"version"`
Disk CloudProjectDatabaseDisk `json:"disk"`
AdvancedConfiguration map[string]string `json:"advancedConfiguration"`
EnablePrometheus bool `json:"EnablePrometheus"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
EnablePrometheus bool `json:"EnablePrometheus"`
EnablePrometheus bool `json:"enablePrometheus"`

)

res := &CloudProjectDatabasePrometheusAccessResponse{}
//log.Printf("[DEBUG] Will create pro: %+v for cluster %s from project %s", params, clusterId, serviceName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//log.Printf("[DEBUG] Will create pro: %+v for cluster %s from project %s", params, clusterId, serviceName)

Required: true,
},
"password_reset": {
Type: schema.TypeString,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would really prefer a bool property here as it will be way clearer for the end user. I understand that it requires him to input true on a first apply and then set the field to false to avoid re-resetting his password, but I think it's better this way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's not how terraform is use, we cannot ask our user to change the resource between the first and second apply. The user must be able to aply 5 time his code without update if he do not change the code.
We use the same strategy for user resources, and for all theses resources the documentation explain how to use it.
Our customers already use it without issue.

Copy link
Member

Choose a reason for hiding this comment

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

What about password_reset_last_request_date with datetime format ?
That would be clearer IMO

Copy link
Member

Choose a reason for hiding this comment

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

Agree with @amstuta that string is clearly not the way to go.

Copy link
Contributor Author

@lpatte lpatte Jan 13, 2025

Choose a reason for hiding this comment

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

Force datetime format is possible but in fact it's just a string with validate function (https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-types#date-time-data).
It's just a trigger attribute with this documentation :

  • password_reset - (Optional) Arbitrary string to change to trigger a password update. Use the terraform refresh command after executing terraform apply to update the output with the new password.

From my point of view, add a validate function will just add complexity for the user.
Also, if I change it here I have to change it in user resources and that will be a kind of breaking change.

}
d.SetId("")
return nil

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change


# ovh_cloud_project_database_prometheus (Data Source)

Use this data source to get information about a prometheus of a database cluster associated with a public cloud project.
Copy link
Contributor

Choose a reason for hiding this comment

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

optional, but maybe you could add something like for mongodb, please use the other datasource ...

Copy link
Member

@rbeuque74 rbeuque74 left a comment

Choose a reason for hiding this comment

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

Change type datetime

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