Skip to content

Conversation

@albertbolt1
Copy link
Contributor

@albertbolt1 albertbolt1 commented Jan 17, 2026

Which Issue(s) This PR Fixes(Closes)

Fixes #5625

Brief Description

Added a command for updating controller config

can be called as such

cargo run --bin rocketmq-admin-cli-rust -- controller updateControllerConfig -a 127.0.0.1:9878 -k key -v value

How Did You Test This Change?

Tested manually

Screenshot 2026-01-17 at 2 25 45 PM

Summary by CodeRabbit

  • New Features

    • Added "updateControllerConfig" CLI command to remotely update controller configuration. Accepts controller address, configuration key, and value; validates inputs, applies the change, reports success or errors.
  • Chores

    • Minor copyright year update.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

Walkthrough

Adds a new CLI subcommand updateControllerConfig (UpdateControllerConfigSubCommand) that validates args, builds a single key/value properties map, starts a DefaultMQAdminExt, calls update_controller_config against one or more Controller addresses, prints the result, and shuts down the admin client.

Changes

Cohort / File(s) Summary
Controller Commands Enum Extension
rocketmq-tools/src/commands/controller_commands.rs
Adds mod update_controller_config_sub_command;, imports UpdateControllerConfigSubCommand, adds enum variant UpdateControllerConfigSubCommand(...) with Clap name updateControllerConfig/about text, and dispatches to its execute method in the command match. Also updates top-level copyright year.
New Subcommand Implementation
rocketmq-tools/src/commands/controller_commands/update_controller_config_sub_command.rs
Adds UpdateControllerConfigSubCommand CLI struct (controller_address, key, value) and implements CommandExecute::execute async: trims inputs, validates non-empty key/value, splits controller_address into server_list, creates/configures/starts DefaultMQAdminExt, builds HashMap<CheetahString, CheetahString> with the single pair, calls update_controller_config(properties, server_list), maps errors to RocketMQError::Internal, prints success, and shuts down the admin client.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as "CLI (UpdateControllerConfigSubCommand)"
    participant Admin as "DefaultMQAdminExt"
    participant Controller as "Controller Nodes (server_list)"

    CLI->>CLI: parse & trim args (controller_address, key, value)
    CLI->>Admin: create instance & setInstanceName
    CLI->>Admin: start()
    CLI->>Admin: build properties HashMap (key -> value)
    Admin->>Controller: update_controller_config(properties, server_list)
    Controller-->>Admin: success / error
    Admin-->>CLI: return result
    CLI->>Admin: shutdown()
    CLI-->>CLI: print success/error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through flags and trimmed the stray,
Sent one key and value on a sunny relay.
Started the admin, whispered to each node,
Updated configs light as a load.
Then I curled and napped on the code.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly summarizes the main change: adding a new command for updating controller configuration, which aligns with the actual implementation of UpdateControllerConfigSubCommand.
Linked Issues check ✅ Passed The PR implements the UpdateControllerConfigSubCommand to enable dynamic controller config updates without restart, meeting all coding requirements specified in issue #5625.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the updateControllerConfig command. The copyright year update (2023 to 2026) is a minor, acceptable change accompanying the feature implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rocketmq-rust-bot
Copy link
Collaborator

🔊@albertbolt1 🚀Thanks for your contribution🎉!

💡CodeRabbit(AI) will review your code first🔥!

Note

🚨The code review suggestions from CodeRabbit are to be used as a reference only, and the PR submitter can decide whether to make changes based on their own judgment. Ultimately, the project management personnel will conduct the final code review💥.

