Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug that can't create fifo queue in SQS. #323

Merged
merged 1 commit into from
Nov 30, 2016

Conversation

ebihara99999
Copy link
Contributor

About the bug

Trying to create FIFO queue following the document, the error occurs (ommited some lines):

/path/to/vendor/bundle/ruby/2.3.0/gems/excon-0.54.0/lib/excon/middlewares/expects.rb:7:in `response_call': Expected(200) <=> Actual(400 Bad Request) (Excon::Error::BadRequest)

InvalidParameterValue Can only include alphanumeric characters, hyphens, or underscores. 1 to 80 in length

The script is

require 'fog/aws'

sqs = Fog::AWS::SQS.new region: "us-west-2"
sqs.create_queue(name="FifoQueue.fifo", {"Attribute.1.Name" => "FifoQueue" , "Attribute.1.Value" => "true"})

How to fix

The error says a queue name can't include '.' but fifo queue needs the '.fifo' suffix.
The version of query api fog-awe uses in SQS is behind from the latest and doesn't support the fifo queue (or more exactly, the old version doesn't support a queue name including '.', which doesn't necessarily mean whether it supports FIFO queue).
I changed the version from 2009-02-01 into 2012-11-05, and the error doesn't show up.

Testing

Executed bundle exec shindo tests/requests/sqs. Results are all green.

@ebihara99999
Copy link
Contributor Author

Considering mocks, it seems I should've created kind of #create_fifo_queue....
You can see the "FifoQueue": "true" attribute when get api.
Or in mock, I should've added conditional statements judging whether it's a fifo queue.
I would appreciate if someone would comment.

@lanej
Copy link
Member

lanej commented Nov 28, 2016

@ebihara99999 i can't speak to your specific fifo queue issue but I can confirm that upgrading the version does work correctly. Could you link a specific references of #create_fifo_queue ?

@ebihara99999
Copy link
Contributor Author

ebihara99999 commented Nov 30, 2016

@lanej Sorry for a confusing report and comment.

Let me rephrase the bug:

  • A FIFO queue name needs to have the .fifo suffix.
  • The old version doesn't support a queue name including '.' (as mentioned above).
  • I judged it is a bug in creating a FIFO queue, not a bug of depending on an old version api.

And I added the comment, if it's a bug about FIFO queue, because

  • I think I should've modified Mock.create_queue.

  • But the api sets the FifoQueue attribute as follows:

    • When it's a FIFO queue, FifoQueue is true.
    • When it's NOT a FIFO queue, the FifoQueue attribute doesn't exist in the attribute. Confirming with AWS CLI,
    $ SQS_QUEUE_URL="URL of NOT a fifo queue"
    
    $ aws sqs get-queue-attributes --queue-url ${SQS_QUEUE_URL} --attribute-names FifoQueue
    An error occurred (InvalidAttributeName) when calling the GetQueueAttributes operation: Unknown Attribute FifoQueue.
    $ SQS_QUEUE_URL="URL of a FIFO queue"
    $ aws sqs get-queue-attributes --queue-url ${SQS_QUEUE_URL} --attribute-names FifoQueue
    {
        "Attributes": {
            "FifoQueue": "true"
        }
    }
  • Considering this, I have no idea how to integrate the FifoQueue attribute into the existing Mock.create_queue, and I left the comment (Creating '#create_fifo_queue' would solve the problem).

@lanej
Copy link
Member

lanej commented Nov 30, 2016

@ebihara99999 thanks for the clarification. This section of the codebase has no object modeling and the request options are freeform. You would create a fifo queue by calling:

sqs.create_queue 'queue.fifo', 'FifoQueue' => true

Bumping the API version is definitely required.

@lanej lanej merged commit 9640d7a into fog:master Nov 30, 2016
@ebihara99999 ebihara99999 deleted the fix_the_bug_of_fifo_queue branch December 5, 2016 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants