-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Changes from 9 commits
851699d
a77f38e
1111471
67dda3f
547a7cf
80e65c3
fa1d8d0
d0fe26c
bd50a25
87a68d1
9c37781
0f3cb84
bce7ef8
9a7b998
1b3cc70
6ca8c00
87c5510
db79bfc
909ae41
4f423ea
0c8c96a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -651,7 +651,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 !meta.(*clients.Client).Features.ManagedDisk.NoDowntimeResize || shutDownOnResize(disk, 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") | ||
|
@@ -976,3 +978,19 @@ func resourceManagedDiskDelete(d *pluginsdk.ResourceData, meta interface{}) erro | |
|
||
return nil | ||
} | ||
|
||
func shutDownOnResize(disk compute.Disk, oldSizeGB, newSizeGB int) bool { | ||
// OS disks can't be expanded without downtime. | ||
if disk.OsType != "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
} | ||
// Standard HDD disks can't be expanded without downtime | ||
if disk.Sku.Name == compute.DiskStorageAccountTypesStandardLRS { | ||
kazimierzbudzyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
} | ||
return false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,10 @@ provider "azurerm" { | |
permanently_delete_on_destroy = true | ||
} | ||
|
||
managed_disk { | ||
no_downtime_resize = true | ||
} | ||
|
||
resource_group { | ||
prevent_deletion_if_contains_resources = true | ||
} | ||
|
@@ -86,6 +90,8 @@ The `features` block supports the following: | |
|
||
* `log_analytics_workspace` - (Optional) A `log_analytics_workspace` block as defined below. | ||
|
||
* `managed_disk` - (Optional) A `managed_disk` block as defined below. | ||
|
||
* `resource_group` - (Optional) A `resource_group` block as defined below. | ||
|
||
* `template_deployment` - (Optional) A `template_deployment` block as defined below. | ||
|
@@ -148,6 +154,12 @@ The `log_analytics_workspace` block supports the following: | |
|
||
--- | ||
|
||
The `managed_disk` block supports the following: | ||
|
||
* `no_downtime_resize` (Optional) Specifies if no-downtime resizes are enabled for the managed disk resources. Defaults to `true`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe use the same name as azure does for this feature enable_live_resize or something like that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah agreed - digging around this it appears that |
||
|
||
--- | ||
|
||
The `resource_group` block supports the following: | ||
|
||
* `prevent_deletion_if_contains_resources` - (Optional) Should the `azurerm_resource_group` resource check that there are no Resources within the Resource Group during deletion? This means that all Resources within the Resource Group must be deleted prior to deleting the Resource Group. Defaults to `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.
it appears the product name for this has settled on
Expand Without Downtime
as such we should make this: