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 azurerm_maintenance_configuration #6038

Merged
merged 4 commits into from Apr 21, 2020

Conversation

njuCZ
Copy link
Contributor

@njuCZ njuCZ commented Mar 9, 2020

partially address #6037
Once it is merged, I'll go on implementing azurerm_maintenance_assignment

After tested, I found the resource_group_name from the response of read api is always small case, so I use azure.SchemaResourceGroupNameDiffSuppress()

Another point is the key of tags from the response of read api is always small case

image

@njuCZ njuCZ changed the title new Resource azurerm_maintenance_configuration New Resource azurerm_maintenance_configuration Mar 9, 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 for the new resource @njuCZ,

Aside from a couple minor comments iv'e left inline this is off to a great start!

scope = "Host"

tags = {
env = "test"
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 ensure uppercase works?

Suggested change
env = "test"
EnV = "TesT"

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 have changed the value to TesT
as for the key, this service will return small case key, regardless of the input case.
If we set EnV = "TesT", the service will return env = "TesT"

@njuCZ
Copy link
Contributor Author

njuCZ commented Mar 10, 2020

@katbyte Thanks for the suggestion, I have refined the codes accordingly. Please have a look again

@ghost ghost removed the waiting-response label Mar 10, 2020
@njuCZ njuCZ requested a review from katbyte March 10, 2020 07:44
@katbyte katbyte modified the milestones: v2.2.0, v2.3.0 Mar 18, 2020
@tombuildsstuff tombuildsstuff modified the milestones: v2.3.0, v2.5.0 Mar 25, 2020
@njuCZ njuCZ force-pushed the maintenance_config branch 4 times, most recently from 334e017 to 2c917ab Compare March 30, 2020 02:32
@jackofallops jackofallops self-assigned this Apr 1, 2020
Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

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

Hi @njuCZ
Thanks for this PR for the preview resource.
The code looks largely OK, but there are aspects/issues with the API that are going to make this problematic for Terraform, in particular the non-standard behaviour around Tag keys. I think we should investigate getting that behaviour corrected before trying to compensate in the provider, or progressing the PR towards merging.

Comment on lines 106 to 113
if _, err := client.CreateOrUpdate(ctx, resGroup, name, configuration); err != nil {
return fmt.Errorf("Error creating/updating MaintenanceConfiguration %q (Resource Group %q): %+v", name, resGroup, err)
}

resp, err := client.Get(ctx, resGroup, name)
if err != nil {
return fmt.Errorf("Error retrieving MaintenanceConfiguration %q (Resource Group %q): %+v", name, resGroup, err)
}
Copy link
Member

Choose a reason for hiding this comment

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

I have concerns around this as the ID in the return from CreateOrUpdate and Get are the same values, but the latter is returned entirely in lower case. This feels like a bug in the API and I'm concerned that when (if?) it is fixed, it will break for us here (since the parsing of the ID elements is case sensitive). Are you aware of any issue raised against this?

},

// can not contain upper case key
"tags": tags.Schema(),
Copy link
Member

Choose a reason for hiding this comment

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

I believe this behaviour to be a problem. Whilst Azure does not treat the Keys as case sensitive, normal expected behaviour is to return the casing provided by the user. Terraform also expects the keys to be returned as originally defined. Can we open an issue on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed


* `scope` - (Optional) The scope of the Maintenance Configuration. Possible values are `All`, `Host`, `Resource` or `InResource`. Default to `All`.

* `tags` - (Optional) A mapping of tags to assign to the resource.
Copy link
Member

Choose a reason for hiding this comment

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

If the tag key bug cannot be addressed, this needs to be highlighted here. Users specifying Tags that are not all lower will experience problems using this resource.

@jackofallops jackofallops modified the milestones: v2.5.0, v2.7.0 Apr 7, 2020
@njuCZ
Copy link
Contributor Author

njuCZ commented Apr 13, 2020

@jackofallops I have added some support for case insensitive resource ID, and added some notes in the doc, do you think it's ok? The service team says it's by design to make the case insensitive

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.

@njuCZ,

given the API has an issue could we open a ticket on the SDK & link to it in the code as well as add validation to prevent any tags from being added with upper case chars in the key?

},

// can not contain upper case key
"tags": tags.Schema(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed

@njuCZ
Copy link
Contributor Author

njuCZ commented Apr 15, 2020

@katbyte I have added custom validation for the tags and opened an issue, Could you please have a look again?

@ghost ghost removed the waiting-response label Apr 15, 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.

Aside from one comment LGTM @njuCZ! I'm gonna approve this and merge to get it in but i'd be great if you could open an issue on the SDK for the comment i've left inline (not a big deal to not link in code but that would be ideal). Thanks!

Comment on lines +24 to +25
if name, err := id.PopSegment("maintenanceconfigurations"); err != nil {
if name, err = id.PopSegment("maintenanceConfigurations"); err != nil {
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 open an SKD issue here and link to 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.

thank you. I have added such bug about returned resource id:
Azure/azure-rest-api-specs#8653
I have noted in the resource_group_name schema defnition

@katbyte katbyte merged commit 95efca9 into hashicorp:master Apr 21, 2020
katbyte added a commit that referenced this pull request Apr 21, 2020
@ghost
Copy link

ghost commented Apr 23, 2020

This has been released in version 2.7.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.7.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented May 21, 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 May 21, 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.

None yet

4 participants