incubator-ambari-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Onischuk (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AMBARI-3244) Ambari Client improve errors handling
Date Wed, 18 Sep 2013 13:51:51 GMT

     [ https://issues.apache.org/jira/browse/AMBARI-3244?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Andrew Onischuk updated AMBARI-3244:
------------------------------------

    Description: 
1. Add a server error response to the getters and creators
>From the user's side error handling look's like this:
{code}
  try:
    // will fail somewhere during trying to create a host model with corrupt
    // response
    host = client.get_host('not existant host')
  except Exception, ex:
    print "Unknown termination reason!"
    return
{code}
2. Some error messages are missed. The problem is that the way we decide, whether error response
is decodable can't be based on the error code

E.g. 404 can be json as well as html
{code}
component = client.get_components('HDP-1.0.0', 'JOBTRACKER')
{code}
{code}
{
  "status" : 404,
  "message" : "The requested resource doesn't exist: Stack data, stackName=HDP, stackVersion=HDP-1.0.0"
}
{code}
3. Encapsulate from user messing with return codes, to find out if everything was fine
Is
{code}
  resp =  cluster.delete_host('bad_host')
  
  if resp.status != 200 and resp.status != 201:
    print "Terminating on error"
    return
{code}
Should be:
{code}
  resp =  cluster.delete_host('bad_host')
  
  if resp.is_error():
    print "Terminating on error"
    return
{code}


  was:
1. Add a server error response to the getters and creators
>From the user's side error handling look's like this:
{code}
  try:
    // will fail somewhere during trying to create a host model with corrupt
    // response
    host = client.get_host('not existant host')
  except Exception, ex:
    print "Unknown termination reason!"
    return
{code}

Should be:
{code}
host, err_resp = client.get_host('not existant host')

if err_resp:
  print "Error happened, terminating with error code" % (err_resp.status)
  print "Reason: %s" % (err_resp.message)
  return
{code}
2. Some error messages are missed. The problem is that the way we decide, whether error response
is decodable can't be based on the error code

E.g. 404 can be json as well as html
{code}
component = client.get_components('HDP-1.0.0', 'JOBTRACKER')
{code}
{code}
{
  "status" : 404,
  "message" : "The requested resource doesn't exist: Stack data, stackName=HDP, stackVersion=HDP-1.0.0"
}
{code}
3. Encapsulate from user messing with return codes, to find out if everything was fine
Is
{code}
  resp =  cluster.delete_host('bad_host')
  
  if resp.status != 200 and resp.status != 201:
    print "Terminating on error"
    return
{code}
Should be:
{code}
  resp =  cluster.delete_host('bad_host')
  
  if resp.is_error():
    print "Terminating on error"
    return
{code}


    
> Ambari Client improve errors handling
> -------------------------------------
>
>                 Key: AMBARI-3244
>                 URL: https://issues.apache.org/jira/browse/AMBARI-3244
>             Project: Ambari
>          Issue Type: Task
>            Reporter: Andrew Onischuk
>            Assignee: Andrew Onischuk
>            Priority: Critical
>             Fix For: 1.4.1
>
>         Attachments: AMBARI-3244_2.patch, AMBARI-3244.patch
>
>
> 1. Add a server error response to the getters and creators
> From the user's side error handling look's like this:
> {code}
>   try:
>     // will fail somewhere during trying to create a host model with corrupt
>     // response
>     host = client.get_host('not existant host')
>   except Exception, ex:
>     print "Unknown termination reason!"
>     return
> {code}
> 2. Some error messages are missed. The problem is that the way we decide, whether error
response is decodable can't be based on the error code
> E.g. 404 can be json as well as html
> {code}
> component = client.get_components('HDP-1.0.0', 'JOBTRACKER')
> {code}
> {code}
> {
>   "status" : 404,
>   "message" : "The requested resource doesn't exist: Stack data, stackName=HDP, stackVersion=HDP-1.0.0"
> }
> {code}
> 3. Encapsulate from user messing with return codes, to find out if everything was fine
> Is
> {code}
>   resp =  cluster.delete_host('bad_host')
>   
>   if resp.status != 200 and resp.status != 201:
>     print "Terminating on error"
>     return
> {code}
> Should be:
> {code}
>   resp =  cluster.delete_host('bad_host')
>   
>   if resp.is_error():
>     print "Terminating on error"
>     return
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message