Defer initializing the API in dogtag-ipa-ca-renew-agent-submit

Wait until we know a supported operation is being called
(SUBMIT and POLL) before initializing the API, which can be
an expensive operation.

https://bugzilla.redhat.com/show_bug.cgi?id=1656519

Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
This commit is contained in:
Rob Crittenden
2019-09-04 13:31:58 -04:00
parent 1d033b040d
commit 0770254ce3

View File

@@ -473,13 +473,13 @@ def main():
else:
kwargs['reuse_existing'] = True
api.bootstrap(in_server=True, context='renew', confdir=paths.ETC_IPA)
api.finalize()
operation = os.environ.get('CERTMONGER_OPERATION')
if operation not in ('SUBMIT', 'POLL'):
return OPERATION_NOT_SUPPORTED_BY_HELPER
api.bootstrap(in_server=True, context='renew', confdir=paths.ETC_IPA)
api.finalize()
tmpdir = tempfile.mkdtemp(prefix="tmp-")
certs.renewal_lock.acquire()
try: