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

RDS: lowercase the DBInstanceIdentifier #8564

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

snordhausen
Copy link
Contributor

Various RDS API calls treat the DBInstanceIdentifier as lowercase / case insensitive.

Documentation for create_db_instance says:
DBInstanceIdentifier [...] This parameter is stored as a lowercase string.

Documentation for describe_db_instances says:
DBInstanceIdentifier [...] This parameter isn’t case-sensitive.

Documentation for modify_db_instance says:
DBInstanceIdentifier [...] This value is stored as a lowercase string.
NewDBInstanceIdentifier [...] This value is stored as a lowercase string.

Documentation for delete_db_instance says:
DBInstanceIdentifier [...] This parameter isn’t case-sensitive.

Various RDS API calls treat the DBInstanceIdentifier as
lowercase / case insensitive.

Documentation for `create_db_instance` says:
`DBInstanceIdentifier [...] This parameter is stored as a lowercase string.`
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds/client/create_db_instance.html

Documentation for `describe_db_instances` says:
`DBInstanceIdentifier [...] This parameter isn’t case-sensitive.`
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds/client/describe_db_instances.html

Documentation for `modify_db_instance` says:
`DBInstanceIdentifier [...] This value is stored as a lowercase string.`
`NewDBInstanceIdentifier [...] This value is stored as a lowercase string.`
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds/client/modify_db_instance.html

Documentation for `delete_db_instance` says:
`DBInstanceIdentifier [...] This parameter isn’t case-sensitive.`
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds/client/delete_db_instance.html
@snordhausen
Copy link
Contributor Author

I'll take a look at the test failures a bit later.

...also for create_db_instance_read_replica().

Documentation for `create_db_instance_read_replica` says:
`DBInstanceIdentifier [...] This parameter is stored as a lowercase string.`
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds/client/create_db_instance_read_replica.html
...for reboot_db_instance(). This already works because the backend
just calls describe_db_instances() which already uses lower case.
...for promote_read_replica.

Documentation for `promote_read_replica` says:
DBInstanceIdentifier [...] This value is stored as a lowercase string.
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds/client/promote_read_replica.html
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.65%. Comparing base (98e2730) to head (daf8992).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8564      +/-   ##
==========================================
- Coverage   92.65%   92.65%   -0.01%     
==========================================
  Files        1231     1231              
  Lines      106851   106853       +2     
==========================================
  Hits        99005    99005              
- Misses       7846     7848       +2     
Flag Coverage Δ
servertests 28.13% <20.00%> (-0.01%) ⬇️
unittests 92.62% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@bpandola bpandola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snordhausen There is a larger issue here, in that all of the RDS models (DBInstance, DBCluster, DBSnapshot, etc.) have case-insensitive identifiers, so I think we need a higher-level solution. Peppering .lower() throughout the code is messy, and it's too easy to miss a spot. We definitely want to handle this at the boundaries and not indiscriminately throughout the code. For example, we could store the identifiers in a case-insensitive dict, we can add a parameter to the filter configuration(s) to indicate if a comparison should be case-insensitive, etc.

If you'd like to consider this a bit more and propose another solution, feel free. If the increased scope is not something you want to tackle, I can add it to my TODO list (as I am currently in the process of refactoring the RDS backend and adding lots of new features).

@snordhausen
Copy link
Contributor Author

@bpandola What do you think about doing it like this? That lower-cases the DBInstanceIdentifier before it gets in contact with any backend logic and replaces the old code.

I think it can be extended for the other cases you mentioned, e.g. with a for-loop in QueryParser.parse() that lower-cases various keys.

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