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

route53: fix CAA record ordering for idempotency #46049

Merged
merged 3 commits into from
Sep 27, 2018

Conversation

felixfontein
Copy link
Contributor

SUMMARY

As reported in #45970, the CAA records returned by boto are sometimes in the order in which they were set, but sometimes not. (This also seems to depend on whether Py2 or Py3 is used. This problem is probably either caused by boto or sax, or by the Route53 API itself.)

This sorts CAA records before comparison, but restores the order in case the record set is finally created or updated via boto.

The PR allows to extend the set of records for which sorting is done by updating the line need_to_sort_records = (type_in == 'CAA') to something like need_to_sort_records = (type_in in ('CAA', 'another type')). I don't know if this is required for other record types as well. Someone more knowledgable of DNS might be able to comment on this.

Fixes #45970.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

route53

ANSIBLE VERSION
2.7.0

@ansibot
Copy link
Contributor

ansibot commented Sep 23, 2018

Hi @felixfontein,

Thank you for the pullrequest, just so you are aware we have a dedicated Working Group for aws.
You can find other people interested in this in #ansible-aws on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 aws bug This issue/PR relates to a bug. cloud core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 23, 2018
@@ -593,13 +600,14 @@ def main():
identifier_in = str(identifier_in)

if rset.type == type_in and decoded_name.lower() == record_in.lower() and rset.identifier == identifier_in:
if need_to_sort_records:
# Sort records
rset.resource_records = sorted(rset.resource_records)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand what this changes, as line 621 just sorts the resource records again whether or not need_to_sort_records is true or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This changes the rset object itself; it's needed because the comparison is done in line 621 between rset and wanted_rset. All the other lines (i.e. putting stuff into record) is done only for state == 'get' if I understand it correctly, and not used anywhere else (in particular, not for comparison).

I kept the sorting in line 621 because that used to be done for all record types (but as I said, it is only used for state == 'get'); I could have only sorted again if it wasn't sorted here already, but I thought that would make it unnecessary complex.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I nearly wrote another comment about how I still don't understand but I got there while writing it :)

@willthames
Copy link
Contributor

This change looks good to me from a code review point of view but I haven't tested it and there is no test suite for route53.

If someone else can give a second opinion, that would be great.

@ryansb ryansb removed the needs_triage Needs a first human triage before being processed. label Sep 25, 2018
@ryansb
Copy link
Contributor

ryansb commented Sep 26, 2018

Hi @felixfontein, I've taken some time to add an integration test that reproduces the CAA issue (but doesn't cover much else) to your fix here. It's a start on the test suite, but for now will not be running in CI. I had a couple other feedback items, but after that I think this is good to go.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Sep 26, 2018
@felixfontein
Copy link
Contributor Author

@ryansb Thanks a lot for the tests! Out of curiosity: I've seen that the route53_zone tests runs on CI. Is there a reason the new tests won't be run there (yet)?

@ryansb
Copy link
Contributor

ryansb commented Sep 27, 2018

Mostly the reason is that those are for zones, and the current CI policy doesn't have permissions to update records and such, which would be required for these tests.

@felixfontein
Copy link
Contributor Author

Ah, that makes sense. Thanks!

@ryansb ryansb merged commit a727a1e into ansible:devel Sep 27, 2018
@felixfontein
Copy link
Contributor Author

@willthames @ryansb thanks for reviewing, adding the tests and merging!

Should I create backports for it (2.7 and 2.6)?

@felixfontein felixfontein deleted the route53-fix-caa-ordering branch September 27, 2018 19:11
@ryansb
Copy link
Contributor

ryansb commented Sep 27, 2018

Backports would be great, but when you do, strip out the new integration tests. I don't want to break past integration suites.

@felixfontein
Copy link
Contributor Author

Sure, I can do that. (Since the tests are disabled, they shouldn't break anything, though.)

felixfontein added a commit to felixfontein/ansible that referenced this pull request Sep 27, 2018
* Fixing record order for CAA records to properly handle idempotency.

* Add integration tests that reproduce CAA failure

(cherry picked from commit a727a1e)
felixfontein added a commit to felixfontein/ansible that referenced this pull request Sep 27, 2018
* Fixing record order for CAA records to properly handle idempotency.

* Add integration tests that reproduce CAA failure

(cherry picked from commit a727a1e)
abadger pushed a commit that referenced this pull request Oct 10, 2018
* [aws] route53 module: fix idempotency for CAA records  (#46049)

* Fixing record order for CAA records to properly handle idempotency.

* Add integration tests that reproduce CAA failure

(cherry picked from commit a727a1e)

* Added changelog.
mattclay pushed a commit that referenced this pull request Oct 16, 2018
* [aws] route53 module: fix idempotency for CAA records  (#46049)

* Fixing record order for CAA records to properly handle idempotency.

* Add integration tests that reproduce CAA failure

(cherry picked from commit a727a1e)

* Added changelog.
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 aws bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

route53: idempotency problems for multiple CAA entries for same record
4 participants