Ticket #6248 (assigned defect)

Opened 6 years ago

Last modified 6 years ago

Presence service broken with NetworkManager-0.7 (NM D-Bus API change)

Reported by: marco Owned by: morgs
Priority: high Milestone: 9.1.0-cancelled
Component: presence-service Version: olpc-3
Keywords: 8.2.0:- 9.1.0:? r+ Cc: dcbw, mstone, mbletsas, morgs, bjordan, gregorio, mikus@…, Collabora, erikos
Action Needed: package Verified: no
Deployments affected: Blocked By:
Blocking:

Description

I'm testing with 0.7.0. No buddies on the mesh view and no telepathy-gabble.log is created.

The presence service log shows that the getDevices call is failing (the method has been renamed to GetDevices apparently). It looks like the network manager Dbus interface changed quite a bit, because getProperties is not working anymore either.

As a quick workaround:

diff --git a/src/psutils.py b/src/psutils.py
index 6b8ec95..ae705f4 100644
--- a/src/psutils.py
+++ b/src/psutils.py
@@ -154,9 +154,8 @@ class IP4AddressMonitor(gobject.GObject):
 
         sys_bus = dbus.SystemBus()
         self._watch = sys_bus.watch_name_owner(NM_SERVICE, self._nm_owner_cb)
-        if not sys_bus.name_has_owner(NM_SERVICE):
-            addr = self._get_address_fallback()
-            self._update_address(addr)
+        addr = self._get_address_fallback()
+        self._update_address(addr)
 
     def do_get_property(self, pspec):
         if pspec.name == "address":

Interesting comment in the code:

class IP4AddressMonitor(gobject.GObject):
    """This class, and direct buddy IPv4 address access, will go away quite soon"""

Attachments

0001--6248-Port-NetworkManager-watcher-code-to-NM-0.7-s.patch (9.2 kB) - added by morgs 6 years ago.
Patch to PS for NM 0.7 API
0001--6248-Port-NetworkManager-watcher-code-to-NM-0.7-s.2.patch (9.6 kB) - added by morgs 6 years ago.
Updated patch
0001--6248-Port-NetworkManager-watcher-code-to-NM-0.7-s.3.patch (9.7 kB) - added by erikos 6 years ago.
incorporated morgan's fallback for NM 0.6 and fixed the inet_ntoa call

Change History

  Changed 6 years ago by marco

I made this high priority because it breaks jhbuild on recent distributions.

  Changed 6 years ago by dcbw

The D-Bus API for NM has changed quite a bit; but it's easier to understand. Take a look at

http://svn.gnome.org/viewvc/NetworkManager/trunk/introspection/

you get a nice overview of the D-Bus API. The process for finding the current IP address is basically:

1) Use the D-Bus properties interface to get the "State" property of org.freedesktop.NetworkManager 2) If that state is 3 (NM_STATE_CONNECTED) then: 3) Call GetActiveConnections() on org.freedesktop.NetworkManager. This returns an array of structs as documented in the introspection XML. 4) For each active connection returned, look through the array of devices that belong to that connection 5) For the first active device object path, use the D-Bus properties interface to get the "Ip4Address" property of the device

Just repeat the process when the NM state changes.

  Changed 6 years ago by morgs

  • cc mstone, morgs added

  Changed 6 years ago by morgs

  • version set to olpc-3

  Changed 6 years ago by dsd

  • summary changed from Presence service is broken with recent NetworkManager to Presence service broken with NetworkManager-0.7 (NM D-Bus API change)

  Changed 6 years ago by marco

  • keywords 8.2.0:? added

  Changed 6 years ago by mstone

  • cc mbletsas, bjordan, sjoerd added
  • keywords 8.2.0:- 9.1.0:? added; 8.2.0:? removed
  • next_action set to code
  • milestone changed from 8.2.0 (was Update.2) to 9.1.0

We'd really really love to see a fix here because it would help Fedora people test our collaboration and because it takes us closer to shipping NM 0.7 (which is necessary for all sorts of reasons); however, we _can_ punt this for into 9.1.0 so we're going to do so. Please volunteer!

  Changed 6 years ago by mstone

  • cc gregorio added

  Changed 6 years ago by mikus

  • cc mikus@… added

follow-up: ↓ 11   Changed 6 years ago by morgs

  • cc Collabora, erikos added; sjoerd removed

An issue with the above workaround: If there is an interface up without an IP address - e.g. a wired interface with the cable unplugged - you get the following failure in presenceservice, from https://bugs.launchpad.net/ubuntu/+source/sugar/+bug/297329:

