-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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: Dedicated Host #5417
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pr @magodo, overall this is looking pretty good! I've left some comments inline that once addressed (and tests pass) this should be good to merge
azurerm/internal/services/compute/resource_arm_dedicated_host.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/resource_arm_dedicated_host.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/resource_arm_dedicated_host.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/resource_arm_dedicated_host.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/resource_arm_dedicated_host.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/resource_arm_dedicated_host.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/tests/resource_arm_dedicated_host_test.go
Show resolved
Hide resolved
azurerm/internal/services/compute/tests/resource_arm_dedicated_host_test.go
Show resolved
Hide resolved
We are also seeing some failed tests:
|
Includes: - custom parser function - rename `sku` to `sku_name` - multi-line code to oneline - increase each timeout of state polling for eventual consistency from 5sec to 10 sec, to alleviate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @magodo,
This is getting quite close, just a few more mostly minor comments inline to address!
Name string | ||
Input string | ||
ExpectedOK bool | ||
ExpectedValue *DedicatedHostId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make this like the supplied PR?
Name string
Input string
Expected *AppServiceResourceID
we can assume nil means an error occured
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way did in PR, by looking through the test table, it feels like user of this function can just reply on the first return value to see whether something goes wrong, and there is no guarantee about the second return value (err
).
While actually we should explicitly tell user some error occurs for invalid resource ID so that user could reply on the err
to see whether something goes wrong and can use the err
to log or whatever.
azurerm/internal/services/compute/resource_arm_dedicated_host.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/tests/resource_arm_dedicated_host_test.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/tests/resource_arm_dedicated_host_test.go
Outdated
Show resolved
Hide resolved
azurerm/internal/services/compute/tests/resource_arm_dedicated_host_test.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @magodo
Thanks for pushing those changes - I've taken a look through and left some comments inline but this is looking good to me - if we can fix up the remaining comments (and the tests pass) then this otherwise LGTM 👍
Thanks!
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validateDedicatedHostGroupName(), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than passing in the Resource Group / Host Group Name here - we can instead pass in the Host Group ID and pull this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on reflection can we make this dedicated_host_group_id
rather than host_group_id
if utils.ResponseWasNotFound(res.Response) { | ||
return "NotFound", "NotFound", nil | ||
} | ||
return nil, "", fmt.Errorf("Error issuing read request in dedicatedHostDeletedRefreshFunc: %+v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return nil, "", fmt.Errorf("Error issuing read request in dedicatedHostDeletedRefreshFunc: %+v", err) | |
return nil, "", fmt.Errorf("Error checking for the status of the Host Group deletion: %+v", err) |
{ | ||
Config: testAccDataSourceDedicatedHost_basic(data), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet(data.ResourceName, "id"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking the ID is superflurious (since this'll fail without it) - can we check the specific fields here?
resource.TestCheckResourceAttr(data.ResourceName, "license_type", string(compute.DedicatedHostLicenseTypesNone)), | ||
resource.TestCheckResourceAttr(data.ResourceName, "auto_replace_on_failure", "true"), | ||
resource.TestCheckResourceAttr(data.ResourceName, "platform_fault_domain", "1"), | ||
resource.TestCheckResourceAttr(data.ResourceName, "sku_name", "DSv3-Type1"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of checking the value of the specific fields we can just use the import step below to do this for us
resource.TestCheckResourceAttr(data.ResourceName, "platform_fault_domain", "1"), | ||
resource.TestCheckResourceAttr(data.ResourceName, "sku_name", "DSv3-Type1"), | ||
resource.TestCheckResourceAttr(data.ResourceName, "license_type", string(compute.DedicatedHostLicenseTypesWindowsServerHybrid)), | ||
resource.TestCheckResourceAttr(data.ResourceName, "auto_replace_on_failure", "false"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of checking the value of the specific fields we can just use the import step below to do this for us
```hcl | ||
resource "azurerm_resource_group" "example" { | ||
name = "example-rg" | ||
location = "West US" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use West Europe for all examples
location = "West US" | |
location = "West Europe" |
|
||
# azurerm_dedicated_host | ||
|
||
Manage an Dedicated Host. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manage an Dedicated Host. | |
Manage a Dedicated Host within a Dedicated Host Group. |
layout: "azurerm" | ||
page_title: "Azure Resource Manager: azurerm_dedicated_host" | ||
description: |- | ||
Manage an Dedicated Host. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manage an Dedicated Host. | |
Manage a Dedicated Host within a Dedicated Host Group. |
|
||
* `platform_fault_domain` - (Required) Specify the fault domain of the Dedicated Host Group in which to create the Dedicated Host. Changing this forces a new resource to be created. | ||
|
||
* `auto_replace_on_failure` - (Optional) Specifies whether the Dedicated Host should be replaced automatically in case of a failure. The value is defaulted to `true` when not provided. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to make this consistent with other resources can we make this:
* `auto_replace_on_failure` - (Optional) Specifies whether the Dedicated Host should be replaced automatically in case of a failure. The value is defaulted to `true` when not provided. | |
* `auto_replace_on_failure` - (Optional) Specifies whether the Dedicated Host should be replaced automatically in case of a failure. Defaults to `true`. |
|
||
```hcl | ||
resource "azurerm_resource_group" "example" { | ||
name = "example-rg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name = "example-rg" | |
name = "example-resources" |
hey @magodo Thanks for this PR - so that we can get this merged in order to support Dedicated Hosts within the new VM Resource, I hope you don't mind but I'm going to push a commit to resolve the pending comments here and kick off the tests 👍 Thanks! |
This has been released in version 1.42.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.42.0"
}
# ... other configuration ... |
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 👉 [email protected]. Thanks! |
New resource dedicated host.
Note:
-parallel=N
intogo test