AWS Task not stopped if the pipeline was cancelled by the user before the ARN is persisted in the metadata
Currently when a pipeline is started, the following steps are executed by the "prepare" stage of the driver:
- Start a Fargate task
- Wait the Fargate task to be running
- Persist the Fargate task ARN and IP for use when the run and cleanup commands are executed
The problem occurs when the user manually cancels the pipeline before the ARN is persisted in the JSON file.
In this case, the runner will execute the cleanup command that won't find the ARN of the Fargate Task to stop. So the Fargate Task will remain running.
To minimize the chance of this problem, we could persist the ARN right after the "start task" command.
I.e:
- Start a Fargate task
- Persist JSON with ARN
- Wait the Fargate task to be running
- Update JSON adding the container IP