Skip to content

HDFS-16842. DatanodeHttpServer does not update config after refreshNamenodes#8291

Open
balodesecurity wants to merge 6 commits intoapache:trunkfrom
balodesecurity:HDFS-16842
Open

HDFS-16842. DatanodeHttpServer does not update config after refreshNamenodes#8291
balodesecurity wants to merge 6 commits intoapache:trunkfrom
balodesecurity:HDFS-16842

Conversation

@balodesecurity
Copy link

@balodesecurity balodesecurity commented Mar 2, 2026

Problem

When DataNode.refreshNamenodes() is called to add a new nameservice it reloads configuration via setConf(new Configuration()), but DatanodeHttpServer kept holding a stale reference to the old Configuration. Subsequent WebHDFS requests for blocks on the newly-added nameservice would fail because the DFSClient created per-request could not resolve the namenode addresses for that nameservice from the stale config.

Root cause: DatanodeHttpServer.conf and confForCreate were final fields set once at construction time. DataNode.refreshNamenodes() never called any update method on httpServer.

Fix

  • Make conf and confForCreate in DatanodeHttpServer volatile (non-final) so Netty I/O threads see updates atomically.
  • Add DatanodeHttpServer.updateConf(Configuration newConf) that refreshes both fields and the embedded Jetty infoServer's servlet-context attributes (CONF_CONTEXT_ATTRIBUTE, CURRENT_CONF).
  • Call httpServer.updateConf(getConf()) at the end of DataNode.refreshNamenodes() after the new configuration has been loaded.

The Netty ChannelInitializer creates a fresh URLDispatcher per connection and reads DatanodeHttpServer.conf at that point, so new connections automatically pick up the updated configuration without requiring a pipeline or server restart.

Testing

  • Added TestDatanodeHttpServerUpdateConf.testUpdateConfRefreshesFields — a unit test (no cluster required) that:
    • Creates a DatanodeHttpServer with an initial configuration.
    • Calls updateConf(newConf).
    • Asserts (via reflection) that the conf and confForCreate instance fields now reference the updated configuration.
    • Asserts that the Jetty infoServer servlet-context attributes have been updated.
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

Related

…menodes.

When DataNode.refreshNamenodes() is called to add a new nameservice it
reloads configuration via setConf(new Configuration()), but the
DatanodeHttpServer kept holding a stale reference to the old
Configuration. Subsequent WebHDFS requests for blocks on the newly
added nameservice would fail because the DFSClient created per-request
could not resolve the namenode addresses for that nameservice.

Fix: make the `conf` and `confForCreate` fields in DatanodeHttpServer
volatile (so Netty I/O threads see writes atomically) and expose a new
updateConf(Configuration) method that refreshes both fields plus the
embedded Jetty infoServer's servlet-context attributes. Call
httpServer.updateConf(getConf()) at the end of
DataNode.refreshNamenodes() after the new configuration has been loaded.

The Netty ChannelInitializer creates a fresh URLDispatcher per
connection; because it accesses the DatanodeHttpServer instance fields
at connection-time, new connections automatically pick up the updated
configuration with no pipeline restart required.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 0s Docker mode activated.
-1 ❌ docker 0m 22s Docker failed to build run-specific yetus/hadoop:tp-9534}.
Subsystem Report/Notes
GITHUB PR #8291
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8291/1/console
versions git=2.34.1
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 0s Docker mode activated.
-1 ❌ docker 0m 13s Docker failed to build run-specific yetus/hadoop:tp-4134}.
Subsystem Report/Notes
GITHUB PR #8291
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8291/2/console
versions git=2.34.1
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 0s Docker mode activated.
-1 ❌ docker 0m 12s Docker failed to build run-specific yetus/hadoop:tp-9976}.
Subsystem Report/Notes
GITHUB PR #8291
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8291/3/console
versions git=2.34.1
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 0s Docker mode activated.
-1 ❌ docker 0m 13s Docker failed to build run-specific yetus/hadoop:tp-10157}.
Subsystem Report/Notes
GITHUB PR #8291
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8291/4/console
versions git=2.34.1
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 0s Docker mode activated.
-1 ❌ docker 0m 14s Docker failed to build run-specific yetus/hadoop:tp-25663}.
Subsystem Report/Notes
GITHUB PR #8291
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8291/5/console
versions git=2.34.1
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@balodesecurity
Copy link
Author

CI failed due to Jenkins Docker infrastructure issue (apt-get failure and yetus/hadoop image pull denied) — unrelated to the patch. Requesting retest.

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants