Skip to content

Fix/aws rds refactor - #3069

Merged
centosinfra-prod-github-app[bot] merged 18 commits into
ansible-collections:mainfrom
Romi1495:fix/aws_rds_refactor
Sep 1, 2026
Merged

centosinfra-prod-github-app[bot] merged 18 commits into
ansible-collections:mainfrom
Romi1495:fix/aws_rds_refactor

Conversation

@Romi1495

Copy link
Copy Markdown
Contributor
SUMMARY

Refactor rds_cluster_param_group module to align error handling with patterns established in #2119 and
#2138. Part of #2003.

ISSUE TYPE

Refactoring Pull Request

COMPONENT NAME

rds_cluster_param_group
module_utils/_rds/api.py
module_utils/_rds/common.py

ADDITIONAL INFORMATION

module_utils/_rds/common.py:

  • Add DBParameterGroupNotFound to RDSErrorHandler._is_missing() error code list

module_utils/_rds/api.py:

  • Refactor describe_db_cluster_parameter_groups() to use @RDSErrorHandler.list_error_handler decorator
    instead of manual try/except with is_boto3_error_code
  • Refactor describe_db_cluster_parameters() to use @RDSErrorHandler.list_error_handler decorator
    instead of manual try/except with is_boto3_error_code

rds_cluster_param_group module:

  • Add PEP 257 docstrings to modify_parameters(), ensure_present(), and ensure_absent() functions

Assisted by Claude opus 4.6

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

Comment thread plugins/module_utils/_rds/common.py Outdated
Comment thread plugins/modules/rds_cluster_param_group.py Outdated
Comment thread plugins/modules/rds_cluster_param_group.py Outdated
Comment thread plugins/module_utils/_rds/api.py Outdated
Comment thread plugins/module_utils/_rds/api.py
Comment thread changelogs/fragments/rds_cluster_param_group-refactor.yml Outdated

@oraNod oraNod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apart from any remaining formatting and other issues that @chynasan pointed out the rest LGTM. Thanks @Romi1495

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/ansible-collections/amazon.aws for 3069,5df79b3a09bab7dc2709ae088d00a90bd77d6257

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/ansible-collections/amazon.aws for 3069,2f907fba961c635028af422e04a26db024e4a342

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/ansible-collections/amazon.aws for 3069,4903bf110013a2d4d0b9d3b96875b3e73e8d84d2

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.
Warning:
Error merging github.com/ansible-collections/amazon.aws for 3069,c3f5c33a429aed053f1186e694d46417e3649e16

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

