Bug 2174857

Summary: nmstatectl service do not support "capture"
Product: Red Hat Enterprise Linux 9 Reporter: Quique Llorente <ellorent>
Component: nmstateAssignee: Gris Ge <fge>
Status: CLOSED ERRATA QA Contact: Mingyu Shi <mshi>
Severity: medium Docs Contact:
Priority: medium    
Version: 9.2CC: ferferna, jiji, jishi, network-qe, sfaye, till
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:24:02 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 Quique Llorente 2023-03-02 14:06:51 UTC
Description of problem:
When using nmstatectl service if the nmpolicy feature is using and the state specify "capture" and "desiredState" then the command fails with 

Mar 02 13:59:48 qemu0 kola-runext-test.sh[1762]: [2023-03-02T13:59:48Z ERROR nmstatectl::service] Failed to apply state file /etc/nmstate/br-ex-policy.yml: serde_yaml::Error: Unsupported keys found: ["capture", "desiredState"]


Version-Release number of selected component (if applicable): 2.2.5


How reproducible: Always


Steps to Reproduce:
1. Create file at /etc/nmstate/state.yml with the content
capture:                                                              
            default-gw-route: routes.running.destination=="0.0.0.0/0"           
            default-gw-iface: interfaces.name==capture.default-gw-route.routes.running.0.next-hop-interface
          desiredState:                                                         
           interfaces:                                                          
            - name: "{{ capture.default-gw-iface.interfaces.0.name }}"          
              description: configured by nmstatectl                             
              type: ethernet                                                    
              state: up                                                         
            - name: br-ex                                                       
              type: linux-bridge                                                
              copy-mac-from: "{{ capture.default-gw-iface.interfaces.0.name }}" 
              state: up                                                         
              ipv4:                                                             
                enabled: true                                                   
                dhcp: true                                                      
              ipv6:                                                             
                enabled: true                                                   
                dhcp: true                                                      
                autoconf: true                                                  
              bridge:                                                           
                port:                                                           
                - name: "{{ capture.default-gw-iface.interfaces.0.name }}"      
2. Run nmstatectl service
3.

Actual results:
Mar 02 13:59:48 qemu0 kola-runext-test.sh[1762]: [2023-03-02T13:59:48Z ERROR nmstatectl::service] Failed to apply state file /etc/nmstate/br-ex-policy.yml: serde_yaml::Error: Unsupported keys found: ["capture", "desiredState"]


Expected results:
Apply the state as expected

Additional info:
We need this at RHEL 9.2 to have RHCOS configure networking with nmstate.service using nmpolicy

Comment 2 Gris Ge 2023-03-06 08:44:11 UTC
Patch posted to upstream: https://github.com/nmstate/nmstate/pull/2264

To test this:
 * Create dummy interface with iproute or nmstate.
 * Store below content as /etc/nmstate/remove_dummy_iface.yml

```yml
capture:
  dummy_iface: interfaces.type == "dummy"
desired:
  interfaces:
  - name: "{{ capture.dummy_iface.interfaces.0.name }}"
    state: absent
```

 * The dummy interface should be removed after `systemctl start nmstate`.

Comment 6 Mingyu Shi 2023-04-24 10:23:15 UTC
Verified with:
nmstate-2.2.9-1.el9.x86_64
nispor-1.2.10-1.el9.x86_64
NetworkManager-1.43.6-1.el9.x86_64
DISTRO=RHEL-9.3.0-20230423.30

Comment 8 errata-xmlrpc 2023-11-07 08:24:02 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:6323