{"record":{"id":"057560e2e123f4d8","repo":"kubernetes/kops","slug":"error-waiting-for-subnet-patch-to-complete-w","errorCode":null,"errorMessage":"error waiting for Subnet patch to complete: %w","messagePattern":"error waiting for Subnet patch to complete: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/subnet.go","lineNumber":246,"sourceCode":"\t\t\treturn nil\n\t\t}\n\n\t\tsubnet.SecondaryIpRanges = nil\n\t\tfor k, v := range expectedRanges {\n\t\t\tsubnet.SecondaryIpRanges = append(subnet.SecondaryIpRanges, &compute.SubnetworkSecondaryRange{\n\t\t\t\tRangeName:   k,\n\t\t\t\tIpCidrRange: v,\n\t\t\t})\n\t\t}\n\t}\n\n\tpatchOp, err := cloud.Compute().Subnetworks().Patch(cloud.Project(), cloud.Region(), subnet.Name, subnet)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error patching Subnet: %w\", err)\n\t}\n\n\tif err := cloud.WaitForOp(patchOp); err != nil {\n\t\treturn fmt.Errorf(\"error waiting for Subnet patch to complete: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc updateStackTypeAndIPv6AccessType(cloud gce.GCECloud, e *Subnet) error {\n\t// We need to refetch to patch it\n\tsubnet, err := cloud.Compute().Subnetworks().Get(cloud.Project(), cloud.Region(), *e.Name)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error fetching subnet for patch: %w\", err)\n\t}\n\n\tsubnet.StackType = fi.ValueOf(e.StackType)\n\tsubnet.Ipv6AccessType = fi.ValueOf(e.Ipv6AccessType)\n\n\tpatchOp, err := cloud.Compute().Subnetworks().Patch(cloud.Project(), cloud.Region(), subnet.Name, subnet)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error patching Subnet: %w\", err)","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/subnet.go#L228-L264","documentation":"This error wraps the failure returned by GCE's WaitForOp while polling the operation produced by Subnetworks().Patch on a subnet. kOps patches the subnet (e.g. to update secondary ranges) and then waits for the long-running GCE operation to finish; if that wait fails or the operation ends in an error state, this error is returned. The underlying GCE error is preserved via %w.","triggerScenarios":"updateSecondaryRanges calls Compute().Subnetworks().Patch(project, region, subnet.Name, subnet) and then cloud.WaitForOp(patchOp); the wait fails because the GCE patch operation completed with an error (e.g. quota, invalid secondary range config) or the polling API call itself errored.","commonSituations":"Changing subnet secondary CIDR ranges to values that conflict with existing ranges or exceed GCP limits; subnets already in use by instances/routers preventing modification; transient GCP API outages during `kops update cluster`; project-level quota exhaustion.","solutions":["Inspect the wrapped %w cause (run with -v=10) to see the GCE operation error detail","Verify the new secondary range CIDRs don't overlap existing ranges or fall outside allowed allocations in the GCP console","Check the subnet is not in use (VMs, forwarding rules, routers) before changing ranges","Retry `kops update cluster` after resolving the GCP-side issue; transient API failures often resolve","Verify project quota and region capacity for IP ranges"],"exampleFix":"// before (kops side, diagnostic)\nreturn fmt.Errorf(\"error waiting for Subnet patch to complete: %w\", err)\n// after\nreturn fmt.Errorf(\"error waiting for Subnet patch to complete (check GCE operation logs for subnet %s): %w\", subnet.Name, err)","handlingStrategy":"retry","validationCode":"gcloud compute networks subnets describe <subnet> --region <region> --format='value(secondaryIpRanges)'","typeGuard":null,"tryCatchPattern":"var waitErr *GceOperationError\nif errors.As(err, &waitErr) { /* inspect waitErr.Operation for GCE detail before retrying */ }","preventionTips":["Pre-validate secondary range CIDRs for overlap before applying","Run kops update with --dry-run first and review subnet changes","Check GCE operation logs in Cloud Console after failed applies"],"tags":["gcp","gce","subnet","infrastructure"],"backgroundTag":"gce-operation-wait-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"}