kubernetes/kops · error

Error creating router interface: %v

Error message

Error creating router interface: %v

What it means

Raised in RenderOpenstack (routerinterface.go:131) when the Neutron add-router-interface API (Cloud.CreateRouterInterface) returns an error while attaching a subnet to the router. The gophercloud error is wrapped verbatim, so the underlying conflict or validation failure is in the inner message.

Source

Thrown at upup/pkg/fi/cloudup/openstacktasks/routerinterface.go:131

			return fi.CannotChangeField("Router")
		}
		if changes.Subnet != nil {
			return fi.CannotChangeField("Subnet")
		}
	}
	return nil
}

func (_ *RouterInterface) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *RouterInterface) error {
	if a == nil {
		routerID := fi.ValueOf(e.Router.ID)
		subnetID := fi.ValueOf(e.Subnet.ID)
		klog.V(2).Infof("Creating RouterInterface for router:%s and subnet:%s", routerID, subnetID)

		opt := routers.AddInterfaceOpts{SubnetID: subnetID}
		v, err := t.Cloud.CreateRouterInterface(routerID, opt)
		if err != nil {
			return fmt.Errorf("Error creating router interface: %v", err)
		}

		e.ID = new(v.PortID)
		klog.V(2).Infof("Creating a new Openstack router interface, id=%s", v.PortID)
		return nil
	}
	e.ID = a.ID
	klog.V(2).Infof("Using an existing Openstack router interface, id=%s", fi.ValueOf(e.ID))
	return nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the wrapped inner error; a 409 usually means overlapping subnets on the router — check `openstack subnet list` for CIDR overlap
  2. Verify the router ID exists in the current project: `openstack router show <router-id>`
  3. Check port quota: `openstack quota show` (ports) and delete stale ports
  4. Re-run `kops update cluster` after fixing; if state is corrupted, detach stale interfaces first

Example fix

// before
ERROR: Error creating router interface: Conflict: Multiple subnets with overlapping CIDR
// after
$ openstack subnet set --no-allocation-pool ...   # or fix cluster spec so subnets don't overlap
$ kops update cluster <name> --yes
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check for overlapping subnets on the router
subs, _ := subnets.List(netClient, subnets.ListOpts{NetworkID: netID}).AllPages()
for _, s := range subs { for _, o := range subs { if s.ID != o.ID && cidrOverlaps(s.CIDR, o.CIDR) { return fmt.Errorf("subnets %s and %s overlap", s.ID, o.ID) } } }

Type guard

func isConflict(err error) bool {
    var gerr gophercloud.ErrUnexpectedResponseCode
    return errors.As(err, &gerr) && gerr.Actual == http.StatusConflict
}

Try / catch

if err := kopsUpdate(); err != nil {
    if isConflict(err) {
        log.Fatal("router interface conflict (likely overlapping subnets) — check `openstack subnet list` CIDRs")
    }
    return err
}

Prevention

When it happens

Trigger: routers.AddInterfaceOpts{SubnetID} is submitted for a router that cannot accept the interface: 409 Conflict because the subnet's IP range overlaps another interface's subnet on the same router, the router or subnet doesn't exist (404), the port creation inside Neutron fails, or the subnet already has an interface attached.

Common situations: Two private subnets with overlapping CIDRs attached to one router (Neutron rejects overlap), the Router task's ID is stale/invalid from a failed earlier run, network MTU/port-quota issues preventing the internal port creation, or applying against the wrong project where the router/subnet IDs don't resolve.

Related errors


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