Bug 2122522

Summary: nmstate API was broken by changing veth type
Product: Red Hat Enterprise Linux 9 Reporter: Petr Horáček <phoracek>
Component: nmstateAssignee: Gris Ge <fge>
Status: CLOSED ERRATA QA Contact: Mingyu Shi <mshi>
Severity: high Docs Contact:
Priority: high    
Version: 9.2CC: ferferna, jiji, jishi, network-qe, sfaye, till
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 07:31:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Horáček 2022-08-30 08:25:27 UTC
Description of problem:
In older versions of nmstate, veth interfaces were clearly marked as `type: veth`. With new versions they are `type: ethernet`. This violated API compatibility, all the existing code depending on veths being marked as "veth" is now broken. Furthermore, it forces us to filter veths by looking at the `veth` key in the yaml. In OpenShift, the difference between veths and physical NICs is crucial, and we need a simple way to distinguish them.

Version-Release number of selected component (if applicable):
rust-based nmstate

How reproducible:
Always

Steps to Reproduce:
1. ip link add va type veth peer name vb
2. nmstatectl show

Actual results:
Veth interfaces are listed with `type: ethernet`.

Expected results:
Veth interfaces are listed with `type: veth`.

Additional info:

Comment 1 Gris Ge 2022-09-02 12:06:18 UTC
Patch sent to upstream: https://github.com/nmstate/nmstate/pull/2025


reviously, in order to simplify the code workflow, we are showing both
eth and normal ethernet as `type: ethernet`. This has break kubernetes
se case where they need it to identify the veth interfaces.

hanged to show veth interface as `type: veth`. When its peer is in
nother network namespace, hide the `veth` section.

xpand the integration test cases to cover these use cases:

* `test_eth_with_veth_conf`
  Desire state is desiring ethernet interface with veth configuration.
  Raise InvalidArgument error (NmstateValueError exception in python)

* `test_add_veth_with_ethernet_peer`
  Desire state contains both veth and veth peer interface. But veth
  peer interface is set as `type: ethernet`.

* `test_add_veth_with_veth_peer_in_desire`
  Desire state contains both veth and veth peer interface. Both veth
  and peer interfaces are set as `type: veth` with `veth` configure
  pointing to each other.

* `test_modify_veth_peer`
  Change veth peer. The old peer should be removed.

* `test_veth_without_peer_fails`
  When adding new veth(not exist) without veth peer defined in veth
  configure, raise InvalidArgument error (NmstateValueError exception
  in python).

* `test_change_veth_with_veth_type_without_veth_conf`
  With pre-exist veth, changing other configure with `type: veth` and
  no veth configure.

* `test_change_veth_with_eth_type_without_veth_conf`
  With pre-exist veth, changing other configure with `type: ethernet` and
  no veth configure.

* `test_veth_with_ignored_peer`
  With pre-exist veth and its peer marked as ignored (unmanaged by NM).
  Applying desire state with `type: veth` and veth configuration should
  not fail. And the veth configuration should be ignored.

* `test_veth_with_ignored_peer_changed_to_new_peer`
  With pre-exist veth and its peer marked as ignored (unmanaged by NM).
  Nmstate will raise InvalidArgument error (NmstateValueError exception
  in python) when user try to change its peer. Also have unit test case
  for this.

Comment 6 Mingyu Shi 2022-11-21 07:12:57 UTC
Verified with:
nmstate-2.2.1-1.el9.x86_64
NetworkManager-1.41.4-2.el9.x86_64
Linux dell-per740-80.rhts.eng.pek2.redhat.com 5.14.0-197.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 16 14:31:27 EST 2022 x86_64 x86_64 x86_64 GNU/Linux
DISTRO=RHEL-9.2.0-20221118.4

Now veth created by:
1. ip link add veth type veth peer veth_p
or
2. nmstate YAML:
interfaces:
- name: veth
  type: veth
  state: up
  veth:
    peer: veth_p

are both shown as "type: veth" in "nmstatectl show" output(rust).


Here's a summary:
In the python version, the veth created with:
1. `ip-link` is shown as "type: ethernet",
2. nmstate/NetworkManager is shows as "type: veth"
You can apply a state with the "type" value as "veth" or "ethernet" to change the result shown in `nmstatectl show`

In the older rust version, any veth is shown as "type: ethernet"

In the current rust version, any veth is shown as "type: veth". when applying a new state, using "type: ethernet" on a veth works, but nmstate only output "type: veth" in `nmstatectl show`

In all nmstate versions(including the current one), when you apply:
interfaces:
- name: veth
  type: veth
  state: absent

If the veth was created by `ip-link`, nmstate only removes its NM connection and keep itself there
If the veth was created by nmstate/NetworkManager, nmstate removes its NM connection and delete the veth from kernel too

Comment 7 Mingyu Shi 2022-11-21 07:16:41 UTC
Hi Petr,

Could you please review the comment above(#comment6) to see if everything's OK in openshift usage?

Comment 8 Petr Horáček 2022-11-25 08:34:46 UTC
Hello, this is exactly what I was looking for. Thank a lot for putting the effort into making the API fitting needs of OpenShift, much appreciated!

Comment 10 errata-xmlrpc 2023-05-09 07:31:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (nmstate bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2190