-
Notifications
You must be signed in to change notification settings - Fork 235
Fixes ipahost idempotence issues #1383
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
Open
rjeffman
wants to merge
3
commits into
freeipa:master
Choose a base branch
from
rjeffman:host_dns_record_idempotence
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Hey there - I've reviewed your changes - here's some feedback:
- The new single_host flag logic (
single_host=len(entry_factory)>1) no longer matches the originalhosts is Nonesemantics—please verify it still produces the intended batching behavior when processing multiple entries. - There’s still duplicated logic for splitting FQDN into host and domain in the DNS record sections—extracting that into a helper would reduce code repetition and minimize edge‐case bugs.
- Even with the EntryFactory, the main function is extremely large; consider breaking out host command generation for each state/action into helper functions to improve readability and maintainability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new single_host flag logic (`single_host=len(entry_factory)>1`) no longer matches the original `hosts is None` semantics—please verify it still produces the intended batching behavior when processing multiple entries.
- There’s still duplicated logic for splitting FQDN into host and domain in the DNS record sections—extracting that into a helper would reduce code repetition and minimize edge‐case bugs.
- Even with the EntryFactory, the main function is extremely large; consider breaking out host command generation for each state/action into helper functions to improve readability and maintainability.
## Individual Comments
### Comment 1
<location> `plugins/modules/ipahost.py:658` </location>
<code_context>
result["result"]["randompassword"]
+def convert_sshpubkey(value):
+ """Ensure sshpubkey values are correct."""
+ if isinstance(value, list):
+ value = [str(normalize_sshpubkey(key)) for key in value]
+ if isinstance(value, (str, unicode)): # pylint: disable=E0606
+ value = str(normalize_sshpubkey(value))
+ return value
+
+
</code_context>
<issue_to_address>
convert_sshpubkey may not handle nested lists or None values robustly.
Please update convert_sshpubkey to handle None inputs and nested lists to prevent runtime errors.
</issue_to_address>
### Comment 2
<location> `plugins/module_utils/ansible_freeipa_module.py:540` </location>
<code_context>
return value
+def convert_param_value_to_uppercase(value):
+ if isinstance(value, list):
+ value = [v.upper() for v in value]
+ if isinstance(value, (str, unicode)):
+ value = value.upper()
+ return value
+
+
</code_context>
<issue_to_address>
convert_param_value_to_uppercase does not handle None values.
Explicitly handle None to ensure consistent behavior and prevent unintended results in downstream code.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
1ccd618 to
35ea5d7
Compare
0b4a6a0 to
b246dff
Compare
Member
Author
|
Dowstream tests are passing with these changes. |
When comparing an argument dict to an IPA dict, the log messages were inconsistent and did not provide enough information for debugging. This change make the messages consistent and display the dict key being evaluated if the key result in tagging the dicts as different. Signed-off-by: Rafael Guterres Jeffman <[email protected]>
This patch moves the function used to ensure that hostnames used in ipasurule are FQDN and unique to module_utils, so it can be used by other modules than require the same behavior for a hostaname parameter. Signed-off-by: Rafael Guterres Jeffman <[email protected]>
When using ipahost with the 'hosts' parameters several parameter conversion routines were not being performed causing the module to try to execute tasks it was not suposed to. This issues were fixed by adapting the module to use EntryFactory. Another issue was happening when 'update_dns: true' is used with some parameters, like 'description', 'location' or 'mac_address', where, even if no change was to be performed the plugin would evaluate that the arguments were different, and tried to modify the object. The fix for this issue is to ignore 'updatedns' when comparing the parameters provided with the existing IPA object. This modification also fix the case where duplicate entries used with the 'name' parameter in case 'state: absent' would fail without indicating the use of duplicate entries. Fixes: freeipa#1296 Fixes: https://issues.redhat.com/browse/RHEL-111063 Signed-off-by: Rafael Guterres Jeffman <[email protected]>
b246dff to
e7819b1
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #1296
Summary by Sourcery
Improve idempotence in the ipahost module by normalizing input values uniformly and refactoring host entry processing.
Bug Fixes:
Enhancements:
Tests: