Bug 798884

Summary: [REST API] No exit-code and incorrect application id is shown when calling gear REST API
Product: OKD Reporter: Johnny Liu <jialiu>
Component: PodAssignee: Ravi Sankar Penta <ravi>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.xCC: andyk, rmillner, rpenta
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-19 18:23:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Johnny Liu 2012-03-01 07:50:23 UTC
Description of problem:
Give a non-existing app name (phptest1) on purpose upon calling rest api,

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

How reproducible:
Always

Steps to Reproduce:
1. Call gear rest api with a non-existing app name (phptest1) on purpose.
$ curl -k -X GET -H 'Accept: application/xml' --user jialiu:214214 https://ec2-184-73-117-151.compute-1.amazonaws.com/broker/rest/domains/jialiu/applications/phptest1/gears
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <type nil="true"></type>
  <version>1.0</version>
  <messages>
    <message>
      <field nil="true"></field>
      <severity>error</severity>
      <exit-code nil="true"></exit-code>
      <text>Application 70226569206200 not found.</text>
    </message>
  </messages>
  <data nil="true"></data>
  <status>not_found</status>
</response>


  
Actual results:
1. No exit-code, according to Bug 787295, every error message should have exit_code.
2. application id is not correct
<text>Application 70226569206200 not found.</text>
should be
<text>Application phptest1 not found.</text>

Expected results:
exit-code and app id is shown correctly in the output of rest api.

Additional info:
About application id issue:
cloud-sdk/controller/lib/cloud-sdk-controller/app/controllers/gears_controller.rb:
<--snip-->
  def show
    domain_id = params[:domain_id]
    app_id = params[:application_id]

    app = Application.find(@cloud_user,app_id)

    if app.nil?
      @reply = RestReply.new(:not_found)
      message = Message.new(:error, "Application #{id} not found.")
      @reply.messages.push(message)
      respond_with @reply, :status => @reply.status
<--snip-->

app_id should be changed to id
or 
#{id} should be changed to #{app_id}

Comment 1 Ravi Sankar 2012-03-15 19:06:20 UTC
Fixed.

Comment 2 Johnny Liu 2012-03-16 11:25:56 UTC
Verified this bug with devenv_stage_144, and PASS.

$ curl -k -X GET -H "Accept: application/xml" --user jialiu:xx https://ec2-50-17-147-234.compute-1.amazonaws.com/broker/rest/domains/jialiu/applications/phptest1/gears
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <data nil="true"></data>
  <status>not_found</status>
  <version>1.0</version>
  <type nil="true"></type>
  <messages>
    <message>
      <severity>error</severity>
      <text>Application 'phptest1' not found.</text>
      <exit-code>101</exit-code>
      <field nil="true"></field>
    </message>
  </messages>
</response>