stdevel / katprep

Python toolkit for automating system maintenance and generating patch reports along with Foreman/Katello and Red Hat Satellite 6.x
GNU General Public License v3.0
35 stars 6 forks source link

Maintaining downtime on Icinga2 fragile #106

Open stdevel opened 5 years ago

stdevel commented 5 years ago

Describe the bug Scheduling downtimes on Icinga2 works, but katprep crashes with an BadStatusLine error.

To Reproduce Steps to reproduce the behavior:

  1. Schedule downtime, e.g.: katprep_maintenance *.json prepare
  2. See error

Expected behavior Downtime should be scheduled without crashing katprep.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context Could also be an upstream issue: https://github.com/Icinga/icinga2/issues/6635

Stacktrace:

$ katprep_maintenance -C katprep.auth 
  File "/usr/local/bin/katprep_maintenance", line 11, in <module>
    load_entry_point('katprep==0.5.0', 'console_scripts', 'katprep_maintenance')()
  File "build/bdist.linux-x86_64/egg/katprep/maintenance.py", line 884, in cli
  File "build/bdist.linux-x86_64/egg/katprep/maintenance.py", line 863, in main
  File "build/bdist.linux-x86_64/egg/katprep/maintenance.py", line 251, in prepare
  File "build/bdist.linux-x86_64/egg/katprep/maintenance.py", line 196, in manage_host_preparation
  File "build/bdist.linux-x86_64/egg/katprep/clients/Icinga2APIClient.py", line 278, in schedule_downtime
  File "build/bdist.linux-x86_64/egg/katprep/clients/Icinga2APIClient.py", line 248, in __manage_downtime
  File "build/bdist.linux-x86_64/egg/katprep/clients/Icinga2APIClient.py", line 160, in __api_post
  File "build/bdist.linux-x86_64/egg/katprep/clients/Icinga2APIClient.py", line 118, in __api_request
  File "/home/vagrant/.local/lib/python2.7/site-packages/requests/sessions.py", line 559, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/vagrant/.local/lib/python2.7/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/vagrant/.local/lib/python2.7/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/vagrant/.local/lib/python2.7/site-packages/requests/adapters.py", line 495, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
stdevel commented 5 years ago

Received the hint, that the API is not designed for serving multiple requests in one session. So the workaround would be to close the API session after every request and re-establish it afterwards.