Bug 1796540 - json data generated by insights plugin is sometimes not parsable
Summary: json data generated by insights plugin is sometimes not parsable
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: RH Cloud - Inventory
Version: 6.6.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Shimon Shtein
QA Contact: Mirek Długosz
URL:
Whiteboard:
: 1809297 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-01-30 16:43 UTC by Paul Dudley
Modified: 2023-09-07 21:39 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-01 12:22:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Paul Dudley 2020-01-30 16:43:30 UTC
When analyzing the json data inside RH inventory tar file - report_for_1.tar.gz - the json data is not parsable. For example:

───────────────────────────────────
[root@iridium tmp]# cat 49154599-35a5-4be7-a6ba-9d9ec9b72c59.json | json_reformat
...
                    "libselinux-2.5-11.el7.x86_64",
parse error: unallowed token at this point in JSON text
                                        6_64", "nss-util-3.28.4-3.el7.
                     (right here) ------^
                    "info-5.1-4.el7.x86_64"
───────────────────────────────────
[root@iridium tmp]# cat 49154599-35a5-4be7-a6ba-9d9ec9b72c59.json | python -m json.tool
No JSON object could be decoded
───────────────────────────────────

The problem appears to be that the parsers fail to prettify json output when they encounter a string of commas and spaces, here:

───────────────────────────────────
[root@iridium tmp]# cat 49154599-35a5-4be7-a6ba-9d9ec9b72c59.json | grep -o ', , ,' | wc -l
76
───────────────────────────────────

And for a generated json file that parses without error:
───────────────────────────────────
╰─ cat 242724c2-9cd6-465d-b8d0-8320d57c97ce.json | grep -o ', , ,' | wc -l
0
───────────────────────────────────

Customers who want to view the report information will not be able to if the information is not parsable with these tools.

Comment 3 Shimon Shtein 2020-02-02 06:32:35 UTC
Can you please attach the report (or json) to see which fields generate such an output?

Comment 5 Paul Dudley 2020-02-03 15:41:15 UTC
The report can be successfully parsed after removing the extra commas and spaces:
───────────────────────────────────
[root@iridium ~]# grep -o fqdn 566cdc6d-fd70-4e04-9277-b0afba5e0a82.json  | python -m json.tool
No JSON object could be decoded
───────────────────────────────────
Number of host entries:
[root@iridium ~]# grep -o fqdn 566cdc6d-fd70-4e04-9277-b0afba5e0a82.json  | wc -l
586

Removing extra commas and spaces:
[root@iridium ~]# cat 566cdc6d-fd70-4e04-9277-b0afba5e0a82.json | tr ' ' '\n' | sed 's/^,//g' | tr -d '\n' | python -m json.tool | tail -n5
            "vm_uuid": "5a2f8602-ea12-4685-ad5c-c919cc8b2d5f"
        }
    ],
    "report_slice_id": "566cdc6d-fd70-4e04-9277-b0afba5e0a82"
}
───────────────────────────────────
The same number of hosts is kept after this editing:
[root@iridium ~]# cat 566cdc6d-fd70-4e04-9277-b0afba5e0a82.json | tr ' ' '\n' | sed 's/^,//g' | tr -d '\n' | python -m json.tool | grep fqdn | wc -l
586

It should be noted that the number of hosts in the report does not match the number of hosts in the Satellite:
───────────────────────────────────
[root@iridium ~]# hammer host list | wc -l
858
───────────────────────────────────
[root@iridium ~]# grep -o fqdn 566cdc6d-fd70-4e04-9277-b0afba5e0a82.json  | wc -l
586

Comment 7 Shimon Shtein 2020-04-07 16:36:36 UTC
*** Bug 1809297 has been marked as a duplicate of this bug. ***

Comment 13 Bryan Kearney 2020-05-01 12:22:15 UTC
I am closing this out as it was delivered in Satelilte 6.6.3.


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