Bug 1677839 - Text attachment generation fails for custom report
Summary: Text attachment generation fails for custom report
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Reporting
Version: 5.9.4
Hardware: Unspecified
OS: Linux
medium
medium
Target Milestone: GA
: 5.11.0
Assignee: Joe Rafaniello
QA Contact: Parthvi Vala
Red Hat CloudForms Documentation
URL:
Whiteboard:
: 1706231 (view as bug list)
Depends On:
Blocks: 1679295 1692488 1693727
TreeView+ depends on / blocked
 
Reported: 2019-02-16 08:39 UTC by Bryan Kinney
Modified: 2019-12-13 14:54 UTC (History)
9 users (show)

Fixed In Version: 5.11.0.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1693727 (view as bug list)
Environment:
Last Closed: 2019-12-13 14:54:32 UTC
Category: Bug
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Custom report exported yaml file (1.96 KB, text/plain)
2019-02-16 08:39 UTC, Bryan Kinney
no flags Details

Description Bryan Kinney 2019-02-16 08:39:41 UTC
Created attachment 1535385 [details]
Custom report exported yaml file

Description of problem:
A CloudForms 4.6 server can't send a custom report with a text attachment.
The other CSV and PDF attachment formats work. Those are generated without error for the same custom report. There are results with the given filter. So not a nil data problem.

The error doesn't give a error dump even at debug log level. Just a negative argument error: Report generation returned: Status [Error] Message [negative argument]


Version-Release number of selected component (if applicable):
build: 5.9.4.7-20180829201904_ced41ae

How reproducible:
Import the custom report's yaml. Run or schedule the report on existing analysis data for VMs. In the schedule settings Text attachment type is selected. The CSV or PDF types can be used for comparison.

Steps to Reproduce:
1. Imported the Custom report yaml
2. Schedule or run that report with Text as the attachment type.

Actual results:
When Text attachment type is selected no report email is sent. Error appears in the evm.log file.

Expected results:
Should receive the report as a text MIME attachment.

Additional info:

The ruport gem doesn't seem to be causing this?
The CloudForms appliance is running on Amazon 1a instance with 16GB of memory.

From the evm.log, notify generation is started but fails.
---
[----] I, [2019-02-12T16:21:46.158041 #31984:14483a0]  INFO -- : MIQ(MiqReportResult#async_generate_result) Adding generate report result [txt] task to the message queue...
[----] I, [2019-02-12T16:21:46.160941 #31984:14483a0]  INFO -- : MIQ(MiqTask#update_status) Task: [] [Queued] [Ok] [Task has been queued]
[----] I, [2019-02-12T16:21:46.170975 #31984:14483a0]  INFO -- : MIQ(MiqQueue.put) Message id: [582071],  id: [], Zone: [], Role: [reporting], Server: [], Ident: [generic], Target id: [], Instance id: [306], Task id: [], Command: [MiqReportResult._async_generate_result], Timeout: [3600], Priority: [20], State: [ready], Deliver On: [], Data: [], Args: [9070, :txt, {:userid=>"tempadmin1", :session_id=>"97e8bcf1b5712b581b3a099ed5c56afe"}]
[----] I, [2019-02-12T16:21:46.175026 #31984:14483a0]  INFO -- : <AuditSuccess> MIQ(MiqReportResult.async_generate_result) userid: [tempadmin1] - Generate Report result [txt]: 'Amazon - Top CPU Consumers (last hr)', successfully initiated
[----] I, [2019-02-12T16:21:46.175095 #31984:14483a0]  INFO -- : MIQ(MiqReportResult#async_generate_result) Finished adding generate report result [txt] task with id [9070] to the message queue
[----] E, [2019-02-12T16:21:50.763308 #31976:14474f0] ERROR -- : MIQ(report_controller-wait_for_task): Report generation returned: Status [Error] Message [negative argument]
---

Comment 1 Joe Rafaniello 2019-02-19 12:32:38 UTC
Hi Bryan,

I'm working on a fix for this issue but wanted to share what I found:
1) I was able to recreate the problem

It's trying to print the lines:
Report based filter fields:                                         |
( Performance - VM : Activity Sample - Timestamp (Day/Time) IS "Last Hour" AND Performance - VM : CPU - Usage>>

Because the condition is so long, it's hitting a bug in the code that I will fix.

2) I was able to remedy the problem by adding more columns to expand the width of the table or

3) Removing parts of the condition will make that line shorter too
VmPerformance-timestamp, Last Hour
VmPerformance-cpu_usage_rate_average, 0

Of course, these don't solve the problem but if the users wanted to get parts of that report to work with no codes changes, they could try the above.  Adding more columns and perhaps removing one or two of the conditions of the report would perhaps enable it to run again.

Comment 2 Joe Rafaniello 2019-02-19 21:57:28 UTC
Add change upstream to fix the reported problem:  https://github.com/ManageIQ/manageiq-ui-classic/pull/5254

Comment 4 CFME Bot 2019-02-21 07:11:48 UTC
New commit detected on ManageIQ/manageiq-ui-classic/master:

https://github.com/ManageIQ/manageiq-ui-classic/commit/10f082f59f5b369a25ba7142cc8d00a5c9732cec
commit 10f082f59f5b369a25ba7142cc8d00a5c9732cec
Author:     Joe Rafaniello <jrafanie>
AuthorDate: Tue Feb 19 16:43:46 2019 -0500
Commit:     Joe Rafaniello <jrafanie>
CommitDate: Tue Feb 19 16:43:46 2019 -0500

    Use ljust to left justify and pad strings

    Text based reports ignore line widths.  Performing manual padding was
    causing a "negative argument" error if a line exceeded the normal
    report's line width.

    Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1677839

 lib/report_formatter/text.rb | 10 +-
 spec/lib/report_formater/text_formatter_spec.rb | 78 +
 spec/support/report_helper.rb | 27 +
 3 files changed, 110 insertions(+), 5 deletions(-)

Comment 5 Parthvi Vala 2019-03-13 10:39:00 UTC
Hey Joe,
I tested this case on 5.10.2 and 5.9.9, and I did not face any error, even when I used a condition longer than the one mentioned here.

This is what I see in the TXT file that I received from the schedule run:
---------+
|Report based filter fields:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|( VM and Instance : Power State = "on" AND VM and Instance : Active = "true" AND VM and Instance : Datastore Path INCLUDES "i" AND VM and Instance.Provider : Hostname INCLUDES "env" AND VM and Instance.Provider : IP Address INCLUDES "1" AND VM and Instance : Memory - Recommendation > 0 )                                                                                                                                                                                                                                                                                   |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I tested with the above custom report, but it generated an empty report for some reason, I am checking it. But other than that, I doubt if the long condition is the reason for failure.

Thanks,
Parthvi

Comment 6 Joe Rafaniello 2019-03-13 20:05:53 UTC
Hi Parthvi,

Thanks for testing this.  What columns did you have in your report?  Maybe you had 0 or 1 column?  My example in the PR needed at least 3 or 4 columns.  I used 4 in the test.
See:

https://github.com/ManageIQ/manageiq-ui-classic/pull/5254/files#diff-6ea95eb5eaf3650ef018c69fb85fa940R16

Thanks,
Joe

Comment 7 Joe Rafaniello 2019-03-13 20:06:44 UTC
Note, if you're getting no data, that could also be causing you a problem when trying to recreate it.  Make sure you get data from your report first, then try adding the filter condition that matches all the rows.

Comment 8 Parthvi Vala 2019-03-14 14:10:58 UTC
Hey Joe,

I had tested with 4-7 columns and it was working, but I tested again with 2 columns and the same long condition and I was able to recreate this error. And I was not receiving any data for the custom report that is provided here, which is why I created my own custom report which generated some data. Anyway looks like you identified the correct error, sorry if I caused any inconvenience.

Thanks,
Parthvi

Comment 10 Parthvi Vala 2019-05-03 06:14:12 UTC
FIXED. Verified on 5.11.0.2.20190430174828_0e34dea.

Comment 11 Yuri Rudman 2019-05-06 12:04:20 UTC
*** Bug 1706231 has been marked as a duplicate of this bug. ***


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