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

Check for conflict entries before raising domain level #324

Closed
wants to merge 1 commit into from
Closed

Check for conflict entries before raising domain level #324

wants to merge 1 commit into from

Conversation

tbordaz
Copy link
Contributor

@tbordaz tbordaz commented Dec 9, 2016

Checking of conflicts is not only done in topology container as
tests showed it can occurs elsewhere

https://fedorahosted.org/freeipa/ticket/6534

return True
else:
return False

Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather rewrite the code to raise exception directly from this function:

+    try:
+        ldap.get_entries(
+            filter="(&(nsds5replconflict=*)(|(objectclass=ldapsubentry)(objectclass=*)))",
+            base_dn=container_dn,
+            scope=ldap.SCOPE_SUBTREE)
+
+        raise errors.InvalidDomainLevelError(...)
+    except errors.NotFound:
+        return

I use get_entreis here because it raises NotFound when no conflicts are found.

@@ -131,6 +155,13 @@ def execute(self, *args, **options):
.format(desired_value, master['cn'][0]))
raise errors.InvalidDomainLevelError(reason=message)

# Check if conflict entries exist in topology subtree, should be resolved first
if check_conflict_entries(ldap, self.api):
Copy link
Contributor

Choose a reason for hiding this comment

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

You can then just plainly call check_conflict_entries(ldap, desired_value, self.api) here.

@martbab
Copy link
Contributor

martbab commented Dec 9, 2016

I have some comments regarding the logic of the check. These will also fix the warning reported by pylint checker.

filter="(&(nsds5replconflict=*)(|(objectclass=ldapsubentry)(objectclass=*)))",
base_dn=container_dn,
scope=ldap.SCOPE_SUBTREE)
return True
Copy link
Contributor

Choose a reason for hiding this comment

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

Please raise the InvalidDomainLevel here directly, there is no point in returning a boolean and then checking it in the caller to raise exception.

This leads to cleaner code uncluttered with extraneous boolean checks.

@martbab
Copy link
Contributor

martbab commented Dec 12, 2016

I am still not happy with the the PR, see review comments.

Checking of conflicts is not only done in topology container as
tests showed it can occurs elsewhere

https://fedorahosted.org/freeipa/ticket/6534
@martbab martbab added the ack Pull Request approved, can be merged label Dec 13, 2016
@martbab
Copy link
Contributor

martbab commented Dec 13, 2016

@martbab martbab closed this Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged
Projects
None yet
3 participants