Setting scheduler timeout=0 results in Timeout being raised outside the task

Bug #1349198 reported by Steve Baker
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Won't Fix
Low
Zane Bitter

Bug Description

When timeout=0 the Timeout is raised, but can't be caught by the task code.

Setting timeout=0 is desirable in some unit tests.

Changed in heat:
assignee: nobody → Zane Bitter (zaneb)
description: updated
Changed in heat:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to heat (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/109885

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

With the above gerrit change, test_timeout_zero passes when it should fail, and the following is logged:

Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/site-packages/subunit/run.py", line 131, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/subunit/run.py", line 127, in main
    stdout=sys.stdout)
  File "/usr/lib/python2.7/site-packages/testtools/run.py", line 220, in __init__
    self.runTests()
  File "/usr/lib/python2.7/site-packages/testtools/run.py", line 371, in runTests
    self.result = testRunner.run(self.test)
  File "/usr/lib/python2.7/site-packages/subunit/run.py", line 62, in run
    test(result)
  File "/usr/lib64/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib64/python2.7/unittest/suite.py", line 108, in run
    test(result)
  File "/usr/lib64/python2.7/unittest/case.py", line 433, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python2.7/site-packages/testscenarios/testcase.py", line 65, in run
    return super(WithScenarios, self).run(result)
  File "/usr/lib/python2.7/site-packages/testtools/testcase.py", line 568, in run
    return self.__RunTest(self, self.exception_handlers).run(result)
  File "/usr/lib/python2.7/site-packages/testtools/runtest.py", line 74, in run
    return self._run_one(actual_result)
  File "/usr/lib/python2.7/site-packages/testtools/runtest.py", line 88, in _run_one
    return self._run_prepared_result(ExtendedToOriginalDecorator(result))
  File "/usr/lib/python2.7/site-packages/testtools/runtest.py", line 100, in _run_prepared_result
    self._run_core()
  File "/usr/lib/python2.7/site-packages/testtools/runtest.py", line 125, in _run_core
    self.case._run_test_method, self.result):
  File "/usr/lib/python2.7/site-packages/testtools/runtest.py", line 176, in _run_user
    return self._got_user_exception(sys.exc_info())
  File "/usr/lib/python2.7/site-packages/testtools/runtest.py", line 203, in _got_user_exception
    raise e
heat.engine.scheduler.Timeout

Revision history for this message
Zane Bitter (zaneb) wrote :

When we throw() the Timeout, it gets raised at the point where the co-routine is stopped - which may be at a yield, or in this case at the very beginning (where it is impossible to catch). The alternative would be to advance the co-routine to the first yield using next() before calling throw()... however this is never what you want in the real world. If you _know_ that the operation is going to time out, it's much better to abort it before it starts than to get it into a half-executed state.

An easier approach for the unit tests might be to just use a very short timeout rather than 0, or to plan on catching the Timeout outside of the co-routine.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (master)

Change abandoned by Steve Baker (<email address hidden>) on branch: master
Review: https://review.openstack.org/109885

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

timeout=0.01 works fine for https://review.openstack.org/#/c/102397/

This bug should probably remain, and the fix could be to raise an exception when timeout <= 0

Changed in heat:
importance: Medium → Low
status: New → Triaged
Revision history for this message
Shashwat Srivastava (shashwat-srivastava) wrote :

Change has been successfully merged into the git repository. Changing the status.

Changed in heat:
status: Triaged → Fix Released
Revision history for this message
Zane Bitter (zaneb) wrote :

Actually, no change was ever merged, and nor should it be.

Changed in heat:
status: Fix Released → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.