mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-09-03 20:52:56 -05:00
Run index task in ldap updater only when needed
When LDAP updater detected an update instruction in indexing tree, it run an indexing task and waited until it ends. However, the task was run regardless of the update instruction result. This lead to unnecessary index tasks being defined and waited for which makes the whole LDAP last longer. Execute indexing task only when an index add/update instruction is successful. https://fedorahosted.org/freeipa/ticket/2866
This commit is contained in:
committed by
Rob Crittenden
parent
d8ba7d9145
commit
2ecfe571fa
@@ -754,6 +754,8 @@ class LDAPUpdate:
|
||||
|
||||
self.print_entity(entry, "Final value after applying updates")
|
||||
|
||||
added = False
|
||||
updated = False
|
||||
if not found:
|
||||
# New entries get their orig_data set to the entry itself. We want to
|
||||
# empty that so that everything appears new when generating the
|
||||
@@ -773,13 +775,13 @@ class LDAPUpdate:
|
||||
self.info("Parent DN of %s may not exist, cannot create the entry",
|
||||
entry.dn)
|
||||
return
|
||||
added = True
|
||||
self.modified = True
|
||||
except Exception, e:
|
||||
self.error("Add failure %s", e)
|
||||
else:
|
||||
# Update LDAP
|
||||
try:
|
||||
updated = False
|
||||
changes = self.conn.generateModList(entry.origDataDict(), entry.toDict())
|
||||
if (entry.dn == DN(('cn', 'schema'))):
|
||||
d = dict()
|
||||
@@ -805,13 +807,14 @@ class LDAPUpdate:
|
||||
self.error("Update failed: %s", e)
|
||||
updated = False
|
||||
|
||||
if (DN(('cn', 'index')) in entry.dn and
|
||||
DN(('cn', 'userRoot')) in entry.dn):
|
||||
taskid = self.create_index_task(entry.getValue('cn'))
|
||||
self.monitor_index_task(taskid)
|
||||
|
||||
if updated:
|
||||
self.modified = True
|
||||
|
||||
if entry.dn.endswith(DN(('cn', 'index'), ('cn', 'userRoot'),
|
||||
('cn', 'ldbm database'), ('cn', 'plugins'),
|
||||
('cn', 'config'))) and (added or updated):
|
||||
taskid = self.create_index_task(entry.getValue('cn'))
|
||||
self.monitor_index_task(taskid)
|
||||
return
|
||||
|
||||
def _delete_record(self, updates):
|
||||
|
||||
Reference in New Issue
Block a user