1226636414.386559 INFO s-p-s: Starting presence service...
Traceback (most recent call last):
  File "/usr/bin/sugar-presence-service", line 24, in <module>
    main.main()
  File "/usr/share/sugar-presence-service/main.py", line 63, in main
    presenceservice.main(test_num, randomize)
  File "/usr/share/sugar-presence-service/presenceservice.py", line 873, in main
    ps = PresenceService()
  File "/usr/share/sugar-presence-service/presenceservice.py", line 88, in __init__
    self._owner = self._create_owner()
  File "/usr/share/sugar-presence-service/presenceservice.py", line 57, in _create_owner
    return ShellOwner(self, self._session_bus)
  File "/usr/share/sugar-presence-service/buddy.py", line 970, in __init__
    key_hash=key_hash)
  File "/usr/share/sugar-presence-service/buddy.py", line 667, in __init__
    self._ip4_addr_monitor = psutils.IP4AddressMonitor.get_instance()
  File "/usr/share/sugar-presence-service/psutils.py", line 143, in get_instance
    _ip4am = IP4AddressMonitor()
  File "/usr/share/sugar-presence-service/psutils.py", line 159, in __init__
    addr, iface = self._get_address_fallback()
  File "/usr/share/sugar-presence-service/psutils.py", line 293, in _get_address_fallback
    return self._get_iface_address(iface)
  File "/usr/share/sugar-presence-service/psutils.py", line 280, in _get_iface_address
    addr = fcntl.ioctl(fd, SIOCGIFADDR, struct.pack('256s', iface[:15]))[20:24]
IOError: [Errno 99] Cannot assign requested address

This then causes Sugar to fail to start, with:

1226490893.407684 ERROR dbus.proxies: Introspect error on org.laptop.Sugar.Presence:/org/laptop/Sugar/Presence: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.Spawn.ChildExited: Launch helper exited with unknown return code 1
1226490893.946251 WARNING sugar.presence.presenceservice: Unable to retrieve local user/owner
                   from presence service: org.freedesktop.DBus.Error.Spawn.ChildExited: Launch helper exited with unknown return code 1
Traceback (most recent call last):
  File "/usr/bin/sugar-shell", line 32, in <module>
    main()
  File "/usr/share/sugar/shell/main.py", line 153, in main
    view.Shell.get_instance()
  File "/usr/share/sugar/shell/view/Shell.py", line 259, in get_instance
    _instance = Shell()
  File "/usr/share/sugar/shell/view/Shell.py", line 55, in __init__
    self._model = shellmodel.get_instance()
  File "/usr/share/sugar/shell/model/shellmodel.py", line 102, in get_instance
    _instance = ShellModel()
  File "/usr/share/sugar/shell/model/shellmodel.py", line 48, in __init__
    self._owner = ShellOwner()
  File "/usr/share/sugar/shell/model/Owner.py", line 76, in __init__
    self._invites = Invites()
  File "/usr/share/sugar/shell/model/Invites.py", line 78, in __init__
    owner = ps.get_owner()
  File "/usr/lib/python2.5/site-packages/sugar/presence/presenceservice.py", line 452, in get_owner
    raise RuntimeError("Could not get owner object.")
RuntimeError: Could not get owner object.

in reply to: ↑ 10   Changed 6 years ago by morgs

Replying to morgs:

An issue with the above workaround: If there is an interface up without an IP address - e.g. a wired interface with the cable unplugged - you get the following failure in presenceservice, from https://bugs.launchpad.net/ubuntu/+source/sugar/+bug/297329:

I have been unable to duplicate this issue myself, and it seems to be from interfaces configured without NM.

Changed 6 years ago by morgs

Patch to PS for NM 0.7 API

  Changed 6 years ago by morgs

  • keywords r? added
  • owner changed from Collabora to morgs
  • next_action changed from code to review
  • status changed from new to assigned

Patch attached for NM 0.7 for Presence Service.

|TestCase| Run Sugar on a system with NetworkManager 0.7, and with a valid jabber server, and watch the ~/.sugar/default/logs/presenceservice.log file. You will see " DEBUG s-p-s.telepathy_plugin: ::: IP4 address now <your IP address>". Disable your network interface. You will see "DEBUG s-p-s.server_plugin: ::: invalid IP4 address, will disconnect". Reenable your network interface. You will see the IP address again.

Changed 6 years ago by morgs

Updated patch

Changed 6 years ago by erikos

incorporated morgan's fallback for NM 0.6 and fixed the inet_ntoa call

  Changed 6 years ago by erikos

  • keywords r+ added; r? removed

So the fallback does work fine on 0.7 - i did not have a 0.6 around to test the other case but that should be fine. I was able to share an activity fine over gabble and the output looked fine to me as well. I had to change the socket.inet_ntoa(struct.pack('I', ip)) call. The Ip4Address we get from NM is an unsigned int so this must be a 'I'.

All the rest looks good to me.

follow-up: ↓ 15   Changed 6 years ago by erikos

looks like sharing using this patch over gabble with 0.82 does work with chat but not with write or browse. trying with sugar head browse and write sharing works fine. food for some thoughts.

in reply to: ↑ 14   Changed 6 years ago by morgs

Replying to erikos:

looks like sharing using this patch over gabble with 0.82 does work with chat but not with write or browse. trying with sugar head browse and write sharing works fine. food for some thoughts.

We have established that this problem was caused by a regression in the version of gabble that was in F-10 and joyride. Should be fixed in the next joyride build.

  Changed 6 years ago by morgs

  • next_action changed from review to package

The latest patch in this ticket was pushed to git master, so sugar-presence-service 0.83.2 will contain it.

The patch applies cleanly to sugar-presence-service 0.82.2 so any other distro shipping 0.82 and NM 0.7 can apply it.

I'll close this ticket once sugar-presence-service 0.83.2 is released and in joyride.

Note: See TracTickets for help on using tickets.