Debian: collect kube-memory reports a stacktrace

Bug #1999673 reported by Al Bailey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
Low
Gustavo Lyra Pereira

Bug Description

Brief Description
-----------------
running collect on a debian STX system will create a kube-memory.info file that contains a stacktrace.
It runs the utility kube-memory
The code is in https://github.com/starlingx/monitoring/tree/master/kube-memory

The tool should report the correct data and not the stacktrace.

Severity
--------
Minor

Steps to Reproduce
------------------
Setup a system (AIO)
sudo kube-memory

Expected Behavior
------------------
Should show the kube-memory results

Actual Behavior
----------------
Shows a stacktrace

Reproducibility
---------------
100%

System Configuration
--------------------
AIO-SX

Branch/Pull Time/Commit
-----------------------
Dec 14, 2022

Last Pass
---------
Centos. (Based on the stacktrace, this likely has never worked in python3, which is what we run on Debian)

Timestamp/Logs
--------------

2022-12-14 16:23:21,477 131875 ERROR kube_memory: exception: TypeError("a bytes-like object is required, not 'str'")
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/kube_memory/kube_memory.py", line 525, in main
    ret = gather_info_and_display()
  File "/usr/lib/python3/dist-packages/kube_memory/kube_memory.py", line 380, in gather_info_and_display
    pt_groups = gather_groups_memory(output_mem)
  File "/usr/lib/python3/dist-packages/kube_memory/kube_memory.py", line 204, in gather_groups_memory
    for line in output_mem.split("\n"):
TypeError: a bytes-like object is required, not 'str'

Test Activity
-------------
Feature Testing

Workaround
----------
None

Revision history for this message
Al Bailey (albailey1974) wrote :

Note: we have seen this type of issue elsewhere, and the fix is to add 'decode' to the data that we read.
example
https://review.opendev.org/c/starlingx/oidc-auth-armada-app/+/846174/4/oidc-auth-tools/oidcauthtools/oidcauthtools/oidc_auth.py

So changing the pipe_output method should be good enough

example
https://github.com/starlingx/monitoring/blob/f79dcc176f7c7c405731426bc242b3cfe48e1055/kube-memory/kube-memory/kube_memory/kube_memory.py#L184

changing:
 return last_popen[-1].communicate()[0]
to:
 return last_popen[-1].communicate()[0].decode()

Ghada Khalil (gkhalil)
tags: added: stx.monitor
Changed in starlingx:
assignee: nobody → Gustavo Lyra Pereira (gustavolyrap)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to monitoring (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/starlingx/monitoring/+/869236

Changed in starlingx:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to monitoring (master)

Reviewed: https://review.opendev.org/c/starlingx/monitoring/+/869236
Committed: https://opendev.org/starlingx/monitoring/commit/f586043ff5a2be7942506f034d80c190f8ba21ba
Submitter: "Zuul (22348)"
Branch: master

commit f586043ff5a2be7942506f034d80c190f8ba21ba
Author: Gustavo Pereira <email address hidden>
Date: Wed Jan 4 10:50:25 2023 -0500

    Fix for TypeError in kube-memory

    This change fixes the TypeError issue
    in kube-memory stacktrace feature.
    Resolved issue by adding a decode
    method to its function return.

    Tested Plan:
    Pass: Installed AIO-SX with full deployment,
    and executed command kube-memory without errors.
    Pass: Installed AIO-DX with full deployment,
    and executed command kube-memory without errors.

    Closes-bug: 1999673

    Signed-off-by: Gustavo Pereira <email address hidden>
    Change-Id: Ie18ab617cd38a0aad1020af7ffea388dbfa5e830

Changed in starlingx:
status: In Progress → Fix Released
Ghada Khalil (gkhalil)
Changed in starlingx:
importance: Undecided → Low
tags: added: stx.8.0
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.