#9305 ipaserver.replication.wait_for_task can't handle NotFound
Opened by rcritten. Modified

Issue

Seen during an installation in CI. IPA version 4.11.0.dev-0.fc37

A pretty normal IPA installation failed during the CA deployment while running an indexing task.

2023-01-11T14:32:01Z DEBUG [6/31]: reindex attributes
2023-01-11T14:32:01Z DEBUG Loading StateFile from '/var/lib/ipa/sysupgrade/sysupgrade.state'
2023-01-11T14:32:01Z DEBUG Creating ipaca reindex task cn=indextask_ipaca_1673447521,cn=index,cn=tasks,cn=config
2023-01-11T14:32:01Z DEBUG Waiting for task...
2023-01-11T14:35:08Z DEBUG Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/ipapython/ipaldap.py", line 1088, in error_handler
yield
File "/usr/lib/python3.11/site-packages/ipapython/ipaldap.py", line 1588, in find_entries
raise e
File "/usr/lib/python3.11/site-packages/ipapython/ipaldap.py", line 1548, in find_entries
result = self.conn.result3(id, 0)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/ldap/ldapobject.py", line 543, in result3
resp_type, resp_data, resp_msgid, decoded_resp_ctrls, retoid, retval = self.result4(
^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/ldap/ldapobject.py", line 553, in result4
ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.11/site-packages/ldap/ldapobject.py", line 128, in _ldap_call
result = func(args,*kwargs)
^^^^^^^^^^^^^^^^^^^^
ldap.NO_SUCH_OBJECT: {'msgtype': 101, 'msgid': 30, 'result': 32, 'desc': 'No such object', 'ctrls': []}

The NotFound was caused by the period LDAP search for status taking 186 seconds. By the time the search finished I assume the task had been reaped by 389-ds and therefore wasn't available:

11/Jan/2023:14:32:01.626367415 +0000] conn=3 op=29 ADD dn="cn=indextask_ipaca_1673447521,cn=index,cn=tasks,cn=config"
[11/Jan/2023:14:32:01.639138114 +0000] conn=3 op=29 RESULT err=0 tag=105 nentries=0 wtime=0.000194222 optime=0.012779534 etime=0.012970808
[11/Jan/2023:14:32:01.641633630 +0000] conn=3 op=30 SRCH base="cn=indextask_ipaca_1673447521,cn=index,cn=tasks,cn=config" scope=0 filter="(objectClass=)" attrs="nsTaskExitCode nsTaskCurrentItem nsTaskStatus nsTaskTotalItems nsTaskLog"
[11/Jan/2023:14:32:01.644290362 +0000] conn=3 op=30 RESULT err=0 tag=101 nentries=1 wtime=0.000254605 optime=0.002658075 etime=0.002909610
[11/Jan/2023:14:32:02.644888698 +0000] conn=3 op=32 SRCH base="cn=indextask_ipaca_1673447521,cn=index,cn=tasks,cn=config" scope=0 filter="(objectClass=
)" attrs="nsTaskExitCode nsTaskCurrentItem nsTaskStatus nsTaskTotalItems nsTaskLog"
[11/Jan/2023:14:35:08.655134606 +0000] conn=3 op=32 RESULT err=32 tag=101 nentries=0 wtime=0.000249566 optime=186.010250463 etime=186.010483900

wait_for_task searches every second looking for task status without a try/except loop. Been this way since 2013.

I guess theoretically it should be more robust and catch errors. But what should it do if we get a NotFound? Assume the task succeeded and proceed or fail with a more specific reason?


Link to the PR-CI job http://freeipa-org-pr-ci.s3-website.eu-central-1.amazonaws.com/jobs/986265f4-91bb-11ed-b8cc-fa163e3eb16d

Metadata