stopTask method
Stops a running task. Any tags associated with the task will be deleted.
When you call StopTask on a task, the equivalent of
docker stop is issued to the containers running in the task.
This results in a stop signal value and a default 30-second timeout, after
which the SIGKILL value is sent and the containers are
forcibly stopped. This signal can be defined in your container image with
the STOPSIGNAL instruction and will default to
SIGTERM. If the container handles the SIGTERM
value gracefully and exits within 30 seconds from receiving it, no
SIGKILL value is sent.
For Windows containers, POSIX signals do not work and runtime stops the
container by sending a CTRL_SHUTDOWN_EVENT. For more
information, see Unable to react to
graceful shutdown of (Windows) container #25982 on GitHub.
May throw AccessDeniedException.
May throw ClientException.
May throw ClusterNotFoundException.
May throw InvalidParameterException.
May throw ServerException.
Parameter task :
Thefull Amazon Resource Name (ARN) of the task.
Parameter cluster :
The short name or full Amazon Resource Name (ARN) of the cluster that
hosts the task to stop. If you do not specify a cluster, the default
cluster is assumed.
Parameter reason :
An optional message specified when a task is stopped. For example, if
you're using a custom scheduler, you can use this parameter to specify the
reason for stopping the task here, and the message appears in subsequent
DescribeTasks>
API operations on this task.
Implementation
Future<StopTaskResponse> stopTask({
required String task,
String? cluster,
String? reason,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AmazonEC2ContainerServiceV20141113.StopTask'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'task': task,
if (cluster != null) 'cluster': cluster,
if (reason != null) 'reason': reason,
},
);
return StopTaskResponse.fromJson(jsonResponse.body);
}