amazon-archives/aws-sdk-core-ruby

Inconsistent responses from ECS endpoints

Closed this issue · 2 comments

I'm seeing inconsistent behaviour when using the SDK for talking to the ECS endpoints. The values returned by some methods are not accepted as values in others that, in theory, should accept them. This is exemplified below, where an attempt to discover the task definition ARN currently in use by a running service is made.

Initial setup:

irb(main):001:0> require 'aws-sdk'
=> true
irb(main):002:0> require 'aws-sdk-core'
=> false
irb(main):003:0> require 'aws-sdk-resources'
=> false
irb(main):004:0>
irb(main):005:0* client = Aws::ECS::Client.new(region: 'us-east-1')
=> #<Aws::ECS::Client>

Get the service ARN from a given cluster:

irb(main):006:0> service_arn = client.list_services(cluster: 'my-cluster').service_arns[0]
=> "arn:aws:ecs:us-east-1:123456789012:service/my-service"

(FAILURE) Describe service using ARN from above:

irb(main):007:0> cluster = client.describe_services(services: [service_arn])
=> #<struct Aws::ECS::Types::DescribeServicesResponse services=[], failures=[#<struct Aws::ECS::Types::Failure arn="arn:aws:ecs:us-east-1:123456789012:service/my-service", reason="MISSING">]>

In this response, I see the ARN I provided and the reason set to MISSING. But what exactly is missing from the query? API docs state services: is the only required param.

Am I holding it the wrong way?

Using SDK 2.1.8.

Original title changed because that was a side-effect of trying to diagnose the problem above. Original error was an ArgumentError from the SDK when attempting to describe a cluster:

irb(main):001:0> require 'aws-sdk'
=> true
irb(main):002:0> require 'aws-sdk-core'
=> false
irb(main):003:0> require 'aws-sdk-resources'
=> false
irb(main):004:0>
irb(main):005:0* client = Aws::ECS::Client.new(region: 'us-east-1')
=> #<Aws::ECS::Client>
irb(main):006:0> client.describe_clusters(cluster: ['my-cluster'])
ArgumentError: unexpected value at params[:cluster]
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.8/lib/aws-sdk-core/param_validator.rb:26:in `validate!'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.8/lib/aws-sdk-core/param_validator.rb:11:in `validate!'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.8/lib/aws-sdk-core/plugins/param_validator.rb:20:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.8/lib/seahorse/client/plugins/raise_response_errors.rb:14:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.8/lib/aws-sdk-core/plugins/param_converter.rb:21:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.8/lib/seahorse/client/plugins/response_target.rb:21:in `call'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.8/lib/seahorse/client/request.rb:70:in `send_request'
    from /Library/Ruby/Gems/2.0.0/gems/aws-sdk-core-2.1.8/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
    from (irb):6
    from /usr/bin/irb:12:in `<main>'
irb(main):007:0>

Have also attempted to describe the cluster using its ARN, with the same result.

To answer my own question: you should always specify cluster when calling #describe_services. Otherwise it defaults to default and you'll most likely not find your service ARN in there (if you deleted the default ECS cluster).