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

nsupdate: fix 'index out of range' error when changing NS records #8614

Merged
merged 3 commits into from
Jul 14, 2024

Conversation

artw
Copy link
Contributor

@artw artw commented Jul 11, 2024

SUMMARY

fallback to authority section of the response if there is no authoritative answer, instead of crashing

fixes #8612

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

nsupdate

ADDITIONAL INFORMATION

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type) labels Jul 11, 2024
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-8 Automatically create a backport for the stable-8 branch backport-9 Automatically create a backport for the stable-9 branch labels Jul 12, 2024
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! A first quick note:

changelogs/fragments/8614-nsupdate-index-out-of-range.yml Outdated Show resolved Hide resolved
Co-authored-by: Felix Fontein <felix@fontein.de>
Comment on lines +373 to +374
lookup_result = lookup.answer[0] if lookup.answer else lookup.authority[0]
entries_to_remove = [n.to_text() for n in lookup_result.items if n.to_text() not in self.value]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, in case lookup.answer does not exist, shouldn't entries_to_remove simply be set to []? In that situation there is no current NS value on that level that can be deleted, after all.

So something like

Suggested change
lookup_result = lookup.answer[0] if lookup.answer else lookup.authority[0]
entries_to_remove = [n.to_text() for n in lookup_result.items if n.to_text() not in self.value]
entries_to_remove = [n.to_text() for n in lookup.answer[0].items if n.to_text() not in self.value] if lookup.answer else []

maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my understanding of that block is bind9 will not let you rewrite the last NS record in the zone, so the new record is inserted first, and old one is deleted after. In my case it would not be the last, but the record does exist and needs to be deleted. But since the zone is subdelegated to another server, the data is in authority section. My guess is it was tested on the server where delegation was to another local zone so this was missed. If we do it like you suggest, we would have dupes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, ok. This still doens't sound right to me, but I don't use bind9 or the module so I don't know what really happens :)

In any case, this shouldn't break any existing behavior since if this happened so far, it resulted in an error, so in the worst case this is introducing wrong behavior in a case that didn't work at all before. If someone complains about it, we'll have to look into it again to figure out why exactly it works for you but not for them. And if nobody complains, I guess it's fine for everyone then :)

@felixfontein
Copy link
Collaborator

I'll merge tomorrow if nobody objects.

@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Jul 14, 2024
@felixfontein felixfontein merged commit 9dd2b71 into ansible-collections:main Jul 14, 2024
147 checks passed
Copy link

patchback bot commented Jul 14, 2024

Backport to stable-8: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-8/9dd2b71d043e89f9918fdf2ccda22674ef25a66a/pr-8614

Backported as #8629

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jul 14, 2024
)

* nsupdate: fix 'index out of range' error when changing NS records

* add clog fragment

* Update changelogs/fragments/8614-nsupdate-index-out-of-range.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9dd2b71)
@felixfontein
Copy link
Collaborator

@artw thanks for your contribution!

Copy link

patchback bot commented Jul 14, 2024

Backport to stable-9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-9/9dd2b71d043e89f9918fdf2ccda22674ef25a66a/pr-8614

Backported as #8630

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Jul 14, 2024
)

* nsupdate: fix 'index out of range' error when changing NS records

* add clog fragment

* Update changelogs/fragments/8614-nsupdate-index-out-of-range.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9dd2b71)
felixfontein pushed a commit that referenced this pull request Jul 14, 2024
…nge' error when changing NS records (#8629)

nsupdate: fix 'index out of range' error when changing NS records (#8614)

* nsupdate: fix 'index out of range' error when changing NS records

* add clog fragment

* Update changelogs/fragments/8614-nsupdate-index-out-of-range.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9dd2b71)

Co-authored-by: Art Win <art@make.lv>
felixfontein pushed a commit that referenced this pull request Jul 14, 2024
…nge' error when changing NS records (#8630)

nsupdate: fix 'index out of range' error when changing NS records (#8614)

* nsupdate: fix 'index out of range' error when changing NS records

* add clog fragment

* Update changelogs/fragments/8614-nsupdate-index-out-of-range.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 9dd2b71)

Co-authored-by: Art Win <art@make.lv>
aioue pushed a commit to aioue/community.general that referenced this pull request Oct 1, 2024
…sible-collections#8614)

* nsupdate: fix 'index out of range' error when changing NS records

* add clog fragment

* Update changelogs/fragments/8614-nsupdate-index-out-of-range.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
TobiasZeuch181 pushed a commit to TobiasZeuch181/zypper_repository_add_list that referenced this pull request Oct 2, 2024
…sible-collections#8614)

* nsupdate: fix 'index out of range' error when changing NS records

* add clog fragment

* Update changelogs/fragments/8614-nsupdate-index-out-of-range.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Massl123 pushed a commit to Massl123/community.general that referenced this pull request Feb 7, 2025
…sible-collections#8614)

* nsupdate: fix 'index out of range' error when changing NS records

* add clog fragment

* Update changelogs/fragments/8614-nsupdate-index-out-of-range.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8 Automatically create a backport for the stable-8 branch backport-9 Automatically create a backport for the stable-9 branch bug This issue/PR relates to a bug module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nsupdate: fails with index out of range' error when updating NS records
3 participants