{"record":{"id":"2179af7af3119cfc","repo":"kubernetes/kops","slug":"error-resizing-instancegroupmanager-v","errorCode":null,"errorMessage":"error resizing InstanceGroupManager: %v","messagePattern":"error resizing InstanceGroupManager: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go","lineNumber":170,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error updating InstanceTemplate for InstanceGroupManager: %v\", err)\n\t\t\t}\n\n\t\t\tif err := t.Cloud.WaitForOp(op); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error updating InstanceTemplate for InstanceGroupManager: %v\", err)\n\t\t\t}\n\n\t\t\tchanges.InstanceTemplate = nil\n\t\t}\n\n\t\tif changes.TargetSize != nil {\n\t\t\tnewSize := int64(0)\n\t\t\tif i.TargetSize != 0 {\n\t\t\t\tnewSize = int64(i.TargetSize)\n\t\t\t}\n\t\t\top, err := t.Cloud.Compute().InstanceGroupManagers().Resize(t.Cloud.Project(), *e.Zone, i.Name, newSize)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error resizing InstanceGroupManager: %v\", err)\n\t\t\t}\n\n\t\t\tif err := t.Cloud.WaitForOp(op); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error resizing InstanceGroupManager: %v\", err)\n\t\t\t}\n\n\t\t\tchanges.TargetSize = nil\n\t\t}\n\n\t\tempty := &InstanceGroupManager{}\n\t\tif !reflect.DeepEqual(empty, changes) {\n\t\t\treturn fmt.Errorf(\"cannot apply changes to InstanceGroupManager: %v\", changes)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go#L152-L188","documentation":"kOps wraps a failure from the GCE Compute API Resize call on an existing InstanceGroupManager when the desired TargetSize differs from the live one. The wrapped %v value is the underlying Google API error. newSize falls back to 0 when the spec's TargetSize is 0, which itself can trigger an API validation error if the MIG cannot shrink that far.","triggerScenarios":"1) Resize returns an API error: quota exceeded for the new (larger) size, MIG busy with another operation (e.g. the SetInstanceTemplate op just before it), invalid target size. 2) Resize succeeds but Cloud.WaitForOp(op) fails while instances are being added/removed (creation failure, quota).","commonSituations":"Scaling a node ASG/MIG above remaining regional CPU quota; shrinking to 0 while instances are in a failed state; autoscaler or another kOps run concurrently resizing the group.","solutions":["Read the wrapped error detail with -v=10 logging to identify the concrete API/operation failure.","Check and raise GCE quota (CPUs, in-use IPs) for the region if growing: `gcloud compute project-info describe`.","Retry `kops update cluster` once any in-flight MIG operation completes.","If shrinking, verify no pinned/standby instances block removal; resize in smaller steps if needed."],"exampleFix":"// before: TargetSize above regional quota\n//   kops set cluster spec.nodes.maxSize=100  # exceeds 48-CPU quota\n// after\n//   kops set cluster spec.nodes.maxSize=24\n//   kops update cluster <name> --yes","handlingStrategy":"validation","validationCode":"// Ensure requested size fits within regional quota before resizing\nquota := getRegionalQuota(project, region, \"CPUS\")\nprojected := currentCores + int64(newTargetSize-desiredCurrent)*coresPerInstance\nif projected > quota.Limit {\n    return fmt.Errorf(\"resize to %d needs %d cores but quota is %d\", newTargetSize, projected, quota.Limit)\n}","typeGuard":"func isQuotaExceeded(err error) bool {\n    var apiErr *googleapi.Error\n    if errors.As(err, &apiErr) && apiErr.Code == 403 {\n        return strings.Contains(apiErr.Message, \"Quota\")\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Check GCE regional quota before scale-ups","Clamp maxSize/minSize in the cluster spec to quota-safe values","Avoid concurrent autoscaler and kOps resizing of the same MIG","Resize in incremental steps for large jumps"],"tags":["gce","resize","instance-group-manager","google-compute-api"],"backgroundTag":"gce-operation-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"}