Healing a component

A heal request targets a component (a resource that is broken) and attempts to return it to an active state.

Before you begin

  • You must create the example assembly instance with an assemblyName of test_1, as described in Creating an assembly instance.
  • To heal the component of an assembly, the assembly to which the component belongs must be in an Active state.

About this task

  • You heal assembly instance components by using the Intents API. For more information about this API, see Intents API.

  • The orchestration component accepts the request to heal without performing any checks first.
  • Heal is a pattern that calls Stop, Start, and then Integrity on the component.
  • If Integrity is successful, then the heal is successful.
  • The assembly containing the broken component must be in the active state to call heal.
  • The request to heal includes the ID of the component in the assembly instance to be healed.

Procedure

  1. To obtain the ID of the component in the assembly instance to be healed, you can query the assembly topology through the Assemblies API using the following GET command:
    Note: You identify the component to be healed by the following combination: The name or ID of the assembly, plus the name or ID of the component.
    GET /api/v1/topology/assemblies?name=test_1
    This query will return assembly topology information including the id in the children section, as depicted in the following sample extract:
    …
      "children": [
        {
          "type": "Component",
          "id": "c903c6db-9a79-4248-b62b-fd11ec01efe0",
          "name": "test_1__A",
          …
    
  2. To initiate a heal pattern from the Intents API, run the following POST command from the swagger-url of the Daytona service. You can use the name or ID as identifier.
    In the following examples, the ID or name obtained in the previous step can be used to define the componentId value, which targets the component to be healed. Any of the following examples will initiate a heal pattern.
    Assembly name and component name
    POST /api/v1/intent/healAssembly 
    {
      "assemblyName": "test_1",
      "brokenComponentName": "test_1__A"
    } 
    
    Assembly name and component ID
    POST /api/v1/intent/healAssembly
    {
      "assemblyName": "test_1",
      "brokenComponentId": "c903c6db-9a79-4248-b62b-fd11ec01efe0"
    } 
    
    Assembly ID and component name
    POST /api/v1/intent/healAssembly
    {
      "assemblyId": "ef4ea879-e313-4e3b-ad11-6a0a7e7544eb",
      "brokenComponentName": "test_1__A"
    } 
    
    Assembly ID and component ID
    POST /api/v1/intent/healAssembly
    {
      "assemblyId": "ef4ea879-e313-4e3b-ad11-6a0a7e7544eb",
      "brokenComponentId": "c903c6db-9a79-4248-b62b-fd11ec01efe0"
    } 
    
    The orchestration component initiates the heal pattern, which cycles through Stop, Start, and Integrity.
  3. Check that the operation completed successfully by querying the process that performed the heal operation.
    For example, to query the last process for the test_1 assembly, run the following command:
    GET /api/v1/processes?assemblyName=test_1&limit=1
    If the status is Completed, the heal operation completed successfully.

Results

The following sample output shows the test_1 assembly with a status of Completed:
	{
		"id": "2114fd60-60c5-4ad3-98ef-fd0097044d45",
		"assemblyId": "c177f293-6072-4f3c-a544-00347cedf897",
		"assemblyName": "test_1",
		"assemblyType": "assembly::dummy::1.0",
		"lifecycleAction": "Heal",
		"intent": {
			"assemblyName": "test_1",
			"brokenComponentId": "183b0c52-f6cd-474c-8ad3-afdf95ed26c6"
		},
		"intentType": "HealAssembly",
		"status": "Completed",
		"startTime": "2022-07-15T14:06:14.775173Z",
		"endTime": "2022-07-15T14:06:17.294087Z",
		"context": {
			"tracectx.transactionid": "91b41695-c7b8-474f-8318-824b98eb70f7",
			"componentId": "183b0c52-f6cd-474c-8ad3-afdf95ed26c6"
		},
		"previousInstance": {...},
		"desiredInstance": {...}
	}