apache/hadoop · error · BadFencingConfigurationException
No argument passed to 'shell' fencing method
Error message
No argument passed to 'shell' fencing method
What it means
ShellCommandFencer.checkArgs() throws BadFencingConfigurationException("No argument passed to 'shell' fencing method") at fencer creation when the 'shell' entry in dfs.ha.fencing.methods has an empty or absent argument — there is no command to execute, so fencing is impossible.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java:75
/** Length at which to abbreviate command in long messages */
private static final int ABBREV_LENGTH = 20;
/** Prefix for target parameters added to the environment */
private static final String TARGET_PREFIX = "target_";
/** Prefix for source parameters added to the environment */
private static final String SOURCE_PREFIX = "source_";
private static final String ARG_DELIMITER = ",";
@VisibleForTesting
static Logger LOG = LoggerFactory.getLogger(ShellCommandFencer.class);
@Override
public void checkArgs(String args) throws BadFencingConfigurationException {
if (args == null || args.isEmpty()) {
throw new BadFencingConfigurationException(
"No argument passed to 'shell' fencing method");
}
// Nothing else we can really check without actually running the command
}
@Override
public boolean tryFence(HAServiceTarget target, String args) {
ProcessBuilder builder;
String cmd = parseArgs(target.getTransitionTargetHAStatus(), args);
if (!Shell.WINDOWS) {
builder = new ProcessBuilder("bash", "-e", "-c", cmd);
} else {
builder = new ProcessBuilder("cmd.exe", "/c", cmd);
}
setConfAsEnvVars(builder.environment());
addTargetInfoAsEnvVars(target, builder.environment());View on GitHub (pinned to 2add963021)
Solutions
- Provide a real command: 'shell(/bin/true)' only for testing, or 'shell(/path/fence.sh)' with an actual fencing script.
- Ensure the argument is not just whitespace — isEmpty() also triggers the exception.
- Fix hdfs-site.xml and restart the daemon / retry failover.
Example fix
<!-- before --> <value>shell()</value> <!-- after --> <value>shell(/usr/local/bin/fence-nn.sh)</value>
Defensive patterns
Strategy: validation
Validate before calling
String line = "shell"; // or parse the arg out of 'shell(...)'
String arg = line.equals("shell") ? null : argInsideParens;
if (arg == null || arg.trim().isEmpty()) {
throw new IllegalStateException("shell fencer needs a command argument");
} Try / catch
try {
new NodeFencer(conf, "shell()");
} catch (BadFencingConfigurationException e) {
// message 'No argument passed' -> supply the command in hdfs-site.xml
} Prevention
- Never ship 'shell()' — always name a concrete command or script path.
- Include dfs.ha.fencing.methods in config templates with real values, not placeholders.
- Validate the full fencing config with a NodeFencer construction smoke test at deploy time.
When it happens
Trigger: dfs.ha.fencing.methods contains exactly 'shell()' or 'shell' with an empty/blank parenthesized argument. checkArgs() runs when the NodeFencer is constructed, so this fails as soon as the fencer is initialized (HA daemon start or first failover).
Common situations: Config template copied with the placeholder never replaced; the command was deleted during editing; misunderstanding that 'shell' requires the command inside parentheses.
Related errors
- Expecting arguments size of at most two, getting {}
- Unable to fence {}. Fencing failed.
- Unable to parse line: '{}'
- Could not find configured fencing method {}
- Class {} does not implement FenceMethod
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/25892cb785e75b92.
Report an issue: GitHub.