@rocketmq-rust-robot rocketmq-rust-robot added Difficulty level/Moderate Moderate difficult ISSUE feature🚀 Suggest an idea for this project. labels Jan 17, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In
`@rocketmq-tools/src/commands/controller_commands/update_controller_config_sub_command.rs`:
- Around line 61-63: The error message uses the wrong command name; update the
RocketMQError::Internal format string in the MQAdminExt::start error path to
reference the correct command (e.g., "UpdateControllerConfigSubCommand") instead
of "AddWritePermSubCommand" so the log accurately identifies the failing command
in the update_controller_config_sub_command logic.
- Around line 65-78: The command currently catches errors from
default_mqadmin_ext.update_controller_config(...) and only prints them, then
always returns Ok(()); change this to propagate failures to the caller by
returning the error instead of swallowing it. Replace the match that prints
Err(e) with propagation (e.g., use the ? operator on the mapped RocketMQError or
return Err(e) from the Err branch) so that update_controller_config errors
bubble up; keep the success branch behavior (printing success) but ensure the
function returns the error (RocketMQError) when update_controller_config fails.
- Around line 38-58: The code currently allows empty/whitespace-only controller
addresses and empty key/value; fix by validating trimmed inputs: ensure
self.controller_address.trim() is non-empty before converting to
controller_address, ensure key and value are non-empty after trim and return
Err(RocketMQError::Internal(...)) if they are; when building
server_array/server_list, split on ';', map each segment to trimmed string and
filter out empty segments (e.g., .split(';').map(|s| s.trim()).filter(|s|
!s.is_empty()) ), then convert remaining segments into CheetahString for
server_list and reject if the filtered list is empty; update uses of
controller_address, key, value, server_array, and server_list accordingly.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@rocketmq-tools/src/commands/controller_commands/update_controller_config_sub_command.rs`:
- Around line 31-37: In execute() the provided rpc_hook is never applied to
DefaultMQAdminExt; change the admin client construction in
UpdateControllerConfigSubCommand::execute to use
DefaultMQAdminExt::with_rpc_hook(...) when rpc_hook is Some, otherwise fall back
to DefaultMQAdminExt::new(); specifically, replace DefaultMQAdminExt::new() with
conditional construction that calls
DefaultMQAdminExt::with_rpc_hook(rpc_hook.unwrap()) (or better: match/if let to
avoid panics) so the Arc<dyn RPCHook> passed into execute is propagated to the
admin client for ACL-enabled clusters.

Comment on lines 31 to 37
impl CommandExecute for UpdateControllerConfigSubCommand {
async fn execute(&self, rpc_hook: Option<Arc<dyn RPCHook>>) -> RocketMQResult<()> {
let mut default_mqadmin_ext = DefaultMQAdminExt::new();
default_mqadmin_ext
.client_config_mut()
.set_instance_name(get_current_millis().to_string().into());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, check the structure of this specific file to understand the full context
rg -n "rpc_hook\|DefaultMQAdminExt" rocketmq-tools/src/commands/controller_commands/update_controller_config_sub_command.rs -A 3

Repository: mxsm/rocketmq-rust

Length of output: 44


🏁 Script executed:

# Search for rpc_hook usage patterns across all command files
rg -n "rpc_hook" rocketmq-tools/src/commands/ -B 2 -A 2

Repository: mxsm/rocketmq-rust

Length of output: 16817


🏁 Script executed:

# Look for DefaultMQAdminExt instantiation patterns
rg -n "DefaultMQAdminExt::new\|DefaultMQAdminExt {" --type rust -A 5

Repository: mxsm/rocketmq-rust

Length of output: 211


🏁 Script executed:

# Check if there's a setter/method for rpc_hook on DefaultMQAdminExt
rg -n "fn.*rpc_hook|set_rpc_hook|with_rpc_hook" --type rust

Repository: mxsm/rocketmq-rust

Length of output: 7738


🏁 Script executed:

# Get the full implementation of update_controller_config_sub_command.rs
cat -n rocketmq-tools/src/commands/controller_commands/update_controller_config_sub_command.rs

Repository: mxsm/rocketmq-rust

Length of output: 3888


🏁 Script executed:

# Check the DefaultMQAdminExt definition and its methods
cat -n rocketmq-tools/src/admin/default_mq_admin_ext.rs

Repository: mxsm/rocketmq-rust

Length of output: 31583


🏁 Script executed:

# Look for how other commands might use rpc_hook with admin ext
rg -n "with_rpc_hook\|set_rpc_hook" rocketmq-tools/src/commands/ -A 2 -B 2

Repository: mxsm/rocketmq-rust

Length of output: 44


Use DefaultMQAdminExt::with_rpc_hook() to apply the provided ACL hook to the admin client.

The rpc_hook parameter received in the execute() method is never applied to DefaultMQAdminExt. Replace DefaultMQAdminExt::new() with DefaultMQAdminExt::with_rpc_hook(rpc_hook.unwrap()) or similar to propagate ACL credentials on secured clusters. Without this, ACL-authenticated requests will fail.

🤖 Prompt for AI Agents
In
`@rocketmq-tools/src/commands/controller_commands/update_controller_config_sub_command.rs`
around lines 31 - 37, In execute() the provided rpc_hook is never applied to
DefaultMQAdminExt; change the admin client construction in
UpdateControllerConfigSubCommand::execute to use
DefaultMQAdminExt::with_rpc_hook(...) when rpc_hook is Some, otherwise fall back
to DefaultMQAdminExt::new(); specifically, replace DefaultMQAdminExt::new() with
conditional construction that calls
DefaultMQAdminExt::with_rpc_hook(rpc_hook.unwrap()) (or better: match/if let to
avoid panics) so the Arc<dyn RPCHook> passed into execute is propagated to the
admin client for ACL-enabled clusters.

@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

❌ Patch coverage is 0% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.35%. Comparing base (0c7147c) to head (a7a5276).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...r_commands/update_controller_config_sub_command.rs 0.00% 47 Missing ⚠️
rocketmq-tools/src/commands/controller_commands.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5697      +/-   ##
==========================================
- Coverage   39.36%   39.35%   -0.02%     
==========================================
  Files         829      830       +1     
  Lines      114180   114228      +48     
==========================================
  Hits        44951    44951              
- Misses      69229    69277      +48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - All CI checks passed ✅

Copy link
Owner

@mxsm mxsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albertbolt1 Please resolve the conflict, thank you

Copy link
Collaborator

@rocketmq-rust-bot rocketmq-rust-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - All CI checks passed ✅

Copy link
Owner

@mxsm mxsm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mxsm mxsm merged commit 6a6fdc0 into mxsm:main Jan 19, 2026
8 of 13 checks passed
@rocketmq-rust-bot rocketmq-rust-bot added approved PR has approved and removed ready to review waiting-review waiting review this PR labels Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI review first Ai review pr first approved PR has approved auto merge Difficulty level/Moderate Moderate difficult ISSUE feature🚀 Suggest an idea for this project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature🚀] Implement Controller Command: Update Controller Config (updateControllerConfig)

4 participants