-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Bugfix: keycloak_identity_provider does not handle mapper changes properly #7418
Bugfix: keycloak_identity_provider does not handle mapper changes properly #7418
Conversation
- wrong identityProviderAlias in mapper configuration
* test for removing an existing mapper * test for adding a new mapper when others already exist * test for module idempotency when mappers not ordered by name in ascending order
* removing an existing mapper * adding a new mapper when others already exist * module idempotency when mappers not ordered by name in ascending order
There was a problem hiding this 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! I've added some first comments.
changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml
Outdated
Show resolved
Hide resolved
changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml
Outdated
Show resolved
Hide resolved
…uration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de>
…uration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de>
@felixfontein Are these checks stable normally, should I look into them failing after they had passed prior to changelog updates? Those could not have broken anything. |
The unit test failure with Python 2.7 has been introduced by this PR; you are calling The AZP errors seem to be some misinformation, if you check out the results on AZP you can see that all tests passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got interrupted when starting to review this, I at least want to send what I commented on so far.
changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml
Outdated
Show resolved
Hide resolved
…uration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't manage to properly look at this before. I'm not sure whether sorting by name (which isn't always present) is a good idea. While trying to figure out what happens I noticed another problem (see my comments below), fixing that one might already solve the issues here.
@felixfontein can we help in any way to get this accepted? |
@danekja my main problem with this is that I don't know whether the change is correct. That simply sorting the list fixes the main problem seems weird to me - it can be true, but it would surprise me. I have no way to test this since I don't have access to a Keycloak instance. It would be great if someone else (for example the module maintainers) could independently check this and make sure this doesn't break their use-cases of this module. |
@felixfontein sorting does not fix the main issue. Sorting only ensures module does not return "changed" when there are no changes. As I stated in the comment above - sorting is used by original author in the API call result parser. I have only ensured the playbook-provided mappers are sorted as well to ensure line 601 All the other changes fix the main issue (#6002). What to do here? We have a schedule to keep, probably more fixes to do to these modules to make them viable and soon I will have to fall back to maintaining our own fork of these module if we are unable to proceed here. I have done my best to keep implementation consistent with the original code, provided a regression test case and ensured the existing test suite is passing. I'm willing to make any changes necessary as I believe fixing the modules and contributing back to the community are the best course of action, but I can't afford to wait months. |
It would help a lot of the module maintainers would review PRs for these modules. I don't use or know these modules. I'm going to merge this once the remaining problem is fixed. |
…t potential failures in case name was not specified in playbook Co-authored-by: Felix Fontein <felix@fontein.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, as far as I can judge it.
Backport to stable-7: 💚 backport PR created✅ Backport PR branch: Backported as #7774 🤖 @patchback |
…perly (#7418) * fix keycloak_identity_provider ITs to actually pass - wrong identityProviderAlias in mapper configuration * kc_identity_provider: add mapper reconfiguration regression tests * test for removing an existing mapper * test for adding a new mapper when others already exist * test for module idempotency when mappers not ordered by name in ascending order * kc_identity_provider: add bugfixes for mapper reconfigurations * removing an existing mapper * adding a new mapper when others already exist * module idempotency when mappers not ordered by name in ascending order * add changelog fragment * prevent unnecessary update_mapper calls when there is no change * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/keycloak_identity_provider.py Co-authored-by: Felix Fontein <felix@fontein.de> * kc_identity_provider: sort changeset mappers via name OR id to prevent potential failures in case name was not specified in playbook Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit fd0d05d)
Backport to stable-8: 💚 backport PR created✅ Backport PR branch: Backported as #7775 🤖 @patchback |
@danekja thanks for your contribution, and sorry it took so long! |
…perly (#7418) * fix keycloak_identity_provider ITs to actually pass - wrong identityProviderAlias in mapper configuration * kc_identity_provider: add mapper reconfiguration regression tests * test for removing an existing mapper * test for adding a new mapper when others already exist * test for module idempotency when mappers not ordered by name in ascending order * kc_identity_provider: add bugfixes for mapper reconfigurations * removing an existing mapper * adding a new mapper when others already exist * module idempotency when mappers not ordered by name in ascending order * add changelog fragment * prevent unnecessary update_mapper calls when there is no change * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/keycloak_identity_provider.py Co-authored-by: Felix Fontein <felix@fontein.de> * kc_identity_provider: sort changeset mappers via name OR id to prevent potential failures in case name was not specified in playbook Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit fd0d05d)
…ider does not handle mapper changes properly (#7774) Bugfix: keycloak_identity_provider does not handle mapper changes properly (#7418) * fix keycloak_identity_provider ITs to actually pass - wrong identityProviderAlias in mapper configuration * kc_identity_provider: add mapper reconfiguration regression tests * test for removing an existing mapper * test for adding a new mapper when others already exist * test for module idempotency when mappers not ordered by name in ascending order * kc_identity_provider: add bugfixes for mapper reconfigurations * removing an existing mapper * adding a new mapper when others already exist * module idempotency when mappers not ordered by name in ascending order * add changelog fragment * prevent unnecessary update_mapper calls when there is no change * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/keycloak_identity_provider.py Co-authored-by: Felix Fontein <felix@fontein.de> * kc_identity_provider: sort changeset mappers via name OR id to prevent potential failures in case name was not specified in playbook Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit fd0d05d) Co-authored-by: Jakub Danek <danekja@users.noreply.github.com>
…ider does not handle mapper changes properly (#7775) Bugfix: keycloak_identity_provider does not handle mapper changes properly (#7418) * fix keycloak_identity_provider ITs to actually pass - wrong identityProviderAlias in mapper configuration * kc_identity_provider: add mapper reconfiguration regression tests * test for removing an existing mapper * test for adding a new mapper when others already exist * test for module idempotency when mappers not ordered by name in ascending order * kc_identity_provider: add bugfixes for mapper reconfigurations * removing an existing mapper * adding a new mapper when others already exist * module idempotency when mappers not ordered by name in ascending order * add changelog fragment * prevent unnecessary update_mapper calls when there is no change * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/7418-kc_identity_provider-mapper-reconfiguration-fixes.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/keycloak_identity_provider.py Co-authored-by: Felix Fontein <felix@fontein.de> * kc_identity_provider: sort changeset mappers via name OR id to prevent potential failures in case name was not specified in playbook Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit fd0d05d) Co-authored-by: Jakub Danek <danekja@users.noreply.github.com>
SUMMARY
keycloak_identity_provider mapper processing contained a bug which resulted in incorrect behaviour in the following cases:
Fixes #6002.
ISSUE TYPE
COMPONENT NAME
keycloak_identity_provider
ADDITIONAL INFORMATION
Issue was caused by
dict.update()
function being used to merge old and new states, without considering it does not recursively process nested lists and dictionaries.Regression tests for all 3 cases have been added to
tests/integration/targets/keycloak_identity_provider/tasks/main.yml