Tom Beerbower created AMBARI-8643:
-------------------------------------

             Summary: Expose Stage and Upgrade Item update status API.
                 Key: AMBARI-8643
                 URL: https://issues.apache.org/jira/browse/AMBARI-8643
             Project: Ambari
          Issue Type: Task
            Reporter: Tom Beerbower
            Assignee: Tom Beerbower
             Fix For: 2.0.0


Upgrade Item state diagram:

{code}                         
    ----------------- HOLDING ------------------------
    | <manual item>                       (release)  |
    |                                                |
    |                                                |
    |                           ----> *ABORTED       |
    |                           |                    |
    |                           |                    v            
**PENDING ---> QUEUED -----> IN_PROGRESS -------> *COMPLETED 
                             ^  | |  |  |                              
                             |  | |  |  
-------------------------------------------
                             |  | |  |                   <hold on err: timeout> 
  |
                             |  | |  -----------------------------------        
  |
                             |  | |           <hold on err: failed>    |        
  |
                             |  | v                                    v        
  |
                             |  | FAILED* <-------------- HOLDING_FAILED 
-------  |
                             |  v               (skip)                         
|  |
                             |  TIMED_OUT* <------------- HOLDING_TIMED_OUT 
-->|  |
                             |                                      ^          
|  |
                             |                                      |          
|  |
                             |                                      
-----------|---
                             |                  (retry)                        |
                             ---------------------------------------------------
             
             ** starting state                   
             *  terminal states 
{code}

Notes:
* The HOLDING, HOLDING_FAILED, HOLDING_TIMED_OUT states are new.
* An item in the HOLDING state can be completed by pushing its state to the 
COMPLETED state through the API (see below).  This will make the next stage 
become the current stage and advance from the PENDING state.
* An item in the HOLDING_FAILED state can be skipped by pushing its state to 
FAILED state through the API.  This will make the next stage become the current 
stage and advance it from the PENDING state.
* An item in the HOLDING_FAILED state can be retried by pushing its state to 
IN_PROGRESS state through the API.  This will keep the stage as the current 
stage and retry the associated tasks.
* An item in the HOLDING_TIMED_OUT state can be skipped by pushing its state to 
TIMED_OUT state through the API.  This will make the next stage become the 
current stage and advance it from the PENDING state.
* An item in the HOLDING_TIMED_OUT can be retried by pushing its state to 
IN_PROGRESS state through the API.  This will keep the stage as the current 
stage and retry the associated tasks.


Updated Proposed API changes:


# Determine if an upgrade is holding by checking the upgrade resource's status.
{code}
GET api/v1/upgrades/1
{
  "href" : "http://c6401.ambari.apache.org:8080/api/v1/upgrades/1";,
  "Upgrade" : {
    ...
    "request_status" : "HOLDING",
    ...
}
{code}
# To find the upgrade item that is holding for a given upgrade look for the 
upgrade item that has a status of HOLDING.  Only the current stage should ever 
be in the HOLDING state.
{code}
GET api/v1/upgrades/1?upgrade_items/UpgradeItem/status=HOLDING

{
  "href" : 
"http://c6401.ambari.apache.org:8080/api/v1/upgrades/1?upgrade_items/UpgradeItem/status=HOLDING";,
  "Requests" : {
    "id" : 1
  },
  "upgrade_items" : [
    {
      "href" : 
"http://c6401.ambari.apache.org:8080/api/v1/upgrades/1/upgrade_items/10";,
      "UpgradeItem" : {
        "request_id" : 1,
        "stage_id" : 10,
        "status" : "HOLDING"
      }
    }
  ]
}
{code}
# To release the hold on a upgrade, complete the the stage that is holding by 
setting it's status to COMPLETED.
{code}
PUT api/v1/upgrades/1/upgrade_items/10

{
  "UpgradeItem" : {
    "status" : "COMPLETED"
  }
}
{code}
# A stage may be marked as 'hold on error' which gives the opportunity to skip 
or retry a failure/timeout.  If an error occurs while executing the taks of a 
'hold on error' upgrade item its status will be set to HOLDING_FAILED or 
HOLDING_TIMED_OUT.  To retry the upgrade item, set its status back to to 
IN_PROGRESS.
{code}
PUT api/v1/upgrades/1/upgrade_items/10

{
  "UpgradeItem" : {
    "status" : "IN_PROGRESS"
  }
}
{code}
# A stage item that is HOLDING_FAILED or HOLDING_TIMED_OUT may be skipped.  To 
skip an item that is in error and holding,  set its status back to to FAILED 
(for HOLDING_FAILED) or TIMED_OUT (for HOLDING_TIMED_OUT).
{code}
PUT api/v1/upgrades/1/upgrade_items/10

{
  "UpgradeItem" : {
    "status" : "FAILED"
  }
}
{code}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to