You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the pyinfra cli, I added the parameters " --serial" and "--fail-percent 0" to let the deploy run one host at a time , and if one host encountered error, the deploy process would stop.
When I use "exec" to execute adhoc command, the --fail-percent worked as expected.But when I switch to a .py file which using "server.shell" to execute the same command, the deploy was still executed on all hosts even the first host had failed.
To Reproduce
Operation code & usage
write a simple deploy file(eg. test_fail_percent.py), using server.shell to execute a command that does not exist.
import pyinfra.operations.server as server
server.shell('uptim')
run pyinfra with the above file with multiple hosts pyinfra -y --serial --fail-percent 0 --debug host1,host2 test_fail_percent.py
Target system information
ubuntu 22.04
Expected behavior
The deploy should be stopped for other hosts when the first host encountered error during the "server.shell" execution
--> Skipping change detection
--> Beginning operation run...
[pyinfra.api.operations] Running all ops on host2
--> Starting operation: server.shell (uptim)
[pyinfra.api.operations] Starting operation {'server.shell'} on host2
[pyinfra.connectors.ssh] Running command on host2: (pty=False) sh -c uptim
[pyinfra.connectors.ssh] Waiting for exit status...
[pyinfra.connectors.ssh] Command exit status: 127
[host2] sh: 1: uptim: not found
[host2] Error: executed 0 commands
[pyinfra.api.state] Failing hosts: host2
[pyinfra.api.operations] Running all ops on host1
--> Starting operation: server.shell (uptim)
[pyinfra.api.operations] Starting operation {'server.shell'} on host1
[pyinfra.connectors.ssh] Running command on host1: (pty=False) sh -c uptim
[pyinfra.connectors.ssh] Waiting for exit status...
[pyinfra.connectors.ssh] Command exit status: 127
[host1] sh: 1: uptim: not found
[host1] Error: executed 0 commands
[pyinfra.api.state] Failing hosts: host1
The text was updated successfully, but these errors were encountered:
avrilmaomao
changed the title
--fail-percent not working when using server.shell or server.script
--fail-percent not working when using server.shell
Sep 4, 2024
Describe the bug
In the pyinfra cli, I added the parameters " --serial" and "--fail-percent 0" to let the deploy run one host at a time , and if one host encountered error, the deploy process would stop.
When I use "exec" to execute adhoc command, the --fail-percent worked as expected.But when I switch to a .py file which using "server.shell" to execute the same command, the deploy was still executed on all hosts even the first host had failed.
To Reproduce
pyinfra -y --serial --fail-percent 0 --debug host1,host2 test_fail_percent.py
ubuntu 22.04
Expected behavior
The deploy should be stopped for other hosts when the first host encountered error during the "server.shell" execution
Meta
pyinfra --support
.System: Linux
Platform: Linux-5.15.0-101-generic-x86_64-with-glibc2.35
Release: 5.15.0-101-generic
Machine: x86_64
pyinfra: v3.1
click: v8.1.7
configparser: v7.0.0
distro: v1.9.0
gevent: v24.2.1
jinja2: v3.1.3
packaging: v24.1
paramiko: v3.4.0
python-dateutil: v2.9.0.post0
pywinrm: v0.4.3
setuptools: v74.1.1
typeguard: v4.3.0
typing-extensions: v4.12.2
wheel: v0.44.0
Executable: /usr/sbin/pyinfra
Python: 3.10.12 (CPython, GCC 11.4.0)
pip
-vv
and--debug
.The text was updated successfully, but these errors were encountered: