Bug 1648499

Summary: Task not marked as Finished while queuing service chargeback report through REST API
Product: Red Hat CloudForms Management Engine Reporter: Nandini Chandra <nachandr>
Component: APIAssignee: Yuri Rudman <yrudman>
Status: CLOSED CURRENTRELEASE QA Contact: Nandini Chandra <nachandr>
Severity: medium Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: medium    
Version: 5.10.0CC: bmidwood, dmetzger, hkataria, lavenel, mpovolny, obarenbo, simaishi, yrudman
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.11.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1702660 (view as bug list) Environment:
Last Closed: 2019-12-13 15:16:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1702660    

Description Nandini Chandra 2018-11-09 23:35:54 UTC
Description of problem:
-----------------------
I ran into this issue while verifying 

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

Run the following command to queue/generate service chargeback report through REST API.

nachandr@unknown104A7DA2510C cfme_tests]$ curl "https://admin:smartvm@10.8.xx.yy/api/services/1" -k -X POST -H "Content-Type" -d '{"action": "queue_chargeback_report"}'
{"success":true,"message":"Queued chargeback report generation for Service id:1 name:'nan-cat-item'","task_id":"4","task_href":"https://10.8.xx.yy/api/tasks/138"}[nachandr@unknown104A7DA2510C cfme_tests]

The above request ends up creating 2 tasks - one to queue it and the other to actually generate the report, see below. However, the request returns the first (id 138) task that never gets set to "Finished". The second task (id 139) does get marked as "Finished"


irb(main):007:0> pp MiqTask.find(138)
#<MiqTask:0x000000000b6c13c0
 id: 138,
 name: "Generating chargeback report with id: 1",
 state: "Queued",
 status: "Ok",
 message: "Queueing Chargeback of Service with id: 1",
 userid: "system",
 created_on: Fri, 09 Nov 2018 13:59:03 UTC +00:00,
 updated_on: Fri, 09 Nov 2018 13:59:03 UTC +00:00,
 pct_complete: nil,
 context_data: nil,
 results: nil,
 miq_server_id: nil,
 identifier: nil,
 started_on: nil,
 zone: nil>

=> #<MiqTask id: 138, name: "Generating chargeback report with id: 1", state: "Queued", status: "Ok", message: "Queueing Chargeback of Service with id: 1", userid: "system", created_on: "2018-11-09 13:59:03", updated_on: "2018-11-09 13:59:03", pct_complete: nil, context_data: nil, results: nil, miq_server_id: nil, identifier: nil, started_on: nil, zone: nil>
irb(main):008:0> pp MiqTask.find(139)
#<MiqTask:0x000000000b6b13d0
 id: 139,
 name: "Generate Report: ''",
 state: "Finished",
 status: "Ok",
 message: "Generating report complete",
 userid: "admin",
 created_on: Fri, 09 Nov 2018 13:59:05 UTC +00:00,
 updated_on: Fri, 09 Nov 2018 13:59:07 UTC +00:00,
 pct_complete: nil,
 context_data: nil,
 results: nil,
 miq_server_id: 1,
 identifier: nil,
 started_on: Fri, 09 Nov 2018 13:59:05 UTC +00:00,
 zone: nil>


Version-Release number of selected component (if applicable):
---------------------
5.10.0.23


How reproducible:
----------------
Always


Steps to Reproduce:
-------------------
1.
2.
3.


Actual results:
---------------
Task created while queuing service chargeback report through REST API is not marked as Finished.


Expected results:
----------------
Task created while queuing service chargeback report through REST API should be marked as Finished.


Additional info:
---------------

Comment 3 CFME Bot 2019-03-15 18:41:08 UTC
New commit detected on ManageIQ/manageiq/master:

https://github.com/ManageIQ/manageiq/commit/10de8acde67333bf824289231f2a2fb0f65bc810
commit 10de8acde67333bf824289231f2a2fb0f65bc810
Author:     Yuri Rudman <yrudman>
AuthorDate: Mon Mar 11 12:17:23 2019 -0400
Commit:     Yuri Rudman <yrudman>
CommitDate: Mon Mar 11 12:17:23 2019 -0400

    pass miq_task_id and miq_callback when submitting job for generating chargeback for servcie. It will allow to initialize task's started_on column and to change task status Finished when queue item delivered.
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1648499

 app/models/service.rb | 16 +-
 1 file changed, 13 insertions(+), 3 deletions(-)

Comment 5 Nandini Chandra 2019-06-07 04:03:09 UTC
Verified in 5.11.05