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

Add resource and data for ovh_dbaas_logs #364

Merged
merged 1 commit into from
Feb 22, 2023
Merged

Conversation

vaxvms
Copy link
Contributor

@vaxvms vaxvms commented Jan 23, 2023

No description provided.

}

func resourceDbaasLogsClusterDelete(d *schema.ResourceData, meta interface{}) error {
if false {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What should i do when releasing the logs cluster from terraform management ?
Should i delete all ACL or should i leave them as-is ?
AFAIK, a empty list mean that the cluster has no ACL

Copy link
Collaborator

Choose a reason for hiding this comment

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

When a user execute the command terraform destroy on this resource, he/she should have a cluster like it was before the usage of this resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about this scenario :

  • you order a dedicated cluster
  • you manage it thru terraform, setting some ACL
  • you add data in it
  • you stop managing it thru terraform

As you go back to initial state, you don't have ACL anymore and a cluster full of data anyone can query

Copy link

@jehuty0shift jehuty0shift left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@scraly scraly left a comment

Choose a reason for hiding this comment

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

Several sugestions made.
Moreover, is it possible to create test acceptances for the new resource?
Thanks :)

resource "ovh_dbaas_logs_cluster" "ldp" {
service_name = "ldp-xx-xxxxx"

archive_input_allowed_networks = ["10.0.0.0/16"]
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
archive_input_allowed_networks = ["10.0.0.0/16"]
archive_allowed_networks = ["10.0.0.0/16"]

website/docs/r/dbaas_logs_cluster.html.markdown Outdated Show resolved Hide resolved
Copy link
Collaborator

@scraly scraly left a comment

Choose a reason for hiding this comment

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

Acceptance tests are missing for resource_dbaas_logs_cluster resource

Copy link
Collaborator

@scraly scraly left a comment

Choose a reason for hiding this comment

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

The new acceptance test is not working:
image

@scraly
Copy link
Collaborator

scraly commented Feb 14, 2023

After a git pull and relaunch the acceptance test.

First, a message asks me to execute make fmt command to format the code:

$ make testacc TESTARGS="-run TestAccDataSourceDbaasLogs_dedicated"
==> Checking that code complies with gofmt requirements...
gofmt needs running on the following files:
./ovh/resource_dbaas_logs_cluster_test.go
You can use the command: `make fmt` to reformat code.
make: *** [fmtcheck] Error 1

$ git pull
Already up to date.

$ make fmt
gofmt -w $(find . -name '*.go' |grep -v vendor)

And the acceptance test failed:

$ make testacc TESTARGS="-run TestAccDataSourceDbaasLogs_dedicated"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccDataSourceDbaasLogs_dedicated -timeout 240m
?   	github.com/ovh/terraform-provider-ovh	[no test files]
=== RUN   TestAccDataSourceDbaasLogs_dedicated
    data_dbaas_logs_test.go:25: Step 1/1 error: Check failed: Check 1/2 error: data.ovh_dbaas_logs.ldp: Attribute 'cluster_type' expected "DEDICATED", got "PRO"
--- FAIL: TestAccDataSourceDbaasLogs_dedicated (7.86s)
FAIL
FAIL	github.com/ovh/terraform-provider-ovh/ovh	8.216s
?   	github.com/ovh/terraform-provider-ovh/ovh/helpers	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/ovh/terraform-provider-ovh/ovh/helpers/hashcode	(cached) [no tests to run]
FAIL
make: *** [testacc] Error 1

So please execute make fmt in your side and then commit the formatting fix, and please fix the acceptance test :)

Thanks

ovh/data_dbaas_logs_test.go Outdated Show resolved Hide resolved
@scraly
Copy link
Collaborator

scraly commented Feb 15, 2023

image
Please define in "sensitive" sensitive informations like certificates, in order to not have the full information during an apply for example :)

This advice is for:

  • dedicated_input_pem
  • direct_input_pem

https://developer.hashicorp.com/terraform/tutorials/configuration-language/sensitive-variables

Thanks

ovh/data_dbaas_logs_test.go Outdated Show resolved Hide resolved
ovh/data_dbaas_logs_test.go Outdated Show resolved Hide resolved
@vaxvms vaxvms force-pushed the ovh_dbaas_logs branch 3 times, most recently from 9935361 to 97538d6 Compare February 15, 2023 10:47
ovh/data_dbaas_logs.go Outdated Show resolved Hide resolved
ovh/resource_dbaas_logs_cluster.go Outdated Show resolved Hide resolved
ovh/resource_dbaas_logs_cluster.go Show resolved Hide resolved
@vaxvms vaxvms force-pushed the ovh_dbaas_logs branch 2 times, most recently from 24c8952 to 095e85a Compare February 16, 2023 12:59
ovh/data_dbaas_logs.go Outdated Show resolved Hide resolved
ovh/data_dbaas_logs.go Outdated Show resolved Hide resolved
}

const testAccDbaasLogsClusterConfig = `
resource "ovh_dbaas_logs_cluster" "ldp" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can add threee more attributes in your resource definition, and three more tests in the acceptance test

resource "ovh_dbaas_logs_cluster" "ldp" {
  service_name     = "%s"
  archive_allowed_networks = ["10.0.0.0/16"]
  direct_input_allowed_networks  = ["10.0.0.0/16"]
  query_allowed_networks   = ["10.0.0.0/16"]
}

and then test if the created query_allowed_networks is equals to ["10.0.0.0/16"] and the same things for the others attributes :)

ovh/provider.go Outdated Show resolved Hide resolved
}

func resourceDbaasLogsClusterDelete(d *schema.ResourceData, meta interface{}) error {
if false {
Copy link
Collaborator

Choose a reason for hiding this comment

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

When a user execute the command terraform destroy on this resource, he/she should have a cluster like it was before the usage of this resource

Reference a DBaaS logs cluster to manipulate ACL on a `DEDICATED` cluster
type.

As LDP cluster can't be created through API, create and delete
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
As LDP cluster can't be created through API, create and delete
!> An LDP cluster can't be created and deleted via Terraform at this time. So when Terraform destroys the resource, it only actually restores it.

type.

As LDP cluster can't be created through API, create and delete
operation are no-op.
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
operation are no-op.

@scraly
Copy link
Collaborator

scraly commented Feb 22, 2023

As we can't, easily, send a warning message to a user when he or she wants to delete/destroy a LDP cluster in order to alert he or she that the cluster will "only" be resetted, I created a feature request: #385

Copy link
Collaborator

@scraly scraly left a comment

Choose a reason for hiding this comment

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

Approved and need to be improved in the future with a fully create and delete feature

@scraly scraly added the 0.28.0 label Feb 22, 2023
@scraly scraly merged commit 8f53cc1 into ovh:master Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants