Skip to content

Derived endpoint does not match configuration file settings #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dylannorthrup opened this issue Apr 9, 2025 · 2 comments
Open
Labels
bug Something isn't working

Comments

@dylannorthrup
Copy link

Describe the bug

Bug Description

I'm trying to run rabbitmq-ng against a remote system. When things did not work, I added some debugging to a local version of the repository to get more information. I am not a Rust programmer, so this is as far as I was able to go, but it shows the settings in my ~/.rabbitmqadmin.conf file are being read, but the derived common_settings do not use the values in the config file for the following parameters:

  • port
  • scheme
  • tls

Reproduction steps

  1. Run rabbitmq-server instance on a remote host
  2. Create a configuration section (eg. test) for that instance in ~/.rabbitmqadmin.conf with the following settings changed from their defaults:
  • port set to 15671
  • tls set to true
  • scheme set to "https"
  1. Run rabbitmqadmin -N test list nodes
  2. Observe it will error and report an incorrect endpoint URL (using http instead of https and port 15672 instead of 15671)

Expected behavior

rabbitmqadmin should try to connect using the port and scheme specified in the ~/.rabbitmqadmin.conf file.

Additional context

The following output log was run from the top of a checked out version of this repository and shows a) the contents of ~/.rabbitmqadmin.conf; b) git diff output; c) execution of cargo build --offline1; and d) the debug output and error showing the wrong URL being used as an endpoint.

hostname> cat ~/.rabbitmqadmin.conf
[test]
hostname = "test-rabbitmq.example.com"
port = 15671
scheme = "https"
tls = true
username = "rabbitmq"
password = "hunter2"
hostname> git diff
diff --git a/src/main.rs b/src/main.rs
index b691c3a..154bd1f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -73,6 +73,8 @@ fn main() {
         .or(Some(DEFAULT_NODE_ALIAS.to_string()));

     let cf_ss = SharedSettings::from_config_file(&config_file_path, node_alias.clone());
+    let cf_ss_clone = SharedSettings::from_config_file(&config_file_path, node_alias.clone());
+    eprintln!("main() Shared Settings from Config File: '{:?}'", cf_ss_clone);
     // If the default config file path is used and the function above
     // reports that it is not found, continue. Otherwise exit.
     if cf_ss.is_err() && !uses_default_config_file_path {
@@ -83,13 +85,27 @@ fn main() {
         );
         eprintln!("Underlying error: {}", cf_ss.unwrap_err());
         process::exit(ExitCode::DataErr.into())
+    } else {
+        eprintln!(
+            "Using node alias '{}' from configuration file '{}'",
+            &node_alias.unwrap(),
+            config_file_path.to_str().unwrap()
+        );
     }
     let common_settings = if let Ok(val) = cf_ss {
         SharedSettings::from_args_with_defaults(&cli, &val)
     } else {
         SharedSettings::from_args(&cli)
     };
+    let common_settings_clone = if let Ok(val) = cf_ss_clone {
+        SharedSettings::from_args_with_defaults(&cli, &val)
+    } else {
+        SharedSettings::from_args(&cli)
+    };
+    eprintln!("main(): common_settings value is '{:?}'", common_settings_clone);
     let endpoint = common_settings.endpoint();
+    let endpoint_clone = common_settings.endpoint();
+    eprintln!("main(): endpoint is '{}'", endpoint_clone);

     let httpc_result = build_http_client(&cli, &common_settings);
     match httpc_result {
hostname> cargo build --offline
   Compiling rabbitmqadmin v2.1.0 (/path/to/repo/rabbitmqadmin-ng)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 13.79s
hostname> ./target/debug/rabbitmqadmin -N test list nodes
main() Shared Settings from Config File: 'Ok(SharedSettings { base_uri: None, tls: true, non_interactive: false, quiet: false, scheme: "https", hostname: Some("test-rabbitmq.example.com"), port: Some(15671), path_prefix: "/api", username: Some("rabbitmq"), password: Some("hunter2"), virtual_host: None, table_style: None })'
Using node alias 'test' from configuration file '~/.rabbitmqadmin.conf'
main(): common_settings value is 'SharedSettings { base_uri: None, tls: false, non_interactive: false, quiet: false, scheme: "http", hostname: Some("test-rabbitmq.example.com"), port: Some(15672), path_prefix: "/api", username: Some("rabbitmq"), password: Some("hunter2"), virtual_host: Some("/"), table_style: Some(Modern) }'
main(): endpoint is 'http://test-rabbitmq.example.com:15672/api'
┌────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ key    │ value                                                                                                     │
├────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ result │ request failed                                                                                            │
├────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ reason │ HTTP API request failed: error sending request for url (http://test-rabbitmq.example.com:15672/api/nodes) │
└────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────┘
hostname>

Footnotes

  1. As a rust novice, this is the method I landed on to do a rebuild from my local modifications of the source. I had previously done a cargo install rabbitmqadmin which copied down the dependencies. I do not claim this is the best way to do a rebuild of the client, it's simply the method I found that worked.

@dylannorthrup dylannorthrup added the bug Something isn't working label Apr 9, 2025
@michaelklishin
Copy link
Collaborator

@dylannorthrup thank you for sharing the details.

@michaelklishin
Copy link
Collaborator

This has not been forgotten but I try to refactor the CLI interface first, based on the first wave of feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants