python-jenkins-developers team mailing list archive
-
python-jenkins-developers team
-
Mailing list archive
-
Message #00550
[Bug 1775047] Re: build_job() is failing with "... empty response" exception when Jenkins is behind haproxy where disabled keep_alive
Reviewed: https://review.openstack.org/572179
Committed: https://git.openstack.org/cgit/openstack/python-jenkins/commit/?id=f420d6de01de4558a8f285deaedae58cbc4cb743
Submitter: Zuul
Branch: master
commit f420d6de01de4558a8f285deaedae58cbc4cb743
Author: Dennis Dmitriev <ddmitriev@xxxxxxxxxxxx>
Date: Mon Jun 4 21:02:20 2018 +0300
Check for 'Location' header in the response
If the keep_alive is not available because of using reverse
proxy, the header 'Content-Lenght' may not be available,
causing the exception:
Error communicating with server[...]: empty response
However, if 'Location' header is present, the response is valid.
Add unit tests:
- build_job must pass even if no 'content-lenght'
in response header
- build_job must fail if no 'location' in response header
Change-Id: I4da6dd19f9d8302a76652a3686a9377f9a2503a6
Closes-Bug:#1775047
** Changed in: python-jenkins
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Python
Jenkins Developers, which is subscribed to Python Jenkins.
https://bugs.launchpad.net/bugs/1775047
Title:
build_job() is failing with "... empty response" exception when
Jenkins is behind haproxy where disabled keep_alive
Status in Python Jenkins:
Fix Released
Bug description:
Jenkins supports keep_alive http option, and when
JenkinsClient:build_job() is called, normally the response contains
the 'content-length' header, for example:
ipdb> response.status_code
201
ipdb> response.headers
{'Date': 'Mon, 04 Jun 2018 11:52:00 GMT', 'Content-Length': '0', 'Location': 'http://10.70.0.15:8081/queue/item/11/', 'X-Content-Type-Options': 'nosniff', 'Server': 'Jetty(9.4.z-SNAPSHOT)'}
But if Jenkins master is behind HAProxy with enabled 'option
httpclose', which disables keep_alive, the response doesn't contain
'content-length' header:
ipdb> response.status_code
201
ipdb> response.headers
{'Date': 'Mon, 04 Jun 2018 11:55:36 GMT', 'Connection': 'close', 'Location': 'http://10.60.0.90:8081/queue/item/16/', 'X-Content-Type-Options': 'nosniff', 'Server': 'Jetty(9.4.z-SNAPSHOT)'}
Other fields that are checked in JenkisClient:_response_handler() are empty in both cases:
ipdb> response.content
''
ipdb> response.text
u''
As the result: JenkinsClient raises an exception like:
File ".../local/lib/python2.7/site-packages/jenkins/__init__.py", line 1280, in build_job
'POST', self.build_job_url(name, parameters, token)))
File ".../lib/python2.7/site-packages/jenkins/__init__.py", line 565, in jenkins_request
self._request(req))
File ".../lib/python2.7/site-packages/jenkins/__init__.py", line 523, in _response_handler
"empty response" % self.server)
jenkins.EmptyResponseException: Error communicating with server[http://10.60.0.90:8081/]: empty response
However, the response is valid because the meaningful part of the
response is the header 'Location'.
To manage notifications about this bug go to:
https://bugs.launchpad.net/python-jenkins/+bug/1775047/+subscriptions
References