-
Notifications
You must be signed in to change notification settings - Fork 707
Description
Hi,
I'm using Jira Data Center Software 10.3.3 hosted in our data center.
I have two problems with the current implementation of the jira.py functions related to reindexing:
- reindex_with_type(indexing_type), ignore indexing_type
- reindex_status() fails when a reindex is running
Start reindex foreground is working when using jira.post(f'/rest/api/2/reindex?type={indexing_type}') instead of jira.reindex_with_type(indexing_type).
reindex_status() fails on requests.exceptions.TooManyRedirects.
This is caused by the 303 status code on /rest/api/2/reindex when a reindex is running.
The status code 303 triggers a redirect, which should not be followed.
Workaround for reindex_with_type
Replace Start reindex foreground command
jira.reindex_with_type("FOREGROUND")
with
using jira.post('/rest/api/2/reindex?type="FOREGROUND"')
Fix for reindex foreground
Add parameter type to the URL as well.
Workaround for reindex_status
logging.info("Wait until reindex completed")
url = self._jira.url_joiner(self._jira.url,self._jira.resource_url("reindex"))
progress = self._jira._session.get(url,allow_redirects=False)
while 303 == progress.status_code :
print("Still reindexing...")
sleep(30)
progress = self._jira._session.get(url,allow_redirects=False)
print(progress.content)Necessary fix for reindex_status
rest_client.py: def request() needs option to not follow redirects. The requests module supports the option to allow_redirects=False, but this can't be configured. I assume this is not wanted or needed for other GET requests, but is essential to the choosen 303 implementation of Jira 10+.
Call chain:
jira:reindex_status() -> rest_client:get() -> rest_client:requests() -> requests.get()
Console output
DEBUG:atlassian.rest_client:curl --silent -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' 'https://jira-lab.ontwikkel.local/rest/api/2/reindex'
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): jira-lab.ontwikkel.local:443
DEBUG:urllib3.connectionpool:https://jira-lab.ontwikkel.local:443 "GET /rest/api/2/reindex HTTP/1.1" 303 269
...
DEBUG:urllib3.connectionpool:https://jira-lab.ontwikkel.local:443 "GET /rest/api/2/reindex/ HTTP/1.1" 303 269
Traceback (most recent call last):
File "/Users/../Workspace/automation/./jira-app.py", line 305, in <module>
main()
File "/Users/../Workspace/automation/./jira-app.py", line 61, in main
execute(option, proj_file, environment)
File "/Users/../Workspace/automation/./jira-app.py", line 128, in execute
reindex(connection_parameters)
File "/Users/../Workspace/automation/./jira-app.py", line 282, in reindex
jira.reindex(blocking)
File "/Users/../Workspace/automation/jiraclient_pythonapi.py", line 632, in reindex
print (self._jira.reindex_status()) # broken on redirect 303
File "/Users/../Workspace/automation/.venv/lib/python3.9/site-packages/atlassian/jira.py", line 4475, in reindex_status
return self.get(url)
File "/Users/../Workspace/automation/.venv/lib/python3.9/site-packages/atlassian/rest_client.py", line 562, in get
response = self.request(
File "/Users/../Workspace/automation/.venv/lib/python3.9/site-packages/atlassian/rest_client.py", line 425, in request
response = self._session.request(
File "/Users/../Workspace/automation/.venv/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/Users/../Workspace/automation/.venv/lib/python3.9/site-packages/requests/sessions.py", line 724, in send
history = [resp for resp in gen]
File "/Users/../Workspace/automation/.venv/lib/python3.9/site-packages/requests/sessions.py", line 724, in <listcomp>
history = [resp for resp in gen]
File "/Users/../Workspace/automation/.venv/lib/python3.9/site-packages/requests/sessions.py", line 191, in resolve_redirects
raise TooManyRedirects(
requests.exceptions.TooManyRedirects: Exceeded 30 redirects.