Skip to content

Fabric returns exit code 0 on failed parallel tasks #572

Description

@statico

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions