{"record":{"id":"91af48fcfe8d6840","repo":"apache/hadoop","slug":"no-fencer-configured-for","errorCode":null,"errorMessage":"No fencer configured for {}","messagePattern":"No fencer configured for (.+?)","errorType":"exception","errorClass":"BadFencingConfigurationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/NNHAServiceTarget.java","lineNumber":193,"sourceCode":"        \"ZKFC address not relevant when auto failover is off\");\n    assert zkfcAddr != null;\n    \n    return zkfcAddr;\n  }\n  \n  void setZkfcPort(int port) {\n    assert autoFailoverEnabled;\n          \n    this.zkfcAddr = new InetSocketAddress(addr.getAddress(), port);\n  }\n\n  @Override\n  public void checkFencingConfigured() throws BadFencingConfigurationException {\n    if (fenceConfigError != null) {\n      throw fenceConfigError;\n    }\n    if (fencer == null) {\n      throw new BadFencingConfigurationException(\n          \"No fencer configured for \" + this);\n    }\n  }\n  \n  @Override\n  public NodeFencer getFencer() {\n    return fencer;\n  }\n  \n  @Override\n  public String toString() {\n    return \"NameNode at \" + (lifelineAddr != null ? lifelineAddr : addr);\n  }\n\n  public String getNameServiceId() {\n    return this.nsId;\n  }\n  ","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/NNHAServiceTarget.java#L175-L211","documentation":"Before promoting a standby to active, failover tooling (hdfs haadmin -failover) and the ZKFC call checkFencingConfigured to guarantee the old active can be fenced. NNHAServiceTarget parses dfs.ha.fencing.methods at construction; if no fencer was produced (fencer == null) — or an earlier parse failure was stashed in fenceConfigError — BadFencingConfigurationException('No fencer configured for <target>') is thrown.","triggerScenarios":"HA is enabled and failover is attempted, but dfs.ha.fencing.methods is absent or empty on the node performing the failover/ZKFC; or the fencer spec is malformed so parsing failed and the error is replayed at this check.","commonSituations":"HA configured except the fencing property; dfs.ha.fencing.methods set on NameNodes but missing on the admin/gateway host where haadmin runs; fencer string with bad syntax after an edit; test clusters set up without sshfence.","solutions":["Set dfs.ha.fencing.methods in hdfs-site.xml, e.g. sshfence (plus ssh private-key config) or 'shell(/bin/true)' for test clusters.","For sshfence, configure dfs.ha.fencing.ssh.private-key-files and passwordless ssh from the ZKFC/NN user to the other NN's root or NN user.","Make sure the property is present on every NameNode and on any host running haadmin/ZKFC, then retry the failover.","If the message repeats after configuring, verify the fencer expression parses (check NameNode/ZKFC logs for the original fenceConfigError)."],"exampleFix":"<!-- before: no fencer -->\n<!-- after: production ssh fencer with fallback -->\n<property>\n  <name>dfs.ha.fencing.methods</name>\n  <value>sshfence</value>\n</property>\n<property>\n  <name>dfs.ha.fencing.ssh.private-key-files</name>\n  <value>/home/hdfs/.ssh/id_rsa</value>\n</property>\n\n<!-- test-cluster alternative -->\n<property>\n  <name>dfs.ha.fencing.methods</name>\n  <value>shell(/bin/true)</value>\n</property>","handlingStrategy":"validation","validationCode":"String methods = conf.get(DFSConfigKeys.DFS_HA_FENCING_METHODS_KEY);\nif (methods == null || methods.trim().isEmpty()) {\n  throw new IllegalStateException(\"dfs.ha.fencing.methods is required before \"\n      + \"failover; configure sshfence or shell(...) on every NN/zkfc host\");\n}\n// dry-run the fencer parse\nNodeFencer fencer = new NodeFencer(new HdfsConfiguration(conf), methods);\nif (fencer == null) throw new IllegalStateException(\"fencer spec unparseable: \" + methods);","typeGuard":null,"tryCatchPattern":"try {\n  target.checkFencingConfigured();\n} catch (BadFencingConfigurationException e) {\n  throw new IllegalStateException(\"Refusing failover without a fencer: set \"\n      + \"dfs.ha.fencing.methods (e.g. sshfence) on this host and the peer\", e);\n}","preventionTips":["Add a config-lint rule: HA namespaces must define dfs.ha.fencing.methods on all NN and zkfc hosts.","Test fencing works before you need it (force a failover in a maintenance window).","For sshfence, verify passwordless ssh from each NN user to the peer NN as part of provisioning."],"tags":["hadoop","hdfs","ha","fencing","failover","configuration"],"backgroundTag":"ha-fencing-not-configured","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}