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

new resource and data source : azurerm_oracle_cloud_vm_cluster #27176

Merged

Conversation

eelhomsi
Copy link
Contributor

@eelhomsi eelhomsi commented Aug 23, 2024

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

Introduce OracleDatabase VMCluster Resource & Data and DBServer Data
Most relevant changes in:
internal/services/oracledatabase/

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

VMCluster Resource tests (ran one by one due to tenancy resourcing constraints):
Screenshot 2024-08-11 at 12 52 20
Screenshot 2024-08-11 at 13 22 34
Screenshot 2024-08-11 at 13 53 18
Screenshot 2024-08-11 at 14 22 39

VM Cluster Data source:
Screenshot 2024-08-12 at 15 51 40

DB Server Data source:
Screenshot 2024-08-12 at 16 18 10

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • FEATURES - Introduced new CloudVmClusterResource, CloudVmClusterDataSource, and DBServersDataSource`.

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @eelhomsi - i've left some comments inline as well as triggered CI for thisPR

}

func NewClient(o *common.ClientOptions) (*Client, error) {
o.DisableCorrelationRequestID = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

how come we are disabling this? please add a comment detailing why

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - I've added a comment explaining why we disabled this.

Comment on lines 165 to 166
},
"cloud_exadata_infrastructure_id": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

there should be a new line here

Suggested change
},
"cloud_exadata_infrastructure_id": {
},
"cloud_exadata_infrastructure_id": {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

Comment on lines 60 to 65
"location": commonschema.Location(),
"name": {
Type: pluginsdk.TypeString,
Required: true,
},
"resource_group_name": {
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
"location": commonschema.Location(),
"name": {
Type: pluginsdk.TypeString,
Required: true,
},
"resource_group_name": {
"location": commonschema.Location(),
"name": {
Type: pluginsdk.TypeString,
Required: true,
},
"resource_group_name": {

should be new lines here. apply to all other schema properties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added new lines for all the schema properties.

Type: pluginsdk.TypeString,
Required: true,
},
"tags": commonschema.Tags(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be at the bottom

Comment on lines 109 to 113
%s
resource "azurerm_oracledatabase_cloud_vm_cluster" "test" {
location = "%[3]s"
name = "OFakeVmacctest%[2]d"
resource_group_name = azurerm_resource_group.test.name
Copy link
Collaborator

Choose a reason for hiding this comment

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

this will need to be formatted with terrafmt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done thanks!


* `cpu_core_count` - (Required) The number of CPU cores enabled on the cloud VM cluster.

* `db_servers` - (Required) The list of DB servers.
Copy link
Collaborator

Choose a reason for hiding this comment

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

list of? hostnames/ ids? if host names

Suggested change
* `db_servers` - (Required) The list of DB servers.
* `db_server_host_namess` - (Required) The list of DB server hostnames to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@katbyte I agree with your comments on the naming of these arguments, however I have been asked to match the official OCI Terraform provider here (concerns about consistent customer experience), so I don't have a lot of freedom in changing them myself:
https://registry.terraform.io/providers/oracle/oci/latest/docs/data-sources/database_cloud_vm_cluster#db_servers

Choose a reason for hiding this comment

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

Typo db_server_host_namess

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes were not used, so the typo was not committed.


* `display_name` - (Required) The user-friendly name for the cloud VM cluster. The name does not need to be unique..

* `gi_version` - (Required) A valid Oracle Grid Infrastructure (GI) software version.
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should avoid ambiguous acronyms

Suggested change
* `gi_version` - (Required) A valid Oracle Grid Infrastructure (GI) software version.
* `oracle_grid_nfrastructure_version` - (Required) A valid Oracle Grid Infrastructure (GI) software version.

Choose a reason for hiding this comment

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

Typo oracle_grid_nfrastructure_version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes were not used, so the typo was not committed.


* `cluster_name` - (Optional) The cluster name for cloud VM cluster.

* `data_collection_options` - (Optional) A `data_collection_options` block as defined below.
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
* `data_collection_options` - (Optional) A `data_collection_options` block as defined below.
* `data_collection` - (Optional) A `data_collection_options` block as defined below.

Type: pluginsdk.TypeString,
Required: true,
},
"resource_group_name": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this still needs to be updated to use common schema

Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we validate this is a proper id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I'm now calling the SDK provided validator.

"cpu_core_count": {
Type: pluginsdk.TypeInt,
Required: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we validate tyhis? i presume it cannot be -1 or 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Optional: true,
Computed: true,
ForceNew: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

and here. please add reasonable validation to all properties where possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
DiffSuppressFunc: GiVersionDiffSuppress,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we diff supressing here? please add a comment explaining

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this is needed anymore, so I have removed it.

output.Hostname = result.Model.Properties.Hostname
output.LicenseModel = string(pointer.From(result.Model.Properties.LicenseModel))
output.MemorySizeInGbs = pointer.From(result.Model.Properties.MemorySizeInGbs)
//output.SshPublicKeys = result.Model.Properties.SshPublicKeys
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uncommented now!

Comment on lines 418 to 419
output.VnetId = result.Model.Properties.VnetId
// Optional
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
output.VnetId = result.Model.Properties.VnetId
// Optional
output.VnetId = result.Model.Properties.VnetId
// Optional
Suggested change
output.VnetId = result.Model.Properties.VnetId
// Optional
output.VnetId = result.Model.Properties.VnetId
// Optional

Comment on lines 109 to 110
%s
resource "azurerm_oracledatabase_cloud_vm_cluster" "test" {
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
%s
resource "azurerm_oracledatabase_cloud_vm_cluster" "test" {
%s
resource "azurerm_oracledatabase_cloud_vm_cluster" "test" {
Suggested change
%s
resource "azurerm_oracledatabase_cloud_vm_cluster" "test" {
%s
resource "azurerm_oracledatabase_cloud_vm_cluster" "test" {

Comment on lines 47 to 50
"resource_group_name": {
Type: pluginsdk.TypeString,
Required: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use common schema here

"name": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validate.Name,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is used for multiple different nameS? are they actually all constrained in the same 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.

Yes both name and display_name will have the same constraints applied to them.

"strings"
)

func ConvertDataCollectionOptionsToInternal(dataCollectionOptions *cloudvmclusters.DataCollectionOptions) []DataCollectionOptionsModel {
Copy link
Collaborator

Choose a reason for hiding this comment

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

These seem to be the expand/flatten functions? these should be in the same file they are used in & use the terminology the rest of the provider does

flatten functions take api response/data -> terraform/internal
expand functions take internal/tf -> api request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Just a comment comments left ineline

internal/services/oracle/cloud_vm_cluster_resource.go Outdated Show resolved Hide resolved
// Example: Initial plan -> testHostname, final result after DBaaS -> testHostname-abc.
// Since testHostname is a prefix of testHostname-abc, then computed diff is zero.
func DbSystemHostnameDiffSuppress(_ string, old string, new string, _ *schema.ResourceData) bool {
return EqualIgnoreCaseSuppressDiff(old, new) || NewIsPrefixOfOldDiffSuppress(old, new)
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. we shouldn't be ignoring case, terraform is case sensitive
  2. instead of suppressing the diff we should/could strip the suffix on read

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the ignoring case part. Can you clarify the second point?

website/docs/d/oracle_cloud_vm_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/d/oracle_cloud_vm_cluster.html.markdown Outdated Show resolved Hide resolved
@eelhomsi
Copy link
Contributor Author

Test evidence here:
Screenshot 2024-10-16 at 13 40 47

Screenshot 2024-10-17 at 05 04 05

Screenshot 2024-10-16 at 14 55 42

Screenshot 2024-10-16 at 15 32 12

Screenshot 2024-10-16 at 16 17 43

Screenshot 2024-10-17 at 05 36 18

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 🏖️

@katbyte katbyte changed the title Introduce OracleDatabase VMCluster Resource & Data and DBServer Data new resource and data source : azurerm_oracle_cloud_vm_cluster Oct 17, 2024
@katbyte katbyte merged commit cb8d847 into hashicorp:main Oct 17, 2024
34 checks passed
@github-actions github-actions bot added this to the v4.6.0 milestone Oct 17, 2024
katbyte added a commit that referenced this pull request Oct 17, 2024
jackofallops added a commit that referenced this pull request Oct 17, 2024
jackofallops added a commit that referenced this pull request Oct 17, 2024
@jackofallops
Copy link
Member

Hi @eelhomsi - Apologies, but we've had to revert this PR. Since it's previously been merged, we cannot re-open from here. Can you please submit a new PR from the Branch and we'll work with you to get it merged?

Thanks!

@eelhomsi
Copy link
Contributor Author

eelhomsi commented Oct 17, 2024

Hi @eelhomsi - Apologies, but we've had to revert this PR. Since it's previously been merged, we cannot re-open from here. Can you please submit a new PR from the Branch and we'll work with you to get it merged?

Thanks!

No problem @jackofallops PR recreated here:
#27677

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants