cron_ipmi_sensors.py: TypeError: write() argument must be str, not bytes

Bug #1879603 reported by Joe Guo
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
hw-health-charm
Fix Released
Critical
Unassigned

Bug Description

After `juju upgrade-charm --switch cs:hw-health-0 hw-health`, I found following exception:

/usr/local/lib/nagios/plugins/cron_ipmi_sensors.py --noentityabsent
    Traceback (most recent call last):
    File "/usr/local/lib/nagios/plugins/cron_ipmi_sensors.py", line 61, in <module>
        gather_metrics()
    File "/usr/local/lib/nagios/plugins/cron_ipmi_sensors.py", line 50, in gather_metrics
        fd.write(output)
    TypeError: write() argument must be str, not bytes

Related branches

Joe Guo (guoqiao)
description: updated
Joe Guo (guoqiao)
Changed in charm-hw-health:
assignee: nobody → Joe Guo (guoqiao)
importance: Undecided → Medium
milestone: none → 20.05
Revision history for this message
Joe Guo (guoqiao) wrote :

In py2: open with `w` == `wb`
In py3: `w` == `wt`
However, subprocess.check_output always return bytes, in both py2/py3.
So in py3, while trying to write output (bytes) to file opened with `w` (`wt`, expect text), it will raise error.

Merge created to fix this bug.

Alvaro Uria (aluria)
Changed in charm-hw-health:
milestone: 20.05 → none
Joe Guo (guoqiao)
Changed in charm-hw-health:
status: New → In Progress
Changed in charm-hw-health:
importance: Medium → Critical
Revision history for this message
Alvaro Uria (aluria) wrote :

Released at cs:~llama-charmers-next/hw-health-2

Please confirm the fix and we will backport it to stable/20.05.

Changed in charm-hw-health:
status: In Progress → Fix Committed
milestone: none → 20.08
Revision history for this message
Márton Kiss (marton-kiss) wrote :

I can confirm it is not throwing the exception anymore with the cs:~llama-charmers-next/hw-health-2 charm.

Andrea Ieri (aieri)
Changed in charm-hw-health:
assignee: Joe Guo (guoqiao) → Andrea Ieri (aieri)
Revision history for this message
Andrea Ieri (aieri) wrote :

The fix has been backported to cs:hw-health-2 (20.05)

Changed in charm-hw-health:
status: Fix Committed → Fix Released
assignee: Andrea Ieri (aieri) → nobody
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.