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
Show file tree
Hide file tree
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
17 changes: 16 additions & 1 deletion internal/services/compute/managed_disk_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ func resourceManagedDisk() *pluginsdk.Resource {
Optional: true,
},

"no_downtime_resize_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

since this is a behavioural feature, this'd need to be added to the features block rather than being enabled against the resource - although I think we actually want to enable this functionality by default where possible once this goes GA - as such I'm not sure this makes sense as a behavioural feature here, where we can instead wait for this to hit GA first and then enable this by default?

We'll also need to update the shutDownOnResize method below to check the disk type too, since this is only supported for Data Disks and not OS Disks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @tombuildsstuff! Implementing your feedback...

This feature is something my team could use immediately (and likely a lot of other users). If possible starting with it being opt-in while in preview would be super helpful to us, especially if GA will take a bit more. After GA we definitely should flip the default of the feature flag as it will make a lot of operations much easier.


"zone": commonschema.ZoneSingleOptionalForceNew(),

"tags": tags.Schema(),
Expand Down Expand Up @@ -652,7 +657,9 @@ 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) {
shouldShutDown = true
if !d.Get("no_downtime_resize_enabled").(bool) || shutDownOnResize(old.(int), new.(int)) {
shouldShutDown = true
}
diskUpdate.DiskUpdateProperties.DiskSizeGB = utils.Int32(int32(new.(int)))
} else {
return fmt.Errorf("- New size must be greater than original size. Shrinking disks is not supported on Azure")
Expand Down Expand Up @@ -977,3 +984,11 @@ func resourceManagedDiskDelete(d *pluginsdk.ResourceData, meta interface{}) erro

return nil
}

func shutDownOnResize(oldSizeGB, newSizeGB int) bool {
// Disks smaller than 4 TiB can't be expanded to 4 TiB or larger without downtime.
if oldSizeGB < 4096 && newSizeGB >= 4096 {
return true
}
return false
}
2 changes: 2 additions & 0 deletions website/docs/r/managed_disk.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ The following arguments are supported:

* `on_demand_bursting_enabled` (Optional) Specifies if On-Demand Bursting is enabled for the Managed Disk. Defaults to `false`.

* `no_downtime_resize_enabled` (Optional) Specifies if no-downtime resizes are enabled for the Managed Disk. Feature is currently in public preview and needs to be opted in. More information can be found in [Resize without downtime (preview) documentation](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/expand-disks#resize-without-downtime-preview) Defaults to `false`.

-> **Note:** Credit-Based Bursting is enabled by default on all eligible disks. More information on [Credit-Based and On-Demand Bursting can be found in the documentation](https://docs.microsoft.com/azure/virtual-machines/disk-bursting#disk-level-bursting).

* `tags` - (Optional) A mapping of tags to assign to the resource.
Expand Down