kubernetes/kops · error
error waiting for router creation: %w
Error message
error waiting for router creation: %w
What it means
Returned by RenderGCE when the GCE operation object produced by Routers().Insert() completes with an error, as reported by t.Cloud.WaitForOp(op). The Insert call itself was accepted, but the long-running Google operation failed server-side, so the Cloud Router was not created. The wrapped error contains Google's operation error details.
Source
Thrown at upup/pkg/fi/cloudup/gcetasks/router.go:176
Name: *e.Name,
NatIpAllocateOption: *e.NATIPAllocationOption,
SourceSubnetworkIpRangesToNat: *e.SourceSubnetworkIPRangesToNAT,
},
},
}
for _, subnet := range e.Subnetworks {
router.Nats[0].Subnetworks = append(router.Nats[0].Subnetworks, &compute.RouterNatSubnetworkToNat{
Name: subnet.URL(project, region),
SourceIpRangesToNat: []string{subnetNatAllIPRanges},
})
}
op, err := t.Cloud.Compute().Routers().Insert(project, region, router)
if err != nil {
return fmt.Errorf("error creating Router: %w", err)
}
if err := t.Cloud.WaitForOp(op); err != nil {
return fmt.Errorf("error waiting for router creation: %w", err)
}
} else {
if !reflect.DeepEqual(changes, &Router{}) {
return fmt.Errorf("applying changes to Router is unsupported: %s", *e.Name)
}
}
return nil
}
type terraformRouterNat struct {
Name *string `cty:"name"`
Region *string `cty:"region"`
Router *terraformWriter.Literal `cty:"router"`
NATIPAllocateOption *string `cty:"nat_ip_allocate_option"`
SourceSubnetworkIPRangesToNat *string `cty:"source_subnetwork_ip_ranges_to_nat"`
Subnetworks []*terraformRouterNatSubnetwork `cty:"subnetwork"`
}View on GitHub (pinned to 4c8573c808)
Solutions
- Inspect the wrapped operation error for the specific Google failure reason (e.g. resource not found, already exists)
- Verify the VPC network and subnets referenced by the router exist in the target region before applying
- If name conflict, delete or rename the pre-existing router in the region (gcloud compute routers list)
- Re-run `kops update cluster` once the referenced resources have propagated — this is often transient
- Check Google Cloud status / regional incidents if the operation error is an internalError
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// Ensure referenced network exists before creating the router
_, err := compute.Networks.Get(projectID, networkName).Do()
if err != nil { return fmt.Errorf("network %s not found: %w", networkName, err) } Type guard
func isOpError(op *compute.Operation) bool {
return op != nil && op.Status == "DONE" && op.Error != nil
} Try / catch
if err := t.Cloud.WaitForOp(op); err != nil {
var ge *googleapi.Error
if errors.As(err, &ge) {
return fmt.Errorf("router creation op failed (%d): %w", ge.Code, err)
}
return fmt.Errorf("error waiting for router creation: %w", err)
} Prevention
- Wait for network/subnet creation to fully complete before the router task (respect task dependencies)
- Avoid manually editing Cloud Routers that kOps manages
- Watch operation error details via `gcloud compute operations describe`
- Check Google Cloud status page during regional incidents
When it happens
Trigger: Routers().Insert succeeds in enqueueing an operation, but WaitForOp polls it and finds status DONE with an error field — e.g. the referenced network/subnet doesn't exist, a router name conflict, or a Google-side failure while creating the router in the region.
Common situations: Network/subnet resources not fully propagated (created earlier in the same apply but eventually-consistent on Google's side); invalid network name in cluster spec; router name collides with a manually created router; regional capacity/API incidents.
Related errors
- error creating Router: %w
- applying changes to Router is unsupported: %s
- error listing routers: %v
- error deleting router %s: %v
- expected exactly one subnet with GCE IP Aliases
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/c9400e0a0cd9b7c5.
Report an issue: GitHub.