nmstate / kubernetes-nmstate

Declarative node network configuration driven through Kubernetes API.
GNU General Public License v2.0
181 stars 89 forks source link

Cannot configure route when ipv4.enabled == false #1231

Open fbecker opened 6 months ago

fbecker commented 6 months ago

What happened: Static route configuration fails when configuring next-hop-interface to an interface where ip is disabled.

I'm getting the following error from nnce:

NmstateError: InvalidArgument: The next hop interface of desired Route 'destination: 192.168.150.0/24 next-hop-interface: ens224' has been marked as IPv4 disabled

What you expected to happen: To be able to add a route without a next-hop-interface or configured IP address. Just like

ip route add 192.168.150.0/24 dev ens224

How to reproduce it (as minimally and precisely as possible):

spec:
  desiredState:
    interfaces:
    - name: ens224
      state: up
      type: ethernet
    routes:
      config:
      - destination: 192.168.150.0/24
        next-hop-interface: ens224
qinqon commented 4 months ago

@cathay4t do you know if we have an issue at nmstate for this ?

cathay4t commented 4 months ago

As the message indicate, you cannot have route on disabled IP stack.

You have to enable IP stack even without address mentioned.

---
routes:
  config:
  - destination: 198.51.100.0/24
    metric: 150
    next-hop-interface: eth1
    table-id: 254
interfaces:
  - name: eth1
    type: ethernet
    state: up
    ipv4:
      enabled: true
cathay4t commented 4 months ago

On second thought, nmstate should support YAML provided by @fbecker , let generate a patch for it.

https://github.com/nmstate/kubernetes-nmstate/issues/1231#issuecomment-2121944023 could be used as workaround.

cathay4t commented 4 months ago

I have PR https://github.com/nmstate/nmstate/pull/2677 created to support:

---
routes:
  config:
  - destination: 198.51.100.0/24
    metric: 150
    next-hop-interface: eth1
    table-id: 254
interfaces:
  - name: eth1
    type: ethernet
    state: up
    ipv4:
      enabled: true
      address: []

But routes on disabled IP is still invalid use case.