{"record":{"id":"6d287682b2d7cea1","repo":"kubernetes/kops","slug":"creating-updating-vmss-w","errorCode":null,"errorMessage":"creating/updating VMSS: %w","messagePattern":"creating/updating VMSS: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/azure/vmscaleset.go","lineNumber":47,"sourceCode":"\n// VMScaleSetsClient is a client for managing VMSSs.\ntype VMScaleSetsClient interface {\n\tCreateOrUpdate(ctx context.Context, resourceGroupName, vmScaleSetName string, parameters compute.VirtualMachineScaleSet) (*compute.VirtualMachineScaleSet, error)\n\tList(ctx context.Context, resourceGroupName string) ([]*compute.VirtualMachineScaleSet, error)\n\tGet(ctx context.Context, resourceGroupName string, vmssName string) (*compute.VirtualMachineScaleSet, error)\n\tDelete(ctx context.Context, resourceGroupName, vmssName string) error\n}\n\ntype vmScaleSetsClientImpl struct {\n\tc *compute.VirtualMachineScaleSetsClient\n}\n\nvar _ VMScaleSetsClient = (*vmScaleSetsClientImpl)(nil)\n\nfunc (c *vmScaleSetsClientImpl) CreateOrUpdate(ctx context.Context, resourceGroupName, vmScaleSetName string, parameters compute.VirtualMachineScaleSet) (*compute.VirtualMachineScaleSet, error) {\n\tfuture, err := c.c.BeginCreateOrUpdate(ctx, resourceGroupName, vmScaleSetName, parameters, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"creating/updating VMSS: %w\", err)\n\t}\n\tresp, err := future.PollUntilDone(ctx, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"waiting for VMSS create/update: %w\", err)\n\t}\n\treturn &resp.VirtualMachineScaleSet, nil\n}\n\nfunc (c *vmScaleSetsClientImpl) List(ctx context.Context, resourceGroupName string) ([]*compute.VirtualMachineScaleSet, error) {\n\tif resourceGroupName == \"\" {\n\t\treturn nil, nil\n\t}\n\n\tvar l []*compute.VirtualMachineScaleSet\n\tpager := c.c.NewListPager(resourceGroupName, nil)\n\tfor pager.More() {\n\t\tresp, err := pager.NextPage(ctx)\n\t\tif err != nil {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/azure/vmscaleset.go#L29-L65","documentation":"Wrapped when the initial BeginCreateOrUpdate call to the VirtualMachineScaleSets client fails synchronously in vmScaleSetsClientImpl.CreateOrUpdate. The VMSS PUT never became a long-running future; the ARM error (invalid VMSS profile, RBAC, quota, image reference) is preserved via %w. Distinct from the later 'waiting for VMSS create/update' polling error.","triggerScenarios":"CreateOrUpdate calls c.c.BeginCreateOrUpdate(ctx, resourceGroupName, vmScaleSetName, parameters, nil) and the SDK errors immediately: malformed VirtualMachineScaleSet parameters (bad vmImage/instance type/SSH config), missing Microsoft.Compute/virtualMachineScaleSets/write permission, wrong resource group, or network failure.","commonSituations":"Invalid instance type or image reference in the kops instance group; spot/max-p price constraints invalid; subnet reference pointing to a not-yet-created vnet; RBAC-restricted service principal; ARM throttling on create.","solutions":["Read the wrapped azcore.ResponseError (StatusCode/ErrorCode) for the exact ARM rejection","Validate the VMSS parameters from the kops instance group spec: vmSize, image, subnet ID, SSH keys","Ensure the service principal has Contributor/Network Contributor + compute write on the resource group","Verify the referenced subnet/vnet exists before creating the VMSS"],"exampleFix":"// before: referencing subnet that does not exist yet\nIPConfigurations: []*compute.VirtualMachineScaleSetIPConfiguration{{ Subnet: &compute.APIEntityReference{ID: to.Ptr(badSubnetID)} }}\n// after: use the subnet created by the kops vnet task\nIPConfigurations: []*compute.VirtualMachineScaleSetIPConfiguration{{ Subnet: &compute.APIEntityReference{ID: to.Ptr(subnet.ID)} }}","handlingStrategy":"try-catch","validationCode":"// Go: pre-validate VMSS parameters before create/update\nif parameters.Location == nil || parameters.VirtualMachineProfile == nil || parameters.VirtualMachineProfile.StorageProfile == nil {\n    return fmt.Errorf(\"VMSS %s/%s missing location or VM profile\", resourceGroupName, vmScaleSetName)\n}\n// confirm the target subnet exists\nif _, err := subnetsClient.Get(ctx, rg, vnetName, subnetName, nil); err != nil {\n    return fmt.Errorf(\"subnet %s referenced by VMSS not found: %w\", subnetName, err)\n}","typeGuard":"func armQuotaOrCapacity(err error) bool {\n    var respErr *azcore.ResponseError\n    return errors.As(err, &respErr) && (respErr.StatusCode == http.StatusConflict || respErr.StatusCode == http.StatusTooManyRequests)\n}","tryCatchPattern":"vmss, err := vmssClient.CreateOrUpdate(ctx, rg, name, parameters)\nif err != nil {\n    var respErr *azcore.ResponseError\n    if errors.As(err, &respErr) {\n        if respErr.StatusCode == http.StatusForbidden {\n            return fmt.Errorf(\"grant compute write RBAC on %s: %w\", rg, err)\n        }\n        if respErr.StatusCode == http.StatusBadRequest {\n            return fmt.Errorf(\"invalid VMSS spec (vmSize/image/subnet): %w\", err)\n        }\n    }\n    return err\n}","preventionTips":["Validate instance type, image reference, and subnet ID in the instance group before apply","Ensure the vnet/subnet tasks complete before VMSS creation","Grant Contributor (compute + network write) to the kops principal","Watch for ARM 429s and respect Retry-After"],"tags":["azure","go","vmss","compute"],"backgroundTag":"azure-vmss-create-or-update-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}