Hi,
I have AWS Java SDK 2.x based code in a Docker container which attempts to run a Fargate task (its own task definition with an overridden command).
I see runTask() being invoked and requests being logged in CloudWatch:
11:43:43
Starting process for item ID: CE5K55ARX
11:43:43
2019-08-16 11:43:43 [main] DEBUG software.amazon.awssdk.request:84 - Sending Request: DefaultSdkHttpFullRequest(httpMethod=POST, protocol=https, host=ecs.us-west-2.amazonaws.com, encodedPath=/, headers=[amz-sdk-invocation-id, Content-Length, Content-Type, User-Agent, X-Amz-Target], queryParameters=[])
However, nothing else happens after that - completed() is never called and does not log the debug message, CloudWatch does not show any logs for the sub-tasks. Looks like execution is requested but sub-tasks are not run, and I don't know where to look for what goes wrong.
The task runs fine on its own, it's just the execution of sub-tasks from SDK that I'm having trouble with.
Here's the code:
public void runTask(Item item)
{
System.out.println("Starting process for item ID: " + item.getId());
TaskOverride cmdOverride = TaskOverride.builder().
containerOverrides(ContainerOverride.builder().
name("some-container"). // dummy name
command("--item",item.getId()). // dummy command
build()).
build();
AwsVpcConfiguration avc = AwsVpcConfiguration.builder().
securityGroups("default").
subnets("subnet-0728a262").
assignPublicIp(AssignPublicIp.ENABLED).
build();
NetworkConfiguration nc = NetworkConfiguration.builder().
awsvpcConfiguration(avc).
build();
RunTaskRequest task = RunTaskRequest.builder().
launchType(LaunchType.FARGATE).
taskDefinition("arn:aws:ecs:us-east-1:XXXXXXXXXXX:task-definition/some-def"). // dummy name
cluster("some-cluster"). // dummy name
count(1).
networkConfiguration(nc).
overrides(cmdOverride).
enableECSManagedTags(false).
startedBy(item.getId()).
build();
ecsClient.runTask(task).whenComplete(completed());
}
public static BiConsumer<RunTaskResponse, Throwable> completed()
{
return (RunTaskResponse resp, Throwable t) ->
{
System.out.println("completed()");
if (resp != null) System.out.println("Tasks completed: " + resp.tasks());
if (t != null) System.out.println("Task error: " + t);
};
}
Any help is appreciated.
Edited by: Zaliakalnis on Aug 16, 2019 5:07 AM
Edited by: Zaliakalnis on Aug 16, 2019 5:17 AM