Skip to content

dynamoDB result backend incorrect exception handling when table exists #6622

Closed

Description

@raffienficiaud

The following code

error_code = e.response['Error'].get('Code', 'Unknown')

tries to create or get the table. In case the table exists and the role executing that code on AWS does not have the CreateTable permission, the raised exception is not the one expected by that particular line. Yet the table exists and the exception is raised because the code tries to create it while lacking permissions.

To reproduce:

  • celery 5.0.5
  • create the result backend table and give the following permissions to the role executing celery on that table:
   "dynamodb:DescribeTable",
   "dynamodb:PutItem",
   "dynamodb:UpdateItem",
   "dynamodb:DeleteItem",
   "dynamodb:BatchWriteItem",
   "dynamodb:GetItem",
   "dynamodb:BatchGetItem",
   "dynamodb:Scan",
   "dynamodb:Query",
   "dynamodb:ConditionCheckItem"
  • remove the permission CreateTable from the role executing the code

Possible solution:

  • handle the check of the table existence with another boto3 call such as describe_table and then fall-back into the table creation
  • provide a configuration that, when indicated, assumes the existence of the table
  • handle that exception differently

Activity

  1. changed the title [-]dynamoDB result backend tries to create tables while role does not permit[/-] [+]dynamoDB result backend incorrect exception handling when table exists[/+] on Jan 30, 2021
  2. auvipy commented on Feb 1, 2021

    @auvipy
    Member

    Possible solution:

    * handle the check of the table existence with another boto3 call such as [`describe_table`](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html#DynamoDB.Client.describe_table) and then fall-back into the table creation
    
    * provide a configuration that, when indicated, assumes the existence of the table
    
    * handle that exception differently
    

    I am no expert on dynamo DB. But if you can come with a change request as your proposed possible solutions we could verify & help to improve.

  3. thedrow commented on Apr 1, 2021

    @thedrow
    Contributor

    @galCohen88 can you try to fix this?

  4. added this to the Future milestone on Sep 16, 2021
  5. modified the milestones: Future, 5.3 on Aug 16, 2022
  6. auvipy commented on Aug 16, 2022

    @auvipy
    Member

    @lyajedi let's continue here

  7. raffienficiaud commented on Aug 31, 2022

    @raffienficiaud
    Author

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions