suzieq icon indicating copy to clipboard operation
suzieq copied to clipboard

[Bug]: sq-poller failed to run on MacOS in Docker

Open greenfox878 opened this issue 1 year ago • 5 comments

Suzieq version

0.23.0

Install Type

container

Python version

whatever is bundled with your container

Impacted component

sq-poller

Steps to Reproduce

docker run -it -v ./parquet-db:/home/suzieq/parquet -v ./suzieq-cfg.yml:/home/suzieq/.suzieq/suzieq-cfg.yml --name sq-poller netenglabs/suzieq:0.23.0
suzieq@40e46586b5f9:~$ sq-poller -I /home/suzieq/.suzieq/suzieq-cfg.yml

Expected Behavior

sq-poller run w/o crash

Observed Behavior

sq-poller crashed with the error:

2024-06-01 15:48:55,445 - suzieq.poller.controller - WARNING - log level INFO
2024-06-01 15:48:55,446 - suzieq.poller.controller - CRITICAL - 'NoneType' object has no attribute 'min'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/suzieq/poller/sq_poller.py", line 50, in start_controller
    log_suzieq_info('Poller Controller', logger, show_more=True)
  File "/usr/local/lib/python3.8/site-packages/suzieq/shared/utils.py", line 1213, in log_suzieq_info
    cpu_info += f'freq. {cpu_freq.min:.2f}Mhz - {cpu_freq.max:.2f}Mhz'
AttributeError: 'NoneType' object has no attribute 'min'

Screenshots

Additional Context

Actually, it is not an suzieq bug, but psutil bug [macOS] cpu_freq() fails on arm64 The issue appears inside docker container even on latest psutil version:

suzieq@5ac8068b56c0:~$ pip freeze | grep psu
psutil==5.9.8
suzieq@5ac8068b56c0:~$ ipython
Python 3.8.14 (default, Oct  5 2022, 11:57:30)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.2 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import psutil
In [2]: psutil.cpu_freq()
In [3]: exit
suzieq@5ac8068b56c0:~$ python -V
Python 3.8.14
suzieq@5ac8068b56c0:~$

greenfox878 avatar Jun 01 '24 15:06 greenfox878

MacOS 12.7.4 (M1) Docker Desktop 4.30.0

greenfox878 avatar Jun 01 '24 16:06 greenfox878

I don't believe this is the first of your problems running suzieq on a non-x86-64 architecture. we don't have a mac m1/m2/m3 box to test and make changes to, unfortunately.

ddutt avatar Jun 01 '24 19:06 ddutt

Can you find an x86_64 arch box to test suzieq with?

ddutt avatar Jun 01 '24 19:06 ddutt

I removed the psutil.cpu_freq() call and built suzieq docker image on my laptop and so far all works fine. It's enough for testing. Of course, production will run on x86_64. Sorry for bothering!

greenfox878 avatar Jun 02 '24 10:06 greenfox878

@greenfox878 this fix also worked for me to run suzieq on my Apple M1 MAX system.

I simply just commented out (highlighted in red) the following lines in the utils.py script and I was able to run the poller and restapi service:

202407202_0307-CapturFiles

All of my software and automation engineers have mac systems (which only come with M1/M2 chips, not Intel chips) so this is the workaround we have to do unfortunately for local testing.

mthomati avatar Jul 20 '24 10:07 mthomati