balodesecurity opened a new pull request, #8291:
URL: https://github.com/apache/hadoop/pull/8291

   ## 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
   
   - JIRA: https://issues.apache.org/jira/browse/HDFS-16842
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to