Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rootless podman containers cause glances to fail with KeyError #2827

Closed
Tokariew opened this issue Jun 10, 2024 · 0 comments · Fixed by #2834
Closed

Rootless podman containers cause glances to fail with KeyError #2827

Tokariew opened this issue Jun 10, 2024 · 0 comments · Fixed by #2834

Comments

@Tokariew
Copy link

Check the bug
Before filling this bug report, please search if a similar issue already exists.
In this case, just add a comment on this existing issue.

Describe the bug
A clear and concise description of what the bug is.

Displaying container status for rootless podman is not working, instead i get following error, when exiting:

Exception in thread Thread-7 (__update_plugin):
Traceback (most recent call last):
  File "/usr/lib64/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/home/tokariew/.local/share/pipx/venvs/glances/lib64/python3.12/site-packages/glances/stats.py", line 258, in __update_plugin
    self._plugins[p].update()
  File "/home/tokariew/.local/share/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/plugin/model.py", line 1151, in wrapper
    ret = fct(self, *args, **kw)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/share/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/plugin/model.py", line 1168, in wrapper
    ret = fct(*args, **kw)
          ^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/share/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/containers/__init__.py", line 223, in update
    stats_podman = self.update_podman() if self.podman_extension else {}
                   ^^^^^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/share/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/containers/__init__.py", line 245, in update_podman
    version, containers = self.podman_extension.update(all_tag=self._all_tag())
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/share/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/containers/engines/podman.py", line 290, in update
    container_stats = [self.generate_stats(container) for container in containers]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/share/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/containers/engines/podman.py", line 328, in generate_stats
    stats['cpu_percent'] = stats["cpu"]['total']
                           ~~~~~~~~~~~~^^^^^^^^^
KeyError: 'total'

To Reproduce

  1. create this simple config file:
[containers]
disable=False
all=True
podman_sock=unix:///run/user/1000/podman/podman.sock
  1. Start Glances with the following options glances -C glances.ini
  2. See error

Expected behavior
The glances will display running podman containers, and not errors

Environement (please complete the following information)

  • Operating System (lsb_release -a or OS name/version): `To be completed with result of:
LSB Version:	n/a
Distributor ID:	Fedora
Description:	Fedora Linux 40 (Forty)
Release:	40
Codename:	n/a
  • Glances & psutil versions: `To be completed with result of:
Glances version:	4.0.8
Glances API version:	4
PsUtil version:		5.9.8
Log file:		/home/tokariew/.cache/glances/glances.log
  • How do you install Glances (Pypi package, script, package manager, source): pipx
  • Glances test: To be completed with result of: glances --issue
➜ glances --issue -C ~/glances.ini
Exception in thread Thread-7 (__update_plugin):
Traceback (most recent call last):
  File "/usr/lib64/python3.12/threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.12/threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "/home/tokariew/.local/pipx/venvs/glances/lib64/python3.12/site-packages/glances/stats.py", line 258, in __update_plugin
    self._plugins[p].update()
  File "/home/tokariew/.local/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/plugin/model.py", line 1151, in wrapper
    ret = fct(self, *args, **kw)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/plugin/model.py", line 1168, in wrapper
    ret = fct(*args, **kw)
          ^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/containers/__init__.py", line 223, in update
    stats_podman = self.update_podman() if self.podman_extension else {}
                   ^^^^^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/containers/__init__.py", line 245, in update_podman
    version, containers = self.podman_extension.update(all_tag=self._all_tag())
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/containers/engines/podman.py", line 290, in update
    container_stats = [self.generate_stats(container) for container in containers]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tokariew/.local/pipx/venvs/glances/lib64/python3.12/site-packages/glances/plugins/containers/engines/podman.py", line 328, in generate_stats
    stats['cpu_percent'] = stats["cpu"]['total']
                           ~~~~~~~~~~~~^^^^^^^^^
KeyError: 'total'
===============================================================================
Glances 4.0.8 (/home/tokariew/.local/pipx/venvs/glances/lib/python3.12/site-packages/glances/__init__.py)
Python 3.12.3 (/home/tokariew/.local/pipx/venvs/glances/bin/python)
PsUtil 5.9.8 (/home/tokariew/.local/pipx/venvs/glances/lib/python3.12/site-packages/psutil/__init__.py)
===============================================================================
alert         [OK]    0.00001s 
[]
amps          [OK]    0.00006s 
[]
cloud         [OK]    0.00003s 
{}
connections   [OK]    0.05131s 
{'ESTABLISHED': 24,
 'LISTEN': 17,
 'SYN_RECV': 0,
 'SYN_SENT': 2,
 'initiated': 2,
 'net_connections_enabled': True,
 'nf_conntrack_count': 53.0,
 'nf_conntrack_enabled': True,
 'nf_conntrack_max': 262144.0,
 'nf_conntrack_percent': 0.0202178955078125,
 'terminated': 2}
containers    [ERROR] 0.03413s 'total'
core          [OK]    0.00121s 
{'log': 12, 'phys': 6}
cpu           [OK]    0.00058s 
{'cpucore': 12,
 'ctx_switches': 0,
 'ctx_switches_gauge': 4375679908,
 'guest': 0.0,
 'idle': 69.9,
 'interrupts': 0,
 'interrupts_gauge': 1711358773,
 'iowait': 1.0,
 'irq': 0.7,
 'nice': 0.0,
 'soft_interrupts': 0,
 'soft_interrupts_gauge': 504551810,
 'steal': 0.0,
 'syscalls': 0,
 'syscalls_gauge': 0,
 'system': 4.9,
 'time_since_update': 2.281040668487549,
 'total': 50.0,
 'user': 23.3}
diskio        [OK]    0.00094s key=disk_name 
[{'disk_name': 'nvme0n1',
  'key': 'disk_name',
  'read_bytes': 0,
  'read_bytes_gauge': 46388284416,
  'read_count': 0,
  'read_count_gauge': 1543583,
  'time_since_update': 2.283613681793213,
  'write_bytes': 0,
  'write_bytes_gauge': 72489518080,
  'write_count': 0,
  'write_count_gauge': 3493038}, ...]
folders       [OK]    0.00004s 
[]
fs            [OK]    0.00100s key=mnt_point 
[{'device_name': '/dev/mapper/luks-874950f7-5c87-4d70-9abb-1e08ae3aca76',
  'free': 627858595840,
  'fs_type': 'btrfs',
  'key': 'mnt_point',
  'mnt_point': '/',
  'percent': 36.8,
  'size': 998483427328,
  'used': 365083500544}, ...]
gpu           [OK]    0.01921s key=gpu_id 
[{'fan_speed': None, 'gpu_id': 'amd0', 'key': 'gpu_id', 'mem': 19, 'name': 'AMD GPU', 'proc': 89, 'temperature': 77}, ...]
help          [OK]    0.00001s 
None
ip            [OK]    0.00004s 
{}
irq           [OK]    0.00148s key=irq_line 
[{'irq_line': 'CAL', 'irq_rate': 60252, 'key': 'irq_line', 'time_since_update': 2.3028995990753174}, ...]
load          [OK]    0.00005s 
{'cpucore': 12, 'min1': 1.21240234375, 'min15': 1.25048828125, 'min5': 1.2548828125}
mem           [OK]    0.00025s 
{'active': 4660936704,
 'available': 27342598144,
 'buffers': 3592192,
 'cached': 18195009536,
 'free': 27342598144,
 'inactive': 15017549824,
 'percent': 18.5,
 'shared': 285134848,
 'total': 33557012480,
 'used': 6214414336}
memswap       [OK]    0.00040s 
{'free': 15944380416,
 'percent': 7.2,
 'sin': 790790144,
 'sout': 2494521344,
 'time_since_update': 2.3022847175598145,
 'total': 17179865088,
 'used': 1235484672}
network       [OK]    0.00207s key=interface_name 
[{'alias': None,
  'bytes_all': 6972,
  'bytes_all_gauge': 112191242700,
  'bytes_all_rate_per_sec': 3295.0,
  'bytes_recv': 3486,
  'bytes_recv_gauge': 56095621350,
  'bytes_recv_rate_per_sec': 1647.0,
  'bytes_sent': 3486,
  'bytes_sent_gauge': 56095621350,
  'bytes_sent_rate_per_sec': 1647.0,
  'interface_name': 'lo',
  'key': 'interface_name',
  'speed': 0,
  'time_since_update': 2.115530252456665}, ...]
now           [OK]    0.00005s 
{'custom': '2024-06-10 13:11:38 CEST', 'iso': '2024-06-10T13:11:38+02:00'}
percpu        [OK]    0.00017s key=cpu_number 
[{'cpu_number': 0,
  'guest': 0.0,
  'guest_nice': 0.0,
  'idle': 0.0,
  'iowait': 0.0,
  'irq': 0.0,
  'key': 'cpu_number',
  'nice': 0.0,
  'softirq': 0.0,
  'steal': 0.0,
  'system': 0.0,
  'total': 100.0,
  'user': 0.0}, ...]
ports         [OK]    0.00027s 
[]
processcount  [OK]    0.10009s 
{'pid_max': 0, 'running': 2, 'sleeping': 229, 'thread': 1028, 'total': 422}
processlist   [OK]    0.00038s 
[]
psutilversion [OK]    0.00002s 
'5.9.8'
quicklook     [OK]    0.00044s 
{'cpu': 50.0,
 'cpu_hz': 3600000000.0,
 'cpu_hz_current': 3859061583.3333325,
 'cpu_log_core': 12,
 'cpu_name': 'AMD Ryzen 5 3600 6-Core Processor',
 'cpu_phys_core': 6,
 'load': 10.4,
 'mem': 18.5,
 'percpu': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}],
 'swap': 7.2}
raid          [OK]    0.00002s 
{}
sensors       [OK]    0.00001s key=label 
[{'critical': 115,
  'key': 'label',
  'label': 'AUXTIN0',
  'type': <SensorType.CPU_TEMP: 'temperature_core'>,
  'unit': 'C',
  'value': 61,
  'warning': 115}, ...]
smart         [NA]
system        [OK]    0.00001s 
{'hostname': 'ryzen.tokariew.xyz',
 'hr_name': 'Fedora Linux 40 64bit / Linux 6.8.11-300.fc40.x86_64',
 'linux_distro': 'Fedora Linux 40',
 'os_name': 'Linux',
 'os_version': '6.8.11-300.fc40.x86_64',
 'platform': '64bit'}
uptime        [OK]    0.00013s 
{'seconds': 98459}
version       [OK]    0.00002s 
'4.0.8'
wifi          [OK]    0.00010s 
[]
===============================================================================
Total time to update all stats: 0.21884s
===============================================================================

Additional context
version reported by pipx:

   package glances 4.0.8, installed using Python 3.12.3
    - glances
    - man1/glances.1
    Injected Packages:
      - fastapi 0.111.0
      - podman 5.0.0

You can also pastebin:

@RazCrimson RazCrimson changed the title don't display rootless podman containers, KeyError Rootless podman containers cause glances to fail with KeyError Jun 16, 2024
@nicolargo nicolargo added this to the Glances 4.1.0 milestone Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants