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_hybrid_compute_machine_extension #21027

Closed
wants to merge 20 commits into from

Conversation

liuwuliuyun
Copy link
Contributor

@liuwuliuyun liuwuliuyun commented Mar 20, 2023

New Resource: azurerm_hybrid_compute_machine_extension
Swagger: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2022-11-10/HybridCompute.json

Testing evidence will be provided after TC run completes.

Copy link
Member

@catriona-m catriona-m 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 this @liuwuliuyun - I've left a couple of minor comments here for you to consider.

Also, given that this is known as "Azure Arc" in the portal, we think it might make more sense to rename this along those same lines - azurerm_arc_machine_extension perhaps? This would also involve renaming the corresponding datasource too. Thanks!

@liuwuliuyun
Copy link
Contributor Author

liuwuliuyun commented Mar 31, 2023

Done the renaming. Here is the testing evidence.

image

func (r HybridComputeMachineDataSource) ResourceType() string {
return "azurerm_hybrid_compute_machine"
func (r ArcMachineDataSource) ResourceType() string {
return "azurerm_arc_machine"
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change, we'd need to add a new data source with the correct name and deprecate this one.

Copy link
Contributor Author

@liuwuliuyun liuwuliuyun Apr 11, 2023

Choose a reason for hiding this comment

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

Should I just change this name back? Since this RP is named hybridcompute, why dont we just call it hybrid_compute_machine and hybrid_compute_machine_extension. Which I believe make more sense than "arc_machine" for any new users. Plus, it will not cause a breaking change.

Comment on lines +168 to +191
"code": {
Type: pluginsdk.TypeString,
Computed: true,
},

"display_status": {
Type: pluginsdk.TypeString,
Computed: true,
},

"level": {
Type: pluginsdk.TypeString,
Computed: true,
},

"message": {
Type: pluginsdk.TypeString,
Computed: true,
},

"time": {
Type: pluginsdk.TypeString,
Computed: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to have multiple statuses? These properties can probably be flattened and moved up a level

Comment on lines +196 to +199
"type": {
Type: pluginsdk.TypeString,
Computed: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

Same comment regarding the field type we do not usually expose these fields.

Comment on lines +405 to +408
model := resp.Model
if model == nil {
return fmt.Errorf("retrieving %s: model was nil", id)
}
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to return an error if Model is nil (same applies to Properties) and for readability we assign it to a variable

Suggested change
model := resp.Model
if model == nil {
return fmt.Errorf("retrieving %s: model was nil", id)
}
if model := resp.Model; model != nil {
...
if props := model.Properties; props != nil {
...

Comment on lines +145 to +159
func (r HybridComputeMachineExtensionResource) complete(data acceptance.TestData, template string) string {
return fmt.Sprintf(`
%s

resource "azurerm_arc_machine_extension" "test" {
name = "acctest-hcme-%d"
arc_machine_id = data.azurerm_arc_machine.test.id
location = "%s"
automatic_upgrade_enabled = false
publisher = "Microsoft.Azure.Monitor"
type = "AzureMonitorLinuxAgent"
type_handler_version = "1.24"
}
`, template, data.RandomInteger, data.Locations.Primary)
}
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this config is missing a fair few properties for it to be complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me add settings and protected settings example to complete config.

Comment on lines +177 to +183
func (r HybridComputeMachineExtensionResource) template(data acceptance.TestData) string {
d := HybridComputeMachineDataSource{}
clientSecret := os.Getenv("ARM_CLIENT_SECRET")
randomUUID, _ := uuid.GenerateUUID()
password := generateRandomPassword(10)
return d.basic(data, clientSecret, randomUUID, password)
}
Copy link
Member

Choose a reason for hiding this comment

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

For consistency the template should exist within the resource's tests and be referenced by the data source tests, not the other way around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, Let me change this.

@liuwuliuyun
Copy link
Contributor Author

liuwuliuyun commented Apr 13, 2023

@stephybun @catriona-m what do you guys think of the naming of resources in the resource provider? Currently we have two options.

  1. keeping every resource starts with azurerm_hybrid_compute_machine*. This solution has no breaking change for users and it aligns with the RP name. If we choose this one, I will revert the name back in this RP with all the suggested change.
  2. change to azurerm_arc_machine*. This solution makes breaking change to current datasource so we have to keep both until 4.0. If we choose this one, I may need to change the datasource first and add this extension with another PR.

@stephybun
Copy link
Member

@liuwuliuyun - the commercial product name which is user facing and carries more weight than the resource provider's name is Azure Arc (for future reference the words hybrid and connected are synonymous with arc in Azure). For consistency with other Arc specific resources within the provider i.e. azurerm_arc_kubernetes_cluster these need to be named/renamed azurerm_arc_*.

It's better to fix these now to set the correct precedent.

@liuwuliuyun
Copy link
Contributor Author

Ok, let me start working on that.

@liuwuliuyun
Copy link
Contributor Author

liuwuliuyun commented Apr 23, 2023

Close this PR due to pending completion name change on the exsiting resources. Will open a new one.

Copy link

github-actions bot commented Jun 2, 2024

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 Jun 2, 2024
@liuwuliuyun liuwuliuyun deleted the hc-ext branch September 19, 2024 06:55
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.

4 participants