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

Add support for no-downtime disk resizes. #17245

Merged
merged 21 commits into from
Nov 9, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/services/compute/managed_disk_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ func resourceManagedDiskUpdate(d *pluginsdk.ResourceData, meta interface{}) erro

if d.HasChange("disk_size_gb") {
if old, new := d.GetChange("disk_size_gb"); new.(int) > old.(int) {
if !meta.(*clients.Client).Features.ManagedDisk.NoDowntimeResize || shutDownOnResize(old.(int), new.(int)) {
if !meta.(*clients.Client).Features.ManagedDisk.NoDowntimeResize || shutDownOnResize(disk, old.(int), new.(int)) {
shouldShutDown = true
}
diskUpdate.DiskUpdateProperties.DiskSizeGB = utils.Int32(int32(new.(int)))
Expand Down Expand Up @@ -980,7 +980,11 @@ func resourceManagedDiskDelete(d *pluginsdk.ResourceData, meta interface{}) erro
return nil
}

func shutDownOnResize(oldSizeGB, newSizeGB int) bool {
func shutDownOnResize(disk compute.Disk, oldSizeGB, newSizeGB int) bool {
// OS disks can't be expanded without downtime.
if disk.OsType != "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tombuildsstuff - let me know if you have suggestions for a better way of detecting data disks.

return true
}
// Disks smaller than 4 TiB can't be expanded to 4 TiB or larger without downtime.
if oldSizeGB < 4096 && newSizeGB >= 4096 {
return true
Expand Down