Ubuntu 21.04 (Hirsute) MOTD network section is broken

Bug #1925974 reported by Dominick Han
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Landscape Client
New
Undecided
Unassigned
landscape-client (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

```
Welcome to Ubuntu 21.04 (GNU/Linux 5.11.0-16-generic x86_64)

 * Documentation: https://help.ubuntu.com
 * Management: https://landscape.canonical.com
 * Support: https://ubuntu.com/advantage

  System information as of Fri Apr 23 14:15:44 EDT 2021

  System load: 4.09 Swap usage: 0% Users logged in: 0
  Usage of /: 7.9% of 438.62GB Temperature: 73.0 C
  Memory usage: 2% Processes: 241

  => There were exceptions while processing one or more plugins. See
     /var/log/landscape/sysinfo.log for more information.

 * Pure upstream Kubernetes 1.21, smallest, simplest cluster ops!

     https://microk8s.io/

0 updates can be installed immediately.
0 of these updates are security updates.

Last login: Fri Apr 23 12:04:04 2021 from 192.168.39.125
```
In the `sysinfo.log` file:
```
2021-04-23 17:13:14,425 ERROR Network plugin raised an exception.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/landscape/sysinfo/sysinfo.py", line 99, in run
    result = plugin.run()
  File "/usr/lib/python3/dist-packages/landscape/sysinfo/network.py", line 36, in run
    device_info = self._get_device_info()
  File "/usr/lib/python3/dist-packages/landscape/lib/network.py", line 163, in get_active_device_info
    speed, duplex = get_network_interface_speed(
  File "/usr/lib/python3/dist-packages/landscape/lib/network.py", line 249, in get_network_interface_speed
    res = status_cmd.tostring()
AttributeError: 'array.array' object has no attribute 'tostring'
```

Upon investigation, `tostring()` method in Python array was deprecated in 3.9 (The default Python version in 21.04?)
On 20.10:
```
Python 3.8.6 (default, Jan 27 2021, 15:42:20)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from array import array
>>> array('B').tostring()
b''
```
On 21.04:
```
Python 3.9.4 (default, Apr 4 2021, 19:38:44)
[GCC 10.2.1 20210401] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from array import array
>>> array('B').tostring()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'array.array' object has no attribute 'tostring'
```

The fix would simply be replacing `tostring()` with `tobytes()`
`tostring` was deprecated since Python 3.2, and was removed in 3.9
https://docs.python.org/3.8/library/array.html#array.array.tostring

PS: I have upgraded my installation from 20.10 instead of brand new installation of the 21.04 release ISO. Not sure if that changes anything, the source I find here still uses `tostring()` https://packages.ubuntu.com/source/hirsute/landscape-client

From apt-cache policy:
```
landscape-client:
  Installed: (none)
  Candidate: 19.12-0ubuntu9
  Version table:
     19.12-0ubuntu9 500
        500 http://ca.archive.ubuntu.com/ubuntu hirsute/main amd64 Packages
```

Tags: patch
Revision history for this message
Dominick Han (dominick-han) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "network.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in landscape-client (Ubuntu):
status: New → Confirmed
Revision history for this message
Jon N (nistorj) wrote :

Hi,

The latest file shows as follows:

```
    try:
        fcntl.ioctl(sock, SIOCETHTOOL, packed) # Status ioctl() call
        if _PY3:
            res = status_cmd.tobytes()
        else:
            res = status_cmd.tostring()
        speed, duplex = struct.unpack("12xHB28x", res)
```

However even with this, or replacing and forcing only tobytes() still produces the following for us:
2021-08-18 03:13:20,074 ERROR Network plugin raised an exception.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/landscape/sysinfo/sysinfo.py", line 99, in run
    result = plugin.run()
  File "/usr/lib/python3/dist-packages/landscape/sysinfo/network.py", line 36, in run
    device_info = self._get_device_info()
  File "/usr/lib/python3/dist-packages/landscape/lib/network.py", line 158, in get_active_device_info
    flags = get_flags(sock, interface.encode())
  File "/usr/lib/python3/dist-packages/landscape/lib/network.py", line 136, in get_flags
    data = fcntl.ioctl(
OSError: [Errno 19] No such device

We have some our ip link has various dummy interfaces and some vrf info in it. not sure if that would cause issues with this or not.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.