Bug 1379079

Summary: [RFE] better traceback for Ansible Tower API errors
Product: Red Hat CloudForms Management Engine Reporter: Tsai Li Ming <ltsai>
Component: ProvidersAssignee: Brandon Dunne <bdunne>
Status: CLOSED CURRENTRELEASE QA Contact: Pavol Kotvan <pakotvan>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.6.0CC: jfrey, jhardy, obarenbo, simaishi
Target Milestone: GAKeywords: FutureFeature, TestOnly, ZStream
Target Release: 5.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: tower
Fixed In Version: 5.8.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1411507 (view as bug list) Environment:
Last Closed: 2017-06-12 16:20:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Ansible Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1411507    

Description Tsai Li Ming 2016-09-24 17:49:54 UTC
Description of problem:
Currently, if the API fails, the evm.log will contain a "DRb::DRbConnError: connection closed" error without any details of the API response. 

I was clueless and it took me some time to figure out that this was an API error. I had to look at Ansible tower httpd log and it was a HTTP 400 error.

Did a tcpdump and found out:
POST /api/v1/job_templates/5/launch/ HTTP/1.1
Authorization: Basic YWRtaW46c3lzdGVt
User-Agent: Faraday v0.9.2
Content-Type: application/json
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
Connection: close
Host: xxxx
Content-Length: 19
{"extra_vars":"{}"}
HTTP/1.1 400 BAD REQUEST
<followed by reason in the response>


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

How reproducible:
Always

Steps to Reproduce:
1. Add Ansible Tower as provider
2. Create a job template but without credentials
3. Launch the job template from CF


Actual results:
Exception without any further details why the API fails.

Expected results:
There should be better logging.

Additional info:

Comment 2 Brandon Dunne 2016-12-06 15:09:45 UTC
Error messages are now properly parsed.  Added error logging on errors.  Added optional debug logging to aid in troubleshooting.

Comment 4 CFME Bot 2016-12-06 17:16:35 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/0366af17f56f73e73cbd28b2b01c742b21651818

commit 0366af17f56f73e73cbd28b2b01c742b21651818
Author:     Brandon Dunne <bdunne>
AuthorDate: Mon Dec 5 15:37:14 2016 -0500
Commit:     Brandon Dunne <bdunne>
CommitDate: Mon Dec 5 15:37:14 2016 -0500

    Ensure AnsibleTowerClient.logger is set to $log not a NullLogger
    
    Update ansible_tower_client to take advantage of debug and error logging enhancements
    https://bugzilla.redhat.com/show_bug.cgi?id=1393941
    https://bugzilla.redhat.com/show_bug.cgi?id=1379079

 Gemfile                                                 | 2 +-
 app/models/manageiq/providers/ansible_tower/provider.rb | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comment 5 Brandon Dunne 2016-12-06 18:36:57 UTC
https://github.com/ManageIQ/manageiq/pull/12996