Page MenuHomePhabricator

Cumin JSON output format broken
Closed, ResolvedPublic

Description

It now tries to serialise the result of each host for some reason:

krenair@deployment-cumin:~$ sudo cumin --force --output json 'P{deployment-cumin.deployment-prep.eqiad.wmflabs}' id
1 hosts will be targeted:
deployment-cumin.deployment-prep.eqiad.wmflabs
FORCE mode enabled, continuing without confirmation
----- OUTPUT of 'id' -----                                                                                                                                                                                  
uid=0(root) gid=0(root) groups=0(root)                                                                                                                                                                      
================                                                                                                                                                                                            
PASS:  |███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100% (1/1) [00:01<00:00,  1.73s/hosts]     
FAIL:  |                                                                                                                                                               |   0% (0/1) [00:01<?, ?hosts/s]     
100.0% (1/1) success ratio (>= 100.0% threshold) for command: 'id'.
100.0% (1/1) success ratio (>= 100.0% threshold) of nodes successfully executed all commands.
_____FORMATTED_OUTPUT_____
Caught TypeError exception: b'uid=0(root) gid=0(root) groups=0(root)' is not JSON serializable

This has broken my cron job that emails me about the puppet results across all our deployment-prep hosts, as it tries to shell out to cumin and gather the results after _____FORMATTED_OUTPUT_____\n as JSON.

Event Timeline

Change 448985 had a related patch set uploaded (by Alex Monk; owner: Alex Monk):
[operations/software/cumin@master] Python 3: Fix another bytes vs. string problem breaking JSON formatting

https://gerrit.wikimedia.org/r/448985

I've patched deployment-cumin:/usr/lib/python3/dist-packages/cumin/cli.py

Change 449130 had a related patch set uploaded (by Volans; owner: Volans):
[operations/software/cumin@master] Fix the -o/--output option (bytes->str conversion)

https://gerrit.wikimedia.org/r/449130

@Krenair Thanks for reporting this issue, I'm sending a separate patch to fix both json and txt choices of the -o/--output option and adding some integration tests for those. I'll release a new version as soon as it's merged.

Change 449130 merged by Volans:
[operations/software/cumin@master] Fix the -o/--output option (bytes->str conversion)

https://gerrit.wikimedia.org/r/449130

Volans removed a project: Patch-For-Review.

Cumin 3.0.2 has been released and includes a fix for this bug. Thanks a lot for reporting it. I'll take care of upgrading production, but I'll leave the hosts in WMCS to their owners.

Change 448985 abandoned by Alex Monk:
Python 3: Fix another bytes vs. string problem breaking JSON formatting

Reason:
I3d7025e8

https://gerrit.wikimedia.org/r/448985