Summary
Add a new --fail-fast option to bssh that stops execution immediately when any node fails (connection error or non-zero exit code). This is a prerequisite for pdsh compatibility mode (meta-issue #91).
Parent Issue
Part of #91 (pdsh compatibility mode) - Phase 1: New Options for Feature Parity
Background
pdsh provides -k option that causes the tool to fail fast on any error:
- Connection failure to any host
- Non-zero return code from any command
This is useful for:
- Critical operations where partial execution is unacceptable
- Deployment scripts where all nodes must succeed
- Validation checks across clusters
Proposed Implementation
CLI Interface
# Default behavior (continue on failure)
bssh -H "node1,node2,node3" "risky-command"
# Continues even if node1 fails, reports all results at end
# Fail-fast mode
bssh -H "node1,node2,node3" --fail-fast "risky-command"
# Stops immediately if any node fails, cancels pending operations
Option Definition
#[arg(
short = 'k',
long = "fail-fast",
help = "Stop execution immediately on first failure\nCancels pending commands when any node fails or returns non-zero"
)]
pub fail_fast: bool,
Implementation Tasks
Acceptance Criteria
Technical Considerations
- Need to implement cancellation tokens or similar mechanism
- Should integrate with tokio's task cancellation
- Consider using
tokio::select! for early termination
- May need to track which tasks have started vs pending
Interaction with Other Options
--fail-fast + --require-all-success: Both require all nodes to succeed, but fail-fast stops early
--fail-fast + --parallel N: Should cancel pending tasks in the semaphore queue
Notes
- Short option
-k does not conflict with existing bssh options
- This complements the existing
--require-all-success and --check-all-nodes options
Summary
Add a new
--fail-fastoption to bssh that stops execution immediately when any node fails (connection error or non-zero exit code). This is a prerequisite for pdsh compatibility mode (meta-issue #91).Parent Issue
Part of #91 (pdsh compatibility mode) - Phase 1: New Options for Feature Parity
Background
pdsh provides
-koption that causes the tool to fail fast on any error:This is useful for:
Proposed Implementation
CLI Interface
Option Definition
Implementation Tasks
--fail-fast/-koption toClistruct insrc/cli.rsAcceptance Criteria
Technical Considerations
tokio::select!for early terminationInteraction with Other Options
--fail-fast+--require-all-success: Both require all nodes to succeed, but fail-fast stops early--fail-fast+--parallel N: Should cancel pending tasks in the semaphore queueNotes
-kdoes not conflict with existing bssh options--require-all-successand--check-all-nodesoptions