From a34d92d25c97feb778d4c222704d8ac32e146768 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Dec 13 2018 16:04:00 +0000 Subject: Create reindex task for ipaca DB pkispawn sometimes does not run its indextasks. This leads to slow unindexed filters on attributes such as description, which is used to log in with a certificate. Explicitly reindex attribute that should have been reindexed by CA's indextasks.ldif. See: https://pagure.io/dogtagpki/issue/3083 Signed-off-by: Christian Heimes Reviewed-By: Rob Crittenden Reviewed-By: Alexander Bokovoy --- diff --git a/ipaserver/install/cainstance.py b/ipaserver/install/cainstance.py index e2dd961..cf0babe 100644 --- a/ipaserver/install/cainstance.py +++ b/ipaserver/install/cainstance.py @@ -403,6 +403,7 @@ class CAInstance(DogtagInstance): self.step("creating installation admin user", self.setup_admin) self.step("configuring certificate server instance", self.__spawn_instance) + self.step("reindex attributes", self.reindex_task) self.step("exporting Dogtag certificate store pin", self.create_certstore_passwdfile) self.step("stopping certificate server instance to update CS.cfg", diff --git a/ipaserver/install/dogtaginstance.py b/ipaserver/install/dogtaginstance.py index d585617..d05e401 100644 --- a/ipaserver/install/dogtaginstance.py +++ b/ipaserver/install/dogtaginstance.py @@ -43,6 +43,7 @@ from ipapython import ipaldap from ipapython import ipautil from ipapython.dn import DN from ipaserver.install import service +from ipaserver.install import sysupgrade from ipaserver.install import replication from ipaserver.install.installutils import stopped_service @@ -537,3 +538,48 @@ class DogtagInstance(service.Service): # shutil.copy() doesn't copy owner s = os.stat(config) os.chown(bak, s.st_uid, s.st_gid) + + def reindex_task(self, force=False): + """Reindex ipaca entries + + pkispawn sometimes does not run its indextasks. This leads to slow + unindexed filters on attributes such as description, which is used + to log in with a certificate. Explicitly reindex attribute that + should have been reindexed by CA's indextasks.ldif. + + See https://pagure.io/dogtagpki/issue/3083 + """ + state_name = 'reindex_task' + if not force and sysupgrade.get_upgrade_state('dogtag', state_name): + return + + cn = "indextask_ipaca_{}".format(int(time.time())) + dn = DN( + ('cn', cn), ('cn', 'index'), ('cn', 'tasks'), ('cn', 'config') + ) + entry = api.Backend.ldap2.make_entry( + dn, + objectClass=['top', 'extensibleObject'], + cn=[cn], + nsInstance=['ipaca'], # Dogtag PKI database + nsIndexAttribute=[ + # from pki/base/ca/shared/conf/indextasks.ldif + 'archivedBy', 'certstatus', 'clientId', 'dataType', + 'dateOfCreate', 'description', 'duration', 'extension', + 'issuedby', 'issuername', 'metaInfo', 'notafter', + 'notbefore', 'ownername', 'publicKeyData', 'requestid', + 'requestowner', 'requestsourceid', 'requeststate', + 'requesttype', 'revInfo', 'revokedOn', 'revokedby', + 'serialno', 'status', 'subjectname', + ], + ttl=[10], + ) + logger.debug('Creating ipaca reindex task %s', dn) + api.Backend.ldap2.add_entry(entry) + logger.debug('Waiting for task...') + exitcode = replication.wait_for_task(api.Backend.ldap2, dn) + logger.debug( + 'Task %s has finished with exit code %i', + dn, exitcode + ) + sysupgrade.set_upgrade_state('dogtag', state_name, True) diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py index 5c9a409..55eabad 100644 --- a/ipaserver/install/ldapupdate.py +++ b/ipaserver/install/ldapupdate.py @@ -543,7 +543,7 @@ class LDAPUpdate: nsIndexAttribute=list(attributes), ) - logger.info( + logger.debug( "Creating task %s to index attributes: %s", dn, ', '.join(attributes) ) @@ -581,7 +581,7 @@ class LDAPUpdate: continue if "finished" in status.lower(): - logger.info("Indexing finished") + logger.debug("Indexing finished") break logger.debug("Indexing in progress") diff --git a/ipaserver/install/server/upgrade.py b/ipaserver/install/server/upgrade.py index 4de7fd9..02ffaa1 100644 --- a/ipaserver/install/server/upgrade.py +++ b/ipaserver/install/server/upgrade.py @@ -2032,6 +2032,7 @@ def upgrade_configuration(): add_default_caacl(ca) if ca.is_configured(): + ca.reindex_task() cainstance.repair_profile_caIPAserviceCert() ca.setup_lightweight_ca_key_retrieval() cainstance.ensure_ipa_authority_entry()