Comment thread plugins/modules/rds_cluster_param_group.py Outdated
Comment thread plugins/modules/rds_cluster_param_group.py Outdated
Comment thread plugins/modules/rds_cluster_param_group.py
Comment thread plugins/modules/rds_cluster_param_group.py Outdated
Romi1495 added a commit to Romi1495/amazon.aws that referenced this pull request Aug 27, 2026
Addresses Alina's review comments on PR ansible-collections#3069: the create/delete/modify
db_cluster_parameter_group boto3 calls now go through module_utils/_rds/api.py
behind RDSErrorHandler, matching the existing convention for other RDS calls
in this file, instead of using local try/except blocks. The parameter
comparison loop is extracted into a local _get_changed_parameters() helper
in the module.
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@GomathiselviS GomathiselviS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please run black and isort locally. This will fix the sorting and the trailing whitespace issues. (https://github.com/ansible-collections/cloud-content-handbook/blob/main/TeamPractices/Guidelines/coding_guidelines.md#automated-checks)

Comment thread changelogs/fragments/rds_cluster_param_group-refactor.yml Outdated
Comment thread plugins/module_utils/_rds/common.py Outdated
Comment thread plugins/module_utils/_rds/common.py Outdated
Comment thread plugins/module_utils/_rds/api.py

@mandar242 mandar242 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some of the commits look unsigned, other than that lgtm! Probably a rebase with signed commit would help

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

Romi1495 and others added 6 commits August 31, 2026 11:11
Addresses Alina's review comments on PR ansible-collections#3069: the create/delete/modify
db_cluster_parameter_group boto3 calls now go through module_utils/_rds/api.py
behind RDSErrorHandler, matching the existing convention for other RDS calls
in this file, instead of using local try/except blocks. The parameter
comparison loop is extracted into a local _get_changed_parameters() helper
in the module.
Co-authored-by: GomathiselviS <gomathiselvi@gmail.com>
Co-authored-by: GomathiselviS <gomathiselvi@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Romi1495
Romi1495 force-pushed the fix/aws_rds_refactor branch from aca284a to 7cb49d5 Compare August 31, 2026 16:14
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@Romi1495
Romi1495 requested review from mandar242 and oraNod September 1, 2026 17:50
Run black and isort on the RDS refactor files to address review
feedback on import sorting and trailing whitespace.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

Comment thread plugins/modules/rds_cluster_param_group.py Outdated
Co-authored-by: GomathiselviS <gomathiselvi@gmail.com>
@Romi1495 Romi1495 added the mergeit Merge the PR (SoftwareFactory) label Sep 1, 2026
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app
centosinfra-prod-github-app Bot merged commit 8d634a0 into ansible-collections:main Sep 1, 2026
11 of 21 checks passed
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

mandar242 added a commit to mandar242/amazon.aws that referenced this pull request Sep 10, 2026
Continues the migration started in ansible-collections#3069, following ansible-collections#2119 and ansible-collections#2138.
Behaviour-preserving.

- Normalize describe_db_cluster_parameter_groups() and
  describe_db_cluster_parameters() to the shared (client, **params) signature,
  dropping the unused `module` argument.
- Drop the redundant botocore import and module.client() try/except, and catch
  AnsibleRDSError once at the module boundary in main().
- Split ensure_present() into smaller documented helpers, and reuse the group
  returned by the create call instead of describing it again. Both API calls
  return the same DBClusterParameterGroup shape, so output is unchanged.
- Index the current parameters by name when comparing them against the
  requested ones.
- Add unit tests for the shared helpers and both modules.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
centosinfra-prod-github-app Bot pushed a commit that referenced this pull request Sep 14, 2026
…ies (#3089)

SUMMARY
Refactors rds_cluster_param_group onto the shared module_utils/rds utilities, continuing the migration started in #3069 and following the patterns established by #2119 (shared boto3 client helpers and error handling) and #2138 (shared describe_* functions).
This is intended to be a pure refactor, no behaviour change.
module_utils/_rds/api.py

describe_db_cluster_parameter_groups() and describe_db_cluster_parameters() now take (client, **params) like every other describe_* helper in the module. Both previously took a module argument that became completely unused once #3069 replaced their manual try/except blocks with the @RDSErrorHandler.list_error_handler decorator. Filter construction moves to the callers, which is where the module params live.
Renamed the connection argument to client in the cluster parameter group create/delete/modify helpers, for consistency with the rest of the file.

rds_cluster_param_group

Dropped the botocore import and the try/except around module.client(). AnsibleAWSModule already handles connection failures, so this was dead code. The client-level retry_decorator is kept, matching #3072.
AnsibleRDSError raised by the shared helpers is now caught once at the module boundary in main().
Split ensure_present() into get_parameter_group(), create_parameter_group() and update_parameter_group(), with type hints and Google-style docstrings throughout.
Reuse the parameter group returned by the create call instead of re-describing it, removing a redundant describe_db_cluster_parameter_groups() call. CreateDBClusterParameterGroup and DescribeDBClusterParameterGroups return the same DBClusterParameterGroup shape in the botocore service model, so the module output is unchanged.
Index the current parameters by name when comparing them against the requested ones, instead of scanning the full list once per requested parameter.

rds_cluster_param_group_info

Adopted the new describe helper signatures and dropped the same redundant botocore import and connection try/except.

ISSUE TYPE

Refactoring Pull Request

COMPONENT NAME
rds_cluster_param_group
rds_cluster_param_group_info
module_utils/_rds/api.py
ADDITIONAL INFORMATION
Behaviour
Everything is intended to be behaviour-preserving: the returned db_cluster_parameter_group keys, the parameter validation failure messages (Could not find parameter with name: ... and The parameter ... cannot be modified, still raised via module.fail_json() so they keep their exact text), the set of parameters sent to ModifyDBClusterParameterGroup, the tags: {} no-op, the check mode early exit and its message, idempotency, and the "does not exist" message on state=absent are all unchanged.
The only externally observable difference is one fewer DescribeDBClusterParameterGroups call on the create path.
Testing

New unit tests: tests/unit/plugins/modules/test_rds_cluster_param_group.py (21 tests) and tests/unit/plugins/modules/test_rds_cluster_param_group_info.py (4 tests), plus 10 tests in test_rds_api.py covering the shared cluster parameter group helpers, which had no unit coverage before.
Full RDS unit suite passes (852 tests).
ansible-test sanity passes on all changed files.
Existing integration tests under tests/integration/targets/rds_cluster_param_group are unchanged and each assertion was traced against the new code paths, but they have not been run against live AWS in this branch. A CI run would be good confirmation.


Assisted-by: Claude Opus 5

Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Don Naro <dnaro@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergeit Merge the PR (SoftwareFactory)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants