Bug 1797986

Summary: Calling 'commit_changes_async' libnm method of with a valid 'profile' object returns error 'Object is no longer in the client cache'
Product: Red Hat Enterprise Linux 8 Reporter: Fernando F. Mancera <ferferna>
Component: nmstateAssignee: Gris Ge <fge>
Status: CLOSED ERRATA QA Contact: Mingyu Shi <mshi>
Severity: high Docs Contact:
Priority: high    
Version: 8.3CC: acardace, atragler, bgalvani, ferferna, fge, jiji, jishi, lrintel, network-qe, rkhan, sukulkar, thaller, till
Target Milestone: rc   
Target Release: 8.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: nmstate-0.3.2-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 03:08:25 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:
Bug Depends On:    
Bug Blocks: 1738136    
Attachments:
Description Flags
Nmstate test log none

Description Fernando F. Mancera 2020-02-04 10:58:34 UTC
Description of problem:

This problem have been detected when running the nmstate wired integration tests against NM 1.22.6. The failure is at the callback function `commit_changes_finish`.

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

NetworkManager 1.22.6

Comment 1 Fernando F. Mancera 2020-02-04 11:07:09 UTC
Created attachment 1657529 [details]
Nmstate test log

We cannot reproduce it manually. I've attached the tests logs.

Comment 2 Beniamino Galvani 2020-02-06 09:00:15 UTC
I'm not very familiar with Python and nmstate code, but from what I
understand the problem seems to be in the test.

test_interface_mtu_change_with_modify() calls _modify_interface()
which does this:

    conn = nm.connection.ConnectionProfile()
    conn.import_by_id(ETH1)
    settings = _create_iface_settings(wired_state, conn)
    new_conn = nm.connection.ConnectionProfile()
    new_conn.create(settings)
    conn.update(new_conn)
    conn.commit(save_to_disk=False)

    nmdev = nm.device.get_device_by_name(ETH1)
    apply_operation(nmdev, conn.profile)

so, it enqueues the commit/reapply operations in the main loop and
returns. Since the function is decorated with @nmclient_context, the
NMClient gets destroyed as soon as the function returns; therefore
when commit() later is dequeued and executed, it fails because the
RemoteConnection object doesn't have an associated client.

I haven't investigated how this worked with NM 1.20, but this seems to
me a bug in the nmstate test implementation. Fernando, what do you
think?

Comment 3 Gris Ge 2020-03-13 04:42:25 UTC
Changed to nmstate

Comment 4 Fernando F. Mancera 2020-04-26 22:04:27 UTC
(In reply to Beniamino Galvani from comment #2)
> I'm not very familiar with Python and nmstate code, but from what I
> understand the problem seems to be in the test.
> 
> test_interface_mtu_change_with_modify() calls _modify_interface()
> which does this:
> 
>     conn = nm.connection.ConnectionProfile()
>     conn.import_by_id(ETH1)
>     settings = _create_iface_settings(wired_state, conn)
>     new_conn = nm.connection.ConnectionProfile()
>     new_conn.create(settings)
>     conn.update(new_conn)
>     conn.commit(save_to_disk=False)
> 
>     nmdev = nm.device.get_device_by_name(ETH1)
>     apply_operation(nmdev, conn.profile)
> 
> so, it enqueues the commit/reapply operations in the main loop and
> returns. Since the function is decorated with @nmclient_context, the
> NMClient gets destroyed as soon as the function returns; therefore
> when commit() later is dequeued and executed, it fails because the
> RemoteConnection object doesn't have an associated client.
> 
> I haven't investigated how this worked with NM 1.20, but this seems to
> me a bug in the nmstate test implementation. Fernando, what do you
> think?

I think you are right. This test could be changed soon as nmstate-0.3 will contain big changes on the Mainloop topic. I will re-check it then.

Comment 5 Gris Ge 2020-06-18 03:53:46 UTC
Not a issue any more as nmstate has changed the use of MainContext.


The new test case name is `test_interface_mtu_change` in case QE want to try it out.

Comment 6 Mingyu Shi 2020-07-21 02:54:14 UTC
Verified with versions:
nmstate-0.3.3-2.el8.noarch
NetworkManager-1.26.0-1.el8.x86_64
DISTRO=RHEL-8.3.0-20200716.n.0
Linux hp-dl388g8-04.rhts.eng.pek2.redhat.com 4.18.0-226.el8.x86_64 #1 SMP Wed Jul 15 07:40:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux


[10:52:09@hp-dl388g8-04 ~/nmstate/tests/integration/nm]0# pytest wired_test.py -vv
============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.6.8, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python3.6
cachedir: .pytest_cache
RPMs: NetworkManager-1.26.0-1.el8.x86_64
OS: Red Hat Enterprise Linux 8.3 Beta (Ootpa)
nmstate: nmstate-0.3.3-2.el8.noarch

rootdir: /root/nmstate, inifile: tox.ini
collected 2 items                                                                                                                                                                                                                            

wired_test.py::test_interface_mtu_change PASSED                                                                                                                                                                                        [ 50%]
wired_test.py::test_interface_mac_change_with_modify PASSED                                                                                                                                                                            [100%]

Comment 10 errata-xmlrpc 2020-11-04 03:08:25 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-2020:4696