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

azurerm_netapp_volume - support mount_ip_addresses #5526

Merged
merged 18 commits into from
May 20, 2020

Conversation

neil-yechenwei
Copy link
Contributor

@neil-yechenwei neil-yechenwei commented Jan 26, 2020

Fixes #5416

@tombuildsstuff tombuildsstuff removed the request for review from katbyte February 4, 2020 10:14
Copy link
Contributor

@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 the main question I've got is regarding the resource design, if we can clarify that then we should be able to determine how to proceed here.

Thanks!

for _, item := range input.([]interface{}) {
if item != nil {
v := item.(map[string]interface{})
ipAddress := v["ipAddress"]
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to be:

Suggested change
ipAddress := v["ipAddress"]
ipAddress := v["ip_address"].(string)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It cannot be updated to "ip_address" since api returns ""mountTargets":[{"provisioningState":"Succeeded","ipAddress":"10.0.2.4"}]" for property mountTargets.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah so this nested object isn't modelled as an object in the Swagger? in which case can we send a PR to the Swagger repo to fix that

Copy link
Contributor

Choose a reason for hiding this comment

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

When it comes to mountTargets, it reminds me that I changed that some time ago... and it may be a mistake. I will take a look at this and see how to change it correctly (and when changing the swagger we should let the service team know and approve, which may take a long time).

@@ -42,6 +42,19 @@ func dataSourceArmNetAppVolume() *schema.Resource {
ValidateFunc: ValidateNetAppPoolName,
},

"mount_targets": {
Type: schema.TypeSet,
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to be a TypeList if it's a Computed field else it's not easily indexable - however - what are the mount targets here, a list of IP Addresses which should be used to mount the volume? If so it's likely this'd make more sense as a list of strings being mount_ip_addresses?

can we also update the test to confirm this field is correctly 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.

Fixed

@neil-yechenwei
Copy link
Contributor Author

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

Copy link
Contributor

@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.

hey @neil-yechenwei

Thanks for making those changes - taking a look through whilst this looks good it appears we also need to send a PR to fix the Swagger prior to merging this, else breaking changes to the API Response won't be caught via the ARM "breaking changes" process - would you be able to send a PR to fix that in the Swagger and link that in the code here so that we can switch it out once fixed?

Thanks!

@@ -43,6 +43,8 @@ The following attributes are exported:

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

* `mount_ip_addresses` - A list of IPv4 Addresses which should be used to mount the volume.
Copy link
Contributor

Choose a reason for hiding this comment

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

this has also been added to the Resource - so can we document this field there 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.

I didn't add this field "mount_ip_addresses" to the resource file. I just added this to data source file. So I think we don't need to document this field to resource md file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason we are only adding it to the datasource and not the resource too? @neil-yechenwei

Copy link
Contributor Author

@neil-yechenwei neil-yechenwei Mar 6, 2020

Choose a reason for hiding this comment

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

You can find user's usage preference from (#5416), seems they want to use data source to retrieve this property value.

@tombuildsstuff tombuildsstuff added the sdk/requires-swagger-changes Changes need to be made in the Swagger specifications to enable this functionality label Feb 11, 2020
@tombuildsstuff tombuildsstuff modified the milestones: v1.44.0, Blocked Feb 11, 2020
@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Feb 11, 2020

hey @neil-yechenwei

Thanks for making those changes - taking a look through whilst this looks good it appears we also need to send a PR to fix the Swagger prior to merging this, else breaking changes to the API Response won't be caught via the ARM "breaking changes" process - would you be able to send a PR to fix that in the Swagger and link that in the code here so that we can switch it out once fixed?

Thanks!

@tombuildsstuff , I am not sure what you mean. Do you mean I need to make a fix to set property type of MountTargets as exact data type not interface{} like ExportPolicy in the Swagger, right? If not, may I know what & why I need to fix in the swagger?
image

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,

Yes that is correct, what tom is referring to is that the MountTargets property is an interface without type

// MountTargets - List of mount targets
	MountTargets interface{} `json:"mountTargets,omitempty"`

when it should be a fully typed array

// MountTargets - List of mount targets
	MountTargets *[]VolumePropertiesMountTarget `json:"mountTargets,omitempty"`

@neil-yechenwei
Copy link
Contributor Author

@katbyte , If you point to this issue, I've confirmed with service owner. They will fix this issue in the future but no ETA. So I've added a comment in the code and filed an issue (Azure/azure-rest-api-specs#8604) on rest api spec. Once they fix this issue, I will make an another PR to update code. So could you help to merge this PR first?

@ghost ghost removed the waiting-response label Mar 5, 2020
@neil-yechenwei neil-yechenwei requested a review from katbyte March 5, 2020 09:32
@katbyte katbyte added sdk/requires-newer-api-version This requires upgrading the version of the API being used sdk/requires-upgrade This is dependent upon upgrading an SDK and removed waiting-response labels Apr 13, 2020
@katbyte katbyte modified the milestones: v2.6.0, Blocked Apr 15, 2020
@ghost ghost added size/XXL and removed size/XL labels May 18, 2020
neil-yechenwei added 2 commits May 18, 2020 14:56
@ghost ghost added size/S and removed size/XXL labels May 18, 2020
@neil-yechenwei
Copy link
Contributor Author

@katbyte & @tombuildsstuff , I've applied the fix for property mountTargets after new go sdk is upgraded. Thanks.

@katbyte katbyte removed sdk/requires-newer-api-version This requires upgrading the version of the API being used sdk/requires-upgrade This is dependent upon upgrading an SDK labels May 20, 2020
@katbyte katbyte removed this from the Blocked milestone May 20, 2020
@katbyte
Copy link
Collaborator

katbyte commented May 20, 2020

@neil-yechenwei - could we add the property to the resource to? thanks!

@neil-yechenwei
Copy link
Contributor Author

@katbyte , I also added it to resource. Thanks.

@katbyte katbyte added this to the v2.11.0 milestone May 20, 2020
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 @neil-yechenwei - LGTM 👍

@katbyte katbyte changed the title Add more support for mountTargets for azurerm_netapp_volume azurerm_netapp_volume - support mount_ip_addresses May 20, 2020
@katbyte katbyte merged commit b0501f9 into hashicorp:master May 20, 2020
katbyte added a commit that referenced this pull request May 20, 2020
@ghost
Copy link

ghost commented May 22, 2020

This has been released in version 2.11.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 = "~> 2.11.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Jun 20, 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!

@ghost ghost locked and limited conversation to collaborators Jun 20, 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.

Support for [Azure NetApp Files] - Create volume no IP address in the attributes
5 participants