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 New Resource & Data Source: azurerm_netapp_volume #4933

Merged
merged 13 commits into from Dec 18, 2019

Conversation

neil-yechenwei
Copy link
Contributor

@neil-yechenwei neil-yechenwei commented Nov 20, 2019

This PR is code implement for issue #3936

Fixes #3936

Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hi @neil-yechenwei

Thanks for this PR - I've taken a look through and left some comments inline but this is off to a good start - there's a few bits of the schema which need to be updated (in particular the allowed_clients field), but if we can fix up the comments then we should be able to run the tests and take another look :)

Thanks!

Computed: true,
},

"export_policy_rule": {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove this field - since I don't think it's likely to be used by users?

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 so. Now both powershell and azure portal for netapp volume have opened this entry to let user edit export policy. And we cannot ensure the users won't use this, right? If they want to use, then I need to submit another PR for this? I think it's not a good option,right? So why don't we leave it as optional field? And this field should be optional after checked official doc https://docs.microsoft.com/en-us/azure/azure-netapp-files/azure-netapp-files-configure-export-policy.

Copy link
Member

Choose a reason for hiding this comment

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

whilst users may configure this on the Resource, the Data Source is Read Only and I can't envisage a scenario where users are likely to use this in the Data Source (since this needs to be a Set too) - for now let's remove it and we can add it back in if users request it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

azurerm/data_source_netapp_volume.go Show resolved Hide resolved
azurerm/internal/services/netapp/validate.go Show resolved Hide resolved
azurerm/internal/services/netapp/validate.go Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Outdated Show resolved Hide resolved
website/docs/r/netapp_volume.html.markdown Outdated Show resolved Hide resolved
website/docs/r/netapp_volume.html.markdown Outdated Show resolved Hide resolved
},

"export_policy_rule": {
Type: schema.TypeList,
Copy link
Member

Choose a reason for hiding this comment

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

since the rule_index is part of this presumably these could be returned in any order and export_policy_rule needs to become a Set?

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 found other field *_rule also is set as TypeList in existing resources of terraform. So I also can set this field as TypeList like others, right? I think even if these could be returned in any order, but I think it doesn't mean it must be set as TypeSet, right? For more details about rule_index and export_policy, please see this doc https://docs.microsoft.com/en-us/azure/azure-netapp-files/azure-netapp-files-configure-export-policy

Copy link
Collaborator

Choose a reason for hiding this comment

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

Most of those should probably be TypeSets too, as order doesn't matter if rule_index is used, otherwise if we keep it as a typelist the ordering could be implicitly inferred by the index. WDYT @tombuildsstuff ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

azurerm/resource_arm_netapp_volume.go Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Show resolved Hide resolved
Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hi @neil-yechenwei

Thanks for this PR - I've taken a look through and left some comments inline but this is off to a good start - there's a few bits of the schema which need to be updated (in particular the allowed_clients field), but if we can fix up the comments then we should be able to run the tests and take another look :)

Thanks!

@tombuildsstuff
Copy link
Member

(sorry for the double-review, Github returned a 500 🙃)

@neil-yechenwei
Copy link
Contributor Author

@tombuildsstuff , Thanks for your comments. I've updated code per your comments.

@ghost ghost removed the waiting-response label Nov 21, 2019
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 for the revisions @neil-yechenwei, i've left some more comments inline

azurerm/resource_arm_netapp_pool_test.go Outdated Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Show resolved Hide resolved
},

