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

Support OS disk size or storage type changes #1313

Closed
wants to merge 1 commit into from
Closed

Support OS disk size or storage type changes #1313

wants to merge 1 commit into from

Conversation

r7vme
Copy link
Contributor

@r7vme r7vme commented May 29, 2018

Related issue: #345

This change allows to change OS disk size and/or storage type by forcing VM recreation.

This is my first code contribution to terraform provider. Please point me if docs/tests adjustments are needed.

Use case

This fits our use case: We switch our "ephemeral" VMs to new storage_type and want terraform to handle it. In current state it fails with

* azurerm_virtual_machine.test: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=409 -- Original Error: failed r
equest: autorest/azure: Service returned an error. Status=<nil> Code="OperationNotAllowed" Message="Managed disk storage account type change thro
ugh Virtual Machine 'acctvm' is not allowed. Please update disk resource at /subscriptions/1be3b2e6-497b-45b9-915f-eb35cae23c6a/resourceGroups/ro
mantest1/providers/Microsoft.Compute/disks/myosdisk1." Target="osDisk.managedDisk.storageAccountType"

Limitations

This does not work if "delete_os_disk_on_termination" is set to "false" (default) and fails with

* azurerm_virtual_machine.test: Long running operation terminated with status 'Failed': Code="ConflictingUserInput" Message="Disk myosdisk1 alrea
dy exists in resource group ROMANTEST1. Only CreateOption.Attach is supported."  

What is the best way to handle such use cases?

Notes

This is nothing to do with data disks changes. In case data disks, i assume we need to gently detach disk/stop vm and make changes. #1207 looks like requirement for data disk changes.

@r7vme r7vme changed the title [WIP] Support OS disk size or type changes [WIP] Support OS disk size or storage type changes May 29, 2018
@katbyte katbyte changed the title [WIP] Support OS disk size or storage type changes Support OS disk size or storage type changes Jun 6, 2018
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.

Hi @r7vme,

Thank you for opening this PR, this has been a long outstanding issue. Unfortunately it is not as easy as marking the properties as force new. This is because now when any additional disks are then added the resource will be recreated.

To correctly work around this a CustomizeDiff function needs to be added to only force a new resource on a diskrename/resize, while not doing a force new of the resource.

There is an old branch exploring this for disk renaming here (size would be the same in theory)

Happy to provide further guidance if you have any questions.

@katbyte katbyte added this to the Future milestone Jul 24, 2018
@metacpp metacpp requested a review from JunyiYi August 2, 2018 23:57
@JunyiYi
Copy link

JunyiYi commented Aug 6, 2018

Hi @r7vme , Thanks for the contribution. Besides the suggestions provided by @katbyte , you also need to update the document here: https://github.com/terraform-providers/terraform-provider-azurerm/blame/master/website/docs/r/virtual_machine.html.markdown#L297.

@r7vme
Copy link
Contributor Author

r7vme commented Oct 5, 2018

thanks for suggestions, unfortunately i don't have timeslot now to work on this.

@r7vme r7vme closed this Oct 5, 2018
@r7vme r7vme deleted the resize_os_disk branch October 5, 2018 08:56
@tombuildsstuff tombuildsstuff modified the milestones: Future, Being Sorted Oct 25, 2018
@ghost
Copy link

ghost commented Mar 6, 2019

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!

@ghost ghost locked and limited conversation to collaborators Mar 6, 2019
@ghost ghost removed the waiting-response label Mar 6, 2019
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