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

Merged
merged 4 commits into from
Jan 24, 2025
Merged

Prometheus for database #787

merged 4 commits into from
Jan 24, 2025

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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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

@lpatte lpatte requested a review from a team as a code owner January 21, 2025 15:19
Comment on lines 36 to 38
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
This attribute can be an arbitrary string but we recommend 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of other variables to automatically trigger it based on this variable update

Comment on lines 34 to 36
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
This attribute can be an arbitrary string but we recommend 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of other variables to automatically trigger it based on this variable update

Comment on lines 36 to 38
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
This attribute can be an arbitrary string but we recommend 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of other variables to automatically trigger it based on this variable update

Comment on lines 43 to 45
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
This attribute can be an arbitrary string but we recommend 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of other variables to automatically trigger it based on this variable update

Comment on lines 36 to 38
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
This attribute can be an arbitrary string but we recommend 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of other variables to automatically trigger it based on this variable update

Comment on lines 46 to 48
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
This attribute can be an arbitrary string but we recommend 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of other variables to automatically trigger it based on this variable update

Comment on lines 38 to 40
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
This attribute can be an arbitrary string but we recommend 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of other variables to automatically trigger it based on this variable update

Comment on lines 44 to 46
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This attribute can be an arbitratry string but we recomand 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of another variables to automaticaly triger it based on this variable update
This attribute can be an arbitrary string but we recommend 2 formats:
- a datetime to keep a trace of the last reset
- a md5 of other variables to automatically trigger it based on this variable update

@amstuta amstuta dismissed rbeuque74’s stale review January 24, 2025 10:27

discussed directly

@amstuta amstuta merged commit c02620f into master Jan 24, 2025
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