"export_policy_rule": {
Type: schema.TypeList,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Most of those should probably be TypeSets too, as order doesn't matter if rule_index is used, otherwise if we keep it as a typelist the ordering could be implicitly inferred by the index. WDYT @tombuildsstuff ?

azurerm/resource_arm_netapp_volume.go Outdated Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Show resolved Hide resolved
azurerm/resource_arm_netapp_volume_test.go Show resolved Hide resolved
azurerm/resource_arm_netapp_volume_test.go Show resolved Hide resolved
website/docs/d/netapp_volume.html.markdown Outdated Show resolved Hide resolved
website/docs/r/netapp_volume.html.markdown Outdated Show resolved Hide resolved
@neil-yechenwei
Copy link
Contributor Author

@katbyte , Thanks for your comments. I've updated code per your comments.

@ghost ghost removed the waiting-response label Nov 22, 2019
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 for the revisions @neil-yechenwei, i've left a couple of additional minor comments inline

azurerm/resource_arm_netapp_pool.go Show resolved Hide resolved
ValidateFunc: validation.IntBetween(1, 5),
},
"allowed_clients": {
Type: schema.TypeList,
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 probably be a set too>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

azurerm/resource_arm_netapp_volume.go Show resolved Hide resolved

* `location` - The Azure Region where the NetApp Volume exists.

* `creation_token` - A unique file path for the volume.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we use data source language here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

website/docs/d/netapp_volume.html.markdown Outdated Show resolved Hide resolved

* `rule_index` - (Required) The index number of the rule.

* `allowed_clients` - (Required) Client ingress specification as list with IPv4 CIDRs, IPv4 host addresses.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we fix the grammar here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


* `service_level` - (Required) The service level of the file system. Valid values include `Premium`, `Standard`, or `Ultra`.

* `subnet_id` - (Required) The ID of a Subnet in which the NetApp Volume, which must have the delegation Microsoft.NetApp/volumes. Changing this forces a new resource to be created.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we fix the grammar here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


* `creation_token` - (Required) A unique file path for the volume. Used when creating mount targets.

* `service_level` - (Required) The service level of the file system. Valid values include `Premium`, `Standard`, or `Ultra`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we elaborate on what the service level means?

website/docs/r/netapp_volume.html.markdown Outdated Show resolved Hide resolved
@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Dec 4, 2019

Thanks for the comments @katbyte , I've created a new issue on azure-sdk-for-go for this API and updated the code per your comments.

@ghost ghost removed the waiting-response label Dec 4, 2019
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.

Thank you for the revisions @neil-yechenwei, I've left some more comments inline that should be addressed before merge.

azurerm/data_source_netapp_volume.go Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Outdated Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Outdated Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Outdated Show resolved Hide resolved
d.Set("subnet_id", props.SubnetID)

if props.UsageThreshold != nil {
d.Set("usage_threshold", *props.UsageThreshold/1073741824)
Copy link
Collaborator

Choose a reason for hiding this comment

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

what units is usage_threshold in? could we make the name usage_threshold_in_units

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 am confused. You want this field name is updated to "usage_threshold_in_units" or "storage_quota_in_gb"? I think "storage_quota_in_gb" as you suggested below is preferred so that I updated this field name to "storage_quota_in_gb".

website/docs/r/netapp_volume.html.markdown Outdated Show resolved Hide resolved
website/docs/r/netapp_volume.html.markdown Outdated Show resolved Hide resolved

* `account_name` - (Required) The name of the NetApp account in which the NetApp Pool should be created. Changing this forces a new resource to be created.

* `creation_token` - (Required) A unique file path for the volume. Used when creating mount targets. Changing this forces a new resource to be created.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this perhaps be called something different? creation token seems odd if its more the "volume path"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

website/docs/r/netapp_volume.html.markdown Outdated Show resolved Hide resolved
website/docs/r/netapp_volume.html.markdown Show resolved Hide resolved
@neil-yechenwei
Copy link
Contributor Author

Thank you for the comments @katbyte , I've updated code per your comments.

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 for the revisions @neil-yechenwei,

In addition to the comments i've left inline some tests are failing:

------- Stdout: -------
=== RUN   TestAccAzureRMNetAppVolume_complete
=== PAUSE TestAccAzureRMNetAppVolume_complete
=== CONT  TestAccAzureRMNetAppVolume_complete
--- FAIL: TestAccAzureRMNetAppVolume_complete (899.77s)
    testing.go:569: Step 0 error: errors during apply:
        
        Error: Error waiting for creation of NetApp Volume "acctest-NetAppVolume-191211182103728355" (Resource Group "acctestRG-netapp-191211182103728355"): Code="InternalServerError" Message="Error calling V1CreateIPRange: {\"code\":null,\"message\":\"Error creating IP range - Specified IP range clashes with an existing IP range\"}\n"
Error: Error waiting for creation of NetApp Volume "acctest-NetAppVolume-191211182103680430" (Resource Group "acctestRG-netapp-191211182103680430"): Code="InternalServerError" Message="The requested FileSystemAllocation was not found."

azurerm/internal/services/netapp/validation_test.go Outdated Show resolved Hide resolved
azurerm/data_source_netapp_volume.go Outdated Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Outdated Show resolved Hide resolved
@tombuildsstuff tombuildsstuff modified the milestones: v1.39.0, v1.40.0 Dec 12, 2019
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.

@neil-yechenwei,

there are still some issues that need to be addressed and multiple tests are failing:

------- Stdout: -------
=== RUN   TestAccAzureRMNetAppVolume_updateSubnet
=== PAUSE TestAccAzureRMNetAppVolume_updateSubnet
=== CONT  TestAccAzureRMNetAppVolume_updateSubnet
--- FAIL: TestAccAzureRMNetAppVolume_updateSubnet (167.89s)
    testing.go:569: Step 0 error: errors during apply:
        
        Error: Error waiting for creation of NetApp Volume "acctest-NetAppVolume-191212172909800478" (Resource Group "acctestRG-netapp-191212172909800478"): Code="InternalServerError" Message="Error calling V1CreateIPRange: {\"code\":null,\"message\":\"Error creating IP range - Specified IP range clashes with an existing IP range\"}\n"

i suggest running all tests in parallel

azurerm/resource_arm_netapp_volume.go Outdated Show resolved Hide resolved
azurerm/resource_arm_netapp_volume.go Outdated Show resolved Hide resolved
website/docs/r/netapp_volume.html.markdown Outdated Show resolved Hide resolved
@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Dec 13, 2019

@katbyte , I already used the command you provided before for testing. Below is my test result whose test cases are all passed. I am using the test command make testacc TEST=./azurerm TESTARGS="-parallel 11 -test.run=TestAccAzureRMNetAppVolume". If it's different with yours, could you share your test command. So I think maybe it's just your test environment issue. Could you double check whether you deleted all NetApp related resources in Azure portal and make sure there is no your own changes on your local before testing? After you deleted all NetApp related resource, please rerun the test cases and all test cases should be passed. For your other comments, I've updated code.

--- PASS: TestAccAzureRMNetAppVolume_complete (571.17s)
--- PASS: TestAccAzureRMNetAppVolume_update (774.01s)
--- PASS: TestAccAzureRMNetAppVolume_basic (968.05s)
--- PASS: TestAccAzureRMNetAppVolume_updateExportPolicyRule (1141.21s)
--- PASS: TestAccAzureRMNetAppVolume_updateSubnet (1546.39s)
PASS
ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 1561.007s

@ghost ghost removed the waiting-response label Dec 13, 2019
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 for the revisions @neil-yechenwei, tests pass and this LGTM now!

@katbyte katbyte merged commit 2ebd225 into hashicorp:master Dec 18, 2019
katbyte added a commit that referenced this pull request Dec 18, 2019
@ghost
Copy link

ghost commented Jan 8, 2020

This has been released in version 1.40.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 1.40.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Mar 28, 2020
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.

Implement Azure Netapp Files Support
3 participants