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

Update azurerm_linux|windows_virtual_machine - make dedicated_host_id updatable #9264

Merged

Conversation

ArcturusZhang
Copy link
Contributor

No description provided.

@ghost ghost added size/L and removed size/XL labels Nov 11, 2020
@ArcturusZhang ArcturusZhang marked this pull request as ready for review November 11, 2020 08:34
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 @ArcturusZhang

Thanks for this PR.

I've taken a look through and left some comments inline but if we can fix those up then we can run the tests and see how this looks 👍

Thanks!

@@ -741,6 +740,13 @@ func resourceLinuxVirtualMachineUpdate(d *schema.ResourceData, meta interface{})
update.Identity = identity
}

if d.HasChange("dedicated_host_id") {
shouldUpdate = true
Copy link
Member

Choose a reason for hiding this comment

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

presumably this also needs to be shut-down and de-allocated - or does the API support live-migration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it needs to be deallocated. But shutdown might not be required, the API does not return any error on that and the update was successful

@@ -786,6 +785,18 @@ func resourceWindowsVirtualMachineUpdate(d *schema.ResourceData, meta interface{
update.Identity = identity
}

if d.HasChange("dedicated_host_id") {
shouldUpdate = true
shouldDeallocate = true
Copy link
Member

Choose a reason for hiding this comment

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

presumably this also needs to be shut-down too?

@ghost ghost added size/XL and removed size/L labels Nov 12, 2020
@ArcturusZhang
Copy link
Contributor Author

ArcturusZhang commented Nov 12, 2020

Hi @tombuildsstuff thank you for review.
I have updated the tests to make the dedicated host id could be updated from

  1. no dedicated host associated
  2. associated to one
  3. associated to another one
  4. association removed.

But I have to write the config with a lot of redundant resources to avoid the terraform bug (I am not sure whether it is resolved).
When we have a state of a dedicated host and a VM associated with that, in the config, we removed dedicated host and the association, in the next apply, terraform will try to first delete the dedicated host and service will return an error complaining the dedicated host cannot be deleted since it is in-use in the VM. To avoid this issue, I have to remain the dedicated host unreferenced in the last step's config.

@ArcturusZhang
Copy link
Contributor Author

And @tombuildsstuff amazingly actually this update of dedicated host id does not requires a shutdown of the VM - at least my tests could work properly.

@katbyte katbyte added this to the v2.37.0 milestone Nov 16, 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 @ArcturusZhang - this LGTM now 👍

@katbyte katbyte merged commit 1e29318 into hashicorp:master Nov 16, 2020
katbyte added a commit that referenced this pull request Nov 16, 2020
@ArcturusZhang ArcturusZhang deleted the virtual-machine-enhancement-host branch November 17, 2020 00:39
@ghost
Copy link

ghost commented Nov 20, 2020

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

@ghost
Copy link

ghost commented Dec 17, 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 as resolved and limited conversation to collaborators Dec 17, 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

3 participants