Fabric returns exit code 0 on failed parallel tasks #572

Closed
statico opened this Issue Feb 28, 2012 · 2 comments

Projects

None yet

2 participants

@statico
statico commented Feb 28, 2012

Given this fabfile.py:

from fabric.api import *

def test():
    abort('whoops')

And the command:

$ fab test -H host1,host2 && echo yes || echo no

The result is:

Fatal error: whoops

Aborting.
[host1] Executing task 'foo'
no

Makes sene. However, if I run them in parallel using the -P flag or @parallel decorator:

[host1] Executing task 'foo'
[host2] Executing task 'foo'

Fatal error: whoops

Aborting.
!!! Parallel execution exception under host 'host1':
Traceback (most recent call last):
  File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/tasks.py", line 167, in inner
    result = task.run(*args, **kwargs)
  File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/tasks.py", line 113, in run
    return self.wrapped(*args, **kwargs)
  File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/decorators.py", line 178, in inner
    return func(*args, **kwargs)
  File "/tmp/temp.py", line 5, in foo
    abort('whoops')
  File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/utils.py", line 26, in abort
    sys.exit(1)
SystemExit: 1

Fatal error: whoops

Aborting.
!!! Parallel execution exception under host 'host0':
Traceback (most recent call last):
  File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/tasks.py", line 167, in inner
    result = task.run(*args, **kwargs)
  File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/tasks.py", line 113, in run
    return self.wrapped(*args, **kwargs)
  File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/decorators.py", line 178, in inner
    return func(*args, **kwargs)
  File "/tmp/temp.py", line 5, in foo
    abort('whoops')
  File "/opt/stow/python-2.7.2/lib/python2.7/site-packages/fabric/utils.py", line 26, in abort
    sys.exit(1)
SystemExit: 1

Done.
yes

Shouldn't fabric return non-zero if any of the subtasks failed? (I don't necessarily care about order, like issue #457)

Fabric is great, BTW. Keep up the fantastic work.

@bitprophet bitprophet added a commit that referenced this issue Feb 28, 2012
@bitprophet bitprophet Changelog entry re #572 1cf9157
@bitprophet
Member

Thanks for the catch! You're absolutely right. I just fixed this and pushed it to the 1.4 and master branches. If you've the will to grab an unreleased version you can check it out. Otherwise I'll probably push a bugfix series in a few days/weekish.

@bitprophet bitprophet closed this Feb 28, 2012
@statico
statico commented Feb 28, 2012

Thanks! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment