Skip to content

Commit

Permalink
*_virtual_machine_scale_set: Do not force recreation on `rolling_up…
Browse files Browse the repository at this point in the history
…grade_policy` and `health_probe_id` update. (#10856)

Fixes #10851
  • Loading branch information
favoretti authored Mar 10, 2021
1 parent 32f160b commit d73de96
Show file tree
Hide file tree
Showing 7 changed files with 727 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,58 @@ func TestAccLinuxVirtualMachineScaleSet_otherPlatformFaultDomainCount(t *testing
})
}

func TestAccLinuxVirtualMachineScaleSet_otherRollingUpgradePolicyUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test")
r := LinuxVirtualMachineScaleSetResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.otherRollingUpgradePolicyUpdate(data, 10, 10, 10, "PT0S"),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"admin_password",
),
{
Config: r.otherRollingUpgradePolicyUpdate(data, 20, 20, 20, "PT1S"),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"admin_password",
),
})
}

func TestAccLinuxVirtualMachineScaleSet_otherHealthProbeUpdate(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_linux_virtual_machine_scale_set", "test")
r := LinuxVirtualMachineScaleSetResource{}

data.ResourceTest(t, r, []resource.TestStep{
{
Config: r.otherHealthProbe(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"admin_password",
),
{
Config: r.otherHealthProbeUpdated(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"admin_password",
),
})
}

func (r LinuxVirtualMachineScaleSetResource) otherBootDiagnostics(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -2045,3 +2097,311 @@ resource "azurerm_linux_virtual_machine_scale_set" "test" {
}
`, r.template(data), data.RandomInteger)
}

func (r LinuxVirtualMachineScaleSetResource) otherRollingUpgradePolicyUpdate(data acceptance.TestData, max_batch_instance_percent, max_unhealthy_instance_percent, max_unhealthy_upgraded_instance_percent int, pause_time_between_batches string) string {
return fmt.Sprintf(`
%s
locals {
frontend_ip_configuration_name = "internal"
}
resource "azurerm_public_ip" "test" {
name = "actestvmsspip-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
allocation_method = "Static"
}
resource "azurerm_lb" "test" {
name = "actestvmsslb-%[2]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
frontend_ip_configuration {
name = local.frontend_ip_configuration_name
public_ip_address_id = azurerm_public_ip.test.id
}
}
resource "azurerm_lb_backend_address_pool" "test" {
name = "backend"
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
}
resource "azurerm_lb_probe" "test" {
name = "ssh-running-probe"
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
port = 22
protocol = "Tcp"
}
resource "azurerm_lb_rule" "test" {
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
probe_id = azurerm_lb_probe.test.id
backend_address_pool_id = azurerm_lb_backend_address_pool.test.id
frontend_ip_configuration_name = local.frontend_ip_configuration_name
name = "LBRule"
protocol = "Tcp"
frontend_port = 22
backend_port = 22
}
resource "azurerm_linux_virtual_machine_scale_set" "test" {
name = "acctestvmss-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "Standard_F2"
instances = 3
admin_username = "adminuser"
admin_password = "P@ssword1234!"
disable_password_authentication = false
upgrade_mode = "Rolling"
health_probe_id = azurerm_lb_probe.test.id
rolling_upgrade_policy {
max_batch_instance_percent = %d
max_unhealthy_instance_percent = %d
max_unhealthy_upgraded_instance_percent = %d
pause_time_between_batches = "%s"
}
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
os_disk {
storage_account_type = "Standard_LRS"
caching = "ReadWrite"
}
network_interface {
name = "example"
primary = true
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.test.id
load_balancer_backend_address_pool_ids = [azurerm_lb_backend_address_pool.test.id]
primary = true
}
}
depends_on = [azurerm_lb_rule.test]
}
`, r.template(data), data.RandomInteger, max_batch_instance_percent, max_unhealthy_instance_percent, max_unhealthy_upgraded_instance_percent, pause_time_between_batches)
}

func (r LinuxVirtualMachineScaleSetResource) otherHealthProbe(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
locals {
frontend_ip_configuration_name = "internal"
}
resource "azurerm_public_ip" "test" {
name = "actestvmsspip-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
allocation_method = "Static"
}
resource "azurerm_lb" "test" {
name = "actestvmsslb-%[2]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
frontend_ip_configuration {
name = local.frontend_ip_configuration_name
public_ip_address_id = azurerm_public_ip.test.id
}
}
resource "azurerm_lb_backend_address_pool" "test" {
name = "backend"
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
}
resource "azurerm_lb_probe" "test" {
name = "ssh-running-probe"
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
port = 22
protocol = "Tcp"
}
resource "azurerm_lb_probe" "test2" {
name = "ssh-running-probe2"
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
port = 22
protocol = "Tcp"
}
resource "azurerm_lb_rule" "test" {
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
probe_id = azurerm_lb_probe.test.id
backend_address_pool_id = azurerm_lb_backend_address_pool.test.id
frontend_ip_configuration_name = local.frontend_ip_configuration_name
name = "LBRule"
protocol = "Tcp"
frontend_port = 22
backend_port = 22
}
resource "azurerm_linux_virtual_machine_scale_set" "test" {
name = "acctestvmss-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "Standard_F2"
instances = 3
admin_username = "adminuser"
admin_password = "P@ssword1234!"
disable_password_authentication = false
upgrade_mode = "Automatic"
health_probe_id = azurerm_lb_probe.test.id
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
os_disk {
storage_account_type = "Standard_LRS"
caching = "ReadWrite"
}
network_interface {
name = "example"
primary = true
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.test.id
load_balancer_backend_address_pool_ids = [azurerm_lb_backend_address_pool.test.id]
primary = true
}
}
depends_on = [azurerm_lb_rule.test]
}
`, r.template(data), data.RandomInteger)
}

func (r LinuxVirtualMachineScaleSetResource) otherHealthProbeUpdated(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
locals {
frontend_ip_configuration_name = "internal"
}
resource "azurerm_public_ip" "test" {
name = "actestvmsspip-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
allocation_method = "Static"
}
resource "azurerm_lb" "test" {
name = "actestvmsslb-%[2]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
frontend_ip_configuration {
name = local.frontend_ip_configuration_name
public_ip_address_id = azurerm_public_ip.test.id
}
}
resource "azurerm_lb_backend_address_pool" "test" {
name = "backend"
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
}
resource "azurerm_lb_probe" "test" {
name = "ssh-running-probe"
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
port = 22
protocol = "Tcp"
}
resource "azurerm_lb_probe" "test2" {
name = "ssh-running-probe2"
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
port = 22
protocol = "Tcp"
}
resource "azurerm_lb_rule" "test" {
resource_group_name = azurerm_resource_group.test.name
loadbalancer_id = azurerm_lb.test.id
probe_id = azurerm_lb_probe.test2.id
backend_address_pool_id = azurerm_lb_backend_address_pool.test.id
frontend_ip_configuration_name = local.frontend_ip_configuration_name
name = "LBRule"
protocol = "Tcp"
frontend_port = 22
backend_port = 22
}
resource "azurerm_linux_virtual_machine_scale_set" "test" {
name = "acctestvmss-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "Standard_F2"
instances = 3
admin_username = "adminuser"
admin_password = "P@ssword1234!"
disable_password_authentication = false
upgrade_mode = "Automatic"
health_probe_id = azurerm_lb_probe.test2.id
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
os_disk {
storage_account_type = "Standard_LRS"
caching = "ReadWrite"
}
network_interface {
name = "example"
primary = true
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.test.id
load_balancer_backend_address_pool_ids = [azurerm_lb_backend_address_pool.test.id]
primary = true
}
}
depends_on = [azurerm_lb_rule.test]
}
`, r.template(data), data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ func resourceLinuxVirtualMachineScaleSet() *schema.Resource {
"health_probe_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: azure.ValidateResourceID,
},

Expand Down
Loading

0 comments on commit d73de96

Please sign in to comment.