kubernetes/kops · error

unexpected number of nats found: %+v

Error message

unexpected number of nats found: %+v

What it means

Validation error from Router.Find when the fetched router's NAT list does not contain exactly one entry. kOps models exactly one Cloud NAT config per router, so zero or multiple NATs (e.g. manually added ones) make the state unmanageable; the full NAT list is printed.

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/router.go:80

// CompareWithID returns the name of the Router.
func (r *Router) CompareWithID() *string {
	return r.Name
}

// Find discovers the Router in the cloud provider.
func (r *Router) Find(c *fi.CloudupContext) (*Router, error) {
	cloud := c.T.Cloud.(gce.GCECloud)

	found, err := cloud.Compute().Routers().Get(cloud.Project(), *r.Region, *r.Name)
	if err != nil {
		if gce.IsNotFound(err) {
			return nil, nil
		}
		return nil, fmt.Errorf("error listing Routers: %w", err)
	}

	if len(found.Nats) != 1 {
		return nil, fmt.Errorf("unexpected number of nats found: %+v", found.Nats)
	}
	nat := found.Nats[0]

	if a, e := found.SelfLink, r.url(cloud.Project()); a != e {
		klog.Warningf("SelfLink did not match URL: %q vs %q", a, e)
	}

	actual := &Router{
		Name:                          &found.Name,
		Lifecycle:                     r.Lifecycle,
		Network:                       &Network{Name: new(lastComponent(found.Network))},
		Region:                        new(lastComponent(found.Region)),
		NATIPAllocationOption:         &nat.NatIpAllocateOption,
		SourceSubnetworkIPRangesToNAT: &nat.SourceSubnetworkIpRangesToNat,
	}

	for _, subnet := range nat.Subnetworks {
		if strings.Join(subnet.SourceIpRangesToNat, ",") != subnetNatAllIPRanges {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the printed NAT list and remove extra manually-created NATs from the router (or let kOps own it exclusively)
  2. If no NAT exists, ensure the router task creates one by re-running apply from a clean state
  3. Avoid mixing manual gcloud NAT edits with kOps-managed routers
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/router.go:80 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/dca36a5af511cd19. Report an issue: GitHub.