question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: Updating a VMSS with new capacity leads to outdated VM models

See original GitHub issue

Describe the bug When updating the scaling capacity of a Virtual Machine Scale Set via Azure Java SDK such as

vmss.update()
           .withCapacity(newCapacity)
           .apply();

the other existing VMs of the VMSS are then somehow outdated and the UI shows they do not have the latest VMSS model applied.

vmss_capacity_update2

When however changing the scaling capacity via the UI the VMs of the VMSS still have the latest VMSS model applied.

vmss_capacity_update1

Exception or Stack Trace There are no errors, it simply seems to be a mismatch in behavior between the API and the SDK

To Reproduce Steps to reproduce the behavior:

Code Snippet see above

Expected behavior I would suggest that simply changing the scaling count should not affect the VMSS model of the VMs itself

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: [Windows]
  • IDE: [IntelliJ]
  • Library/Libraries: [e.g. com.azure:azure-resourcemanager:2.20.0]
  • Java version: [LibericaJDK-16]
  • Frameworks: [Quarkus]

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [x ] Bug Description Added
  • [x ] Repro Steps Added
  • [x ] Setup information Added

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
XiaofeiCaocommented, Nov 24, 2022

Thanks @hendrik-schaffer for your detailed explanation of your situation. I’ll check if the patch pattern can resolve the altering of the latest model state.

@weidongxu-microsoft This may be an issue we want to fix. When the vmss’s UpgradePolicy is set to Automatic, all existing VMs in the vmss is likely to be rebooted if the Latest Model is No. I’ll have that checked too.

1reaction
hendrik-schaffercommented, Nov 28, 2022

Sure. Please find below the JSON View of our VMSS

{
    "name": "enterpriserunner-vmss-ubuntu-server-int",
    "id": "/subscriptions/SUBSCRIPTION-ID/resourceGroups/RG_REDACTED/providers/Microsoft.Compute/virtualMachineScaleSets/enterpriserunner-vmss-ubuntu-server-int",
    "type": "Microsoft.Compute/virtualMachineScaleSets",
    "location": "westeurope",
    "tags": {
        "createdBy": "Jenkins"
    },
    "identity": {
        "type": "UserAssigned",
        "userAssignedIdentities": {
            "/subscriptions/SUBSCRIPTION-ID/resourceGroups/RG_REDACTED/providers/Microsoft.ManagedIdentity/userAssignedIdentities/githubrunnervms-mi-int": {
                "principalId": "REDACTED",
                "clientId": "REDACTED"
            }
        }
    },
    "sku": {
        "name": "Standard_DS2_v2",
        "tier": "Standard",
        "capacity": 3
    },
    "properties": {
        "singlePlacementGroup": true,
        "orchestrationMode": "Uniform",
        "upgradePolicy": {
            "mode": "Manual",
            "rollingUpgradePolicy": {
                "maxBatchInstancePercent": 20,
                "maxUnhealthyInstancePercent": 20,
                "maxUnhealthyUpgradedInstancePercent": 20,
                "pauseTimeBetweenBatches": "PT0S"
            }
        },
        "virtualMachineProfile": {
            "osProfile": {
                "computerNamePrefix": "atcrun",
                "adminUsername": "cloud",
                "linuxConfiguration": {
                    "disablePasswordAuthentication": true,
                    "ssh": {
                        "publicKeys": [
                            {
                                "path": "/home/cloud/.ssh/authorized_keys",
                                "keyData": "ssh-rsa SSH_KEY_REDACCTED"
                            }
                        ]
                    },
                    "provisionVMAgent": true
                },
                "secrets": [],
                "allowExtensionOperations": true,
                "requireGuestProvisionSignal": true
            },
            "storageProfile": {
                "osDisk": {
                    "osType": "Linux",
                    "diffDiskSettings": {
                        "option": "Local",
                        "placement": "CacheDisk"
                    },
                    "createOption": "FromImage",
                    "caching": "ReadOnly",
                    "managedDisk": {
                        "storageAccountType": "Standard_LRS"
                    },
                    "diskSizeGB": 30
                },
                "imageReference": {
                    "id": "/subscriptions/SUBSCRIPTION-ID/resourceGroups/RG_REDACTED/providers/Microsoft.Compute/galleries/atc_images_int/images/enterpriserunner-ubuntu-20.04-gen2-int/versions/3.6.1"
                }
            },
            "networkProfile": {
                "networkInterfaceConfigurations": [
                    {
                        "name": "entercfecNic",
                        "properties": {
                            "primary": true,
                            "enableAcceleratedNetworking": false,
                            "disableTcpStateTracking": false,
                            "dnsSettings": {
                                "dnsServers": []
                            },
                            "enableIPForwarding": false,
                            "ipConfigurations": [
                                {
                                    "name": "entercfecIPConfig",
                                    "properties": {
                                        "subnet": {
                                            "id": "/subscriptions/SUBSCRIPTION-ID/resourceGroups/RG_REDACTED/providers/Microsoft.Network/virtualNetworks/VNET-SPOKE-AMS-0221/subnets/Subnet-1"
                                        },
                                        "privateIPAddressVersion": "IPv4"
                                    }
                                }
                            ]
                        }
                    }
                ]
            },
            "extensionProfile": {
                "extensions": [
                    {
                        "name": "CustomScript",
                        "properties": {
                            "autoUpgradeMinorVersion": true,
                            "publisher": "Microsoft.Azure.Extensions",
                            "type": "CustomScript",
                            "typeHandlerVersion": "2.1"
                        }
                    }
                ]
            }
        },
        "provisioningState": "Succeeded",
        "overprovision": false,
        "doNotRunExtensionsOnOverprovisionedVMs": false,
        "uniqueId": "9af6d670-2987-479e-9c0a-7375d77aa313"
    }
}

To update the VMSS via the SDK, we are using the following code snippet:


public VirtualMachineScaleSet getLinuxEnterpriseRunnerVMSS() {
        return getAzureResourceManager().virtualMachineScaleSets()
                .getByResourceGroup(resourceGroup, linuxEnterpriseRunnerVMSSName);
}

protected void scaleUpLinuxRunnerVMSS(VirtualMachineScaleSet vmss) {
        
        // calculate new instance count 
        // [....] 
        vmss.update()
                .withCapacity(newVmInstanceCount)
                .apply();

        LOG.info("Scaled up VMSS {} to {} instances.", vmss.name(), newVmInstanceCount);
}

@Test
void scaleUpLinuxVMSS() {
        VirtualMachineScaleSet targetVMSS = githubRunnerService.getLinuxEnterpriseRunnerVMSS();
        githubRunnerService.scaleUpLinuxRunnerVMSS(targetVMSS);
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

FAQ for Azure Virtual Machine Scale Sets - Microsoft Learn
If you increase capacity to 18, then 3 new VMs are created. Each time, the VM instance ID is incremented from the previous...
Read more >
VMSS + latestModelApplied · Issue #62 · Azure/vm-scale-sets
"Upgrading" from the portal means apply the latest VMSS model to the VM. ... when latest is set and you scale out (increase...
Read more >
New ways to manage Azure VMs using Virtual Machine Scale ...
See, in action, the latest capabilities that Azure Virtual Machines Scale Sets provides. Discover how Azure Virtual Machine Scale Sets can ...
Read more >
Upgrade or update BIG-IP VE instances in an Azure VMSS (F5 ...
The deployment uses the VMSS upgrade policy to replace your old BIG-IP instances with new ones running the BIG-IP version you are upgrading...
Read more >
Updating Azure VM Scale Set without downtime with Rolling ...
This article will explain how you configure your VM Scale Set (or just VMSS for brevity) and the peripheral components required for this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found