Olesya
Olesya

Reputation: 382

Erroneous Aws::ECS::Errors::ClusterNotFoundException — what is happening?

I have an ECS cluster, an active service for it, and a task for this service. I am trying to call ListTasks with Ruby AWS SDK.

When there is no active task, it comes through with an empty list, as expected. But when there is a running task, I get the Aws::ECS::Errors::ClusterNotFoundException.

I tried calling ListClusters, and got a successful response: {:cluster_arns=>["arn:aws:ecs:<region>:<account_num>:cluster/<cluster_name>"], :next_token=>nil}.

I also tried calling DescribeServices, and got a successful response as well: {:clusters=>[{:cluster_arn=>"arn:aws:ecs:<region>:<account_num>:cluster/<cluster_name>", :cluster_name=>"<cluster_name>", :status=>"ACTIVE", :registered_container_instances_count=>0, :running_tasks_count=>1, :pending_tasks_count=>0, :active_services_count=>1, :statistics=>[], :tags=>[], :settings=>[{:name=>"containerInsights", :value=>"enabled"}], :capacity_providers=>["FARGATE_SPOT", "FARGATE"], :default_capacity_provider_strategy=>[{:capacity_provider=>"FARGATE", :weight=>1, :base=>0}], :attachments=>nil, :attachments_status=>nil}], :failures=>[]}.

In addition, I regularly call DescribeServices and UpdateService for the same cluster name successfully.

But the error persists for ListTasks.

Has anyone encountered something similar? What do you think is happening?

UPD The code that generates the error:

@@ecs_client = Aws::ECS::Client.new(
  region: Aws.config[:region],
  access_key_id: Aws.config[:credentials].access_key_id,
  secret_access_key: Aws.config[:credentials].secret_access_key
)

...

tasks = @@ecs_client.list_tasks({ cluster: '<cluster_name>' })

Upvotes: 0

Views: 459

Answers (1)

once
once

Reputation: 1399

If you do not specify a cluster when calling the "ListTasks" API, the "default" cluster is assumed. Also, double check the region used in your script.

Upvotes: 0

Related Questions