Updated on 2023-08-14 GMT+08:00

Executing a Stack Lifecycle

Function

This API is used to perform lifecycle operations for a specific stack.

URI

PUT /v2/stacks/{stack_id}/actions

Table 1 Parameter description

Parameter

Mandatory

Description

stack_id

Yes

Stack ID, which has a length of 1 to 64 characters

Request

  • Request parameters

    The request parameters are applicable only to scenarios where the rollback fails.

    Table 2 Request parameters

    Parameter

    Mandatory

    Type

    Description

    failure_strategy

    No

    String

    Failure strategy. The default value is DoNothing. The value can be DoNothing or Rollback.

    nodes

    No

    Array of objects

    For details about parameters of a stack element lifecycle, see Table 3.

    timeout

    No

    Integer

    Lifecycle timeout period (in minutes). The default value is 60 minutes. This value has a length of 0 to 1440 minutes (a maximum of one day, that is, 24 x 60 minutes).

    lifecycle

    Yes

    String

    Lifecycle name

    The value can be create, delete, upgrade, rollback, or retry.

    inputs

    No

    String

    The stack configuration parameters need to be specified during the upgrade. Each key-value structure represents an input and corresponds to the inputs in the template.

    template_id

    No

    String

    Uses the new template to execute the lifecycle.

    1. Only the inputs upgrade mode is supported during the upgrade.

    2. The failure_strategy parameter supports rollback only in the lifecycle of create.

    3. The agent, job, DynamicVolume, FlexVolume, DynamicNodePool, NodePool, and AutoScaler elements do not support upgrade or reinstallation upon installation failure.

    Table 3 Node parameters

    Parameter

    Mandatory

    Type

    Description

    name

    Yes

    String

    Node name

    parameters

    No

    Object

    Node lifecycle parameters, in which ScaleParams parameters (Table 4) are used for the scaling operations.

    Table 4 Scaling parameters

    Parameter

    Mandatory

    Type

    Description

    instances

    Yes

    Integer

    Number of nodes. The value ranges from 0 to 100.

    Scaling lifecycle is supported only for stateless applications whose number of instances is defined in inputs. If the inputs section is shared by multiple applications, the scale operation is supported only when all these applications are scaled at the same time.

  • Creation request example
    {
        "lifecycle": "create",
        "timeout": 20,
        "failure_strategy": "Rollback"
    }
  • Rollback request example
    {
        "lifecycle": "rollback"
    }
  • Configuration parameter upgrade request example
    {
        "lifecycle": "upgrade",
        "inputs": {
            "param1": "value1"
        }
    }
  • Retry request example
    {
        "lifecycle": "retry",
        "timeout": 20
    }

Response

  • Response parameters
    Table 5 Response parameters

    Parameter

    Type

    Description

    action_id

    String

    Execution record ID

    last_action_id

    String

    Record ID of the previous execution

  • Example response
    {
        "action_id" : "string",
        "last_action_id" : "string",
    }

Status Code

  • Normal
    Table 6 Status code

    Status Code

    Description

    200

    Executing the stack lifecycle is successful.

  • Abnormal
    Table 7 Status code

    Status Code

    Description

    400

    The request parameter is incorrect.

    404

    The stack or the element does not exist.

    500

    The server fails to process the request due to an unexpected condition.