Bug 1709663 - CPU benchmarking fails with error "a bytes-like object is required, not 'str'"
Summary: CPU benchmarking fails with error "a bytes-like object is required, not 'str'"
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: python-hardware
Version: 15.0 (Stein)
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: beta
: 15.0 (Stein)
Assignee: Riccardo Pittau
QA Contact: nlevinki
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-05-14 06:36 UTC by Dan Macpherson
Modified: 2023-03-24 14:48 UTC (History)
7 users (show)

Fixed In Version: python-hardware-0.20.2-0.20190618010411.1701537.el8ost
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1753653 (view as bug list)
Environment:
Last Closed: 2019-09-21 11:21:58 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github redhat-cip hardware issues 87 0 None closed CPU benchmark fails with Python 3 2020-09-23 09:12:36 UTC
Github redhat-cip hardware pull 88 0 None closed Fix error cpu benchmark with Python 3.x 2020-09-23 09:12:32 UTC
Red Hat Product Errata RHEA-2019:2811 0 None None None 2019-09-21 11:22:17 UTC

Description Dan Macpherson 2019-05-14 06:36:55 UTC
Description of problem:
Running CPU benchmarking for hardware-detect causes the following error:

Traceback (most recent call last):
  File "/bin/hardware-detect", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/hardware/detect.py", line 1022, in main
    _main(options)
  File "/usr/lib/python3.6/site-packages/hardware/detect.py", line 962, in _main
    bm_cpu.cpu_perf(hrdw)
  File "/usr/lib/python3.6/site-packages/hardware/benchmark/cpu.py", line 118, in cpu_perf
    run_sysbench_cpu(hw_lst, max_time, 1, processor_num)
  File "/usr/lib/python3.6/site-packages/hardware/benchmark/cpu.py", line 52, in run_sysbench_cpu
    if "total number of events" in line:
TypeError: a bytes-like object is required, not 'str'

This affects the ironic inspection process. The ironic agent tries to benchmark the node CPU, fails, immediately restarts the ironic agent service, and attempts to benchmark the CPU again. This causes a never-ending loop and the inspection process never completes.

Version-Release number of selected component (if applicable):
python3-hardware          noarch   0.20.2-0.20190429092025.3be61d4.el8ost
python3-hardware-detect   noarch   0.20.2-0.20190429092025.3be61d4.el8ost

Error occurs in two situations:

1. Manual test of "hardware-detect --benchmark cpu" on RHEL8 VM
2. During ironic inspection (using rhosp-director-images-ipa-x86_64 15.0-20190509.3.el8ost) of physical and virtual nodes.

How reproducible:
Always

Steps to Reproduce:
1. Install python3-hardware
2. Run "hardware-detect --benchmark cpu"
3. Get an error about the object/str issue

Actual results:
An error

Expected results:
Working CPU benchmark

Additional info:
I also tested running an earlier version of hardware-detect. I ran python2-hardware 0.18-12.fc29 on my Fedora 29 laptop and running "hardware-detect --benchmark cpu" works.

Comment 1 Riccardo Pittau 2019-05-17 13:50:20 UTC
confirmed also upstream, can reproduce with Python 3.6 and 3.7

this is due to the fact that the output of the commands in Python 3.x is considered bytes and not text

we'll have a fix ASAP

Comment 2 Riccardo Pittau 2019-06-06 09:42:48 UTC
Fix has been merged upstream

Comment 6 Alistair Tonner 2019-07-11 14:09:52 UTC
Puddle: RHOS_TRUNK-15.0-RHEL-8-20190708.n.2
Kernel: 4.18.0-80.4.2.el8_0.x86_64

python3-hardware          0.20.2-0.20190618010411.1701537.el8ost  rhelosp-15.0-trunk  
python3-hardware-detect   0.20.2-0.20190618010411.1701537.el8ost  rhelosp-15.0-trunk      


  -- This now functions correctly without the listed error.

(manully installed code, ran command both as user and as root on undercloud and compute node)

Comment 8 Dan Macpherson 2019-09-19 10:16:46 UTC
Hi folks,

I retested the CPU benchmarking and it works, but it looks like the memory benchmark has the same issue:

Memory Performance: 8 logical CPU to test (ETA: 350 seconds)
Benchmarking memory @1K from CPU 0 for 5 seconds (1 threads)
Traceback (most recent call last):
  File "/usr/bin/hardware-detect", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/hardware/detect.py", line 981, in main
    bm_mem.mem_perf(hrdw)
  File "/usr/lib/python3.6/site-packages/hardware/benchmark/mem.py", line 152, in mem_perf
    block_size, 1, cpu_nb)
  File "/usr/lib/python3.6/site-packages/hardware/benchmark/mem.py", line 91, in run_sysbench_memory_threaded
    if "transferred" in line:
TypeError: a bytes-like object is required, not 'str'

Should I create a new BZ for that issue?

Comment 9 Bob Fournier 2019-09-19 11:49:50 UTC
Dan - yes, can you create a new BZ for this?

Comment 10 Dan Macpherson 2019-09-19 14:19:04 UTC
Created a similar BZ for the memory benchmarking: https://bugzilla.redhat.com/show_bug.cgi?id=1753653

Comment 11 errata-xmlrpc 2019-09-21 11:21:58 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, 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/RHEA-2019:2811


Note You need to log in before you can comment on or make changes to this bug.