{"record":{"id":"8ee5c6ba59e2221e","repo":"kubernetes/kops","slug":"listing-virtual-networks-w","errorCode":null,"errorMessage":"listing virtual networks: %w","messagePattern":"listing virtual networks: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/azure/virtualnetwork.go","lineNumber":68,"sourceCode":"\t}\n\treturn &vnet.VirtualNetwork, err\n}\n\nfunc (c *virtualNetworksClientImpl) List(ctx context.Context, resourceGroupName string) ([]*network.VirtualNetwork, error) {\n\tif resourceGroupName == \"\" {\n\t\treturn nil, nil\n\t}\n\n\tvar l []*network.VirtualNetwork\n\tpager := c.c.NewListPager(resourceGroupName, nil)\n\tfor pager.More() {\n\t\tresp, err := pager.NextPage(ctx)\n\t\tif err != nil {\n\t\t\tvar respErr *azcore.ResponseError\n\t\t\tif errors.As(err, &respErr) && respErr.ErrorCode == \"ResourceGroupNotFound\" {\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"listing virtual networks: %w\", err)\n\t\t}\n\t\tl = append(l, resp.Value...)\n\t}\n\treturn l, nil\n}\n\nfunc (c *virtualNetworksClientImpl) Delete(ctx context.Context, resourceGroupName, vnetName string) error {\n\tfuture, err := c.c.BeginDelete(ctx, resourceGroupName, vnetName, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"deleting virtual network: %w\", err)\n\t}\n\tif _, err = future.PollUntilDone(ctx, nil); err != nil {\n\t\treturn fmt.Errorf(\"waiting for virtual network deletion completion: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc newVirtualNetworksClientImpl(subscriptionID string, cred *azidentity.DefaultAzureCredential) (*virtualNetworksClientImpl, error) {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/azure/virtualnetwork.go#L50-L86","documentation":"Wrapped when paging through virtual networks in a resource group fails, but only after the special case where the whole resource group does not exist (which returns nil, nil). Any other pager error — RBAC denial, throttling, network failure — is wrapped here. Callers of List treat this as a hard failure of inventory discovery.","triggerScenarios":"virtualNetworksClientImpl.List's pager.NextPage(ctx) returns a non-ResponseError error, or a ResponseError whose ErrorCode is anything other than ResourceGroupNotFound (e.g. AuthorizationFailed, TooManyRequests).","commonSituations":"Service principal lacks Microsoft.Network/virtualNetworks/read; ARM throttling (429) in a busy subscription; transient network errors; listing in a partially deleted resource group hitting other ARM errors.","solutions":["Grant the principal Reader/Network Contributor on the resource group","Retry with backoff if the wrapped error is a 429/throttle ResponseError","Confirm the resource group name matches the cluster spec (a missing group is silently tolerated, other errors are not)","Check connectivity to management.azure.com"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: verify permissions/read access before listing\n// (no local pre-check possible; grant Reader on the RG in advance)\naz role assignment create --assignee <principal> --role Reader --resource-group <rg>","typeGuard":"func isRetryableListError(err error) bool {\n    var respErr *azcore.ResponseError\n    return errors.As(err, &respErr) && respErr.StatusCode == http.StatusTooManyRequests\n}","tryCatchPattern":"vnets, err := vnetsClient.List(ctx, rg)\nif err != nil {\n    var respErr *azcore.ResponseError\n    if errors.As(err, &respErr) && respErr.StatusCode == http.StatusTooManyRequests {\n        // back off and retry per Retry-After header\n    }\n    return fmt.Errorf(\"cannot enumerate vnets (check RG name and RBAC): %w\", err)\n}","preventionTips":["Pre-grant Reader/Network Contributor on the resource group used by kops","Keep RG names in cluster spec consistent with Azure to avoid partial-deletion edge cases","Use ARM retry/backoff defaults to absorb 429s","Watch for RG deletion during verification"],"tags":["azure","go","network","vnet","list"],"backgroundTag":"azure-api-list-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}