Skip to content

Commit 113dd67

Browse files
committed
Fix nats-servers format in docs, examples, and specs
The Ruby MCollective server_resolver splits middleware_hosts on ':', so 'nats://broker:4222' produces three elements instead of two and breaks the NATS connection. The correct format is 'host:port' without the nats:// prefix because the NATS connector adds the scheme itself when constructing URIs. Signed-off-by: nmburgan <13688219+nmburgan@users.noreply.github.com>
1 parent 07f6b87 commit 113dd67

8 files changed

Lines changed: 15 additions & 14 deletions

File tree

developer-docs/choria/choria-transport-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ libdir = /opt/puppetlabs/mcollective/plugins
146146
logger_type = console
147147
loglevel = warn
148148
securityprovider = choria
149-
plugin.choria.middleware_hosts = nats://primary.example.com:4222
149+
plugin.choria.middleware_hosts = primary.example.com:4222
150150
plugin.security.provider = file
151151
plugin.security.file.certificate = ~/.puppetlabs/etc/puppet/ssl/certs/<username>.mcollective.pem
152152
plugin.security.file.key = ~/.puppetlabs/etc/puppet/ssl/private_keys/<username>.mcollective.pem

documentation/choria-transport.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ targets:
5252
choria:
5353
collective: production
5454
nats-servers:
55-
- nats://broker1:4222
56-
- nats://broker2:4222
55+
- broker1:4222
56+
- broker2:4222
5757
```
5858
5959
If the config file is in one of the auto-detected locations (`~/.choriarc`,
@@ -97,7 +97,7 @@ targets:
9797
| `interpreters` | | Hash | (none) | File extension to interpreter mapping (e.g., `{".rb": "/usr/bin/ruby"}`). |
9898
| `mcollective-certname` | `--choria-mcollective-certname` | String | (auto) | Override the MCollective certname for Choria client identity. See [Non-root certname](#non-root-certname) below. |
9999
| `nats-connection-timeout` | `--nats-connection-timeout` | Integer | `30` | Seconds to wait for the TCP connection to the NATS broker. |
100-
| `nats-servers` | `--nats-servers` | String or Array | (from config file) | NATS broker addresses in `nats://host:port` format (comma-separated for multiple). Multiple servers provide failover if a broker is unavailable. Overrides the config file. |
100+
| `nats-servers` | `--nats-servers` | String or Array | (from config file) | NATS broker addresses in `host:port` format (comma-separated for multiple). Do not use the `nats://` prefix. Multiple servers provide failover if a broker is unavailable. Overrides the config file. |
101101
| `puppet-environment` | `--choria-puppet-environment` | String | `production` | Puppet environment for bolt_tasks file URIs. |
102102
| `rpc-timeout` | `--choria-rpc-timeout` | Integer | `30` | Seconds to wait for replies to individual RPC calls. |
103103
| `ssl-ca` | `--choria-ssl-ca` | String | (from config file) | CA certificate path for TLS. |

lib/bolt/bolt_option_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ def initialize(options)
11501150
@options[:'command-timeout'] = timeout
11511151
end
11521152
define('--nats-servers SERVERS',
1153-
'NATS broker addresses in nats://host:port format (comma-separated for multiple).') do |servers|
1153+
'NATS broker addresses in host:port format (comma-separated for multiple). Do not use the nats:// prefix.') do |servers|
11541154
@options[:'nats-servers'] = servers
11551155
end
11561156
define('--nats-connection-timeout SECONDS', Integer,

lib/bolt/config/transport/options.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,14 @@ module Options
286286
},
287287
"nats-servers" => {
288288
type: [String, Array],
289-
description: "One or more NATS server addresses for the Choria transport. Overrides the middleware " \
290-
"hosts from the Choria client configuration file. Can be a single string or an array.",
289+
description: "One or more NATS server addresses in host:port format for the Choria transport. " \
290+
"Do not use the nats:// prefix. Overrides the middleware hosts from the Choria " \
291+
"client configuration file. Can be a single string or an array.",
291292
items: {
292293
type: String
293294
},
294295
_plugin: true,
295-
_example: ["nats://broker1:4222", "nats://broker2:4222"]
296+
_example: ["broker1:4222", "broker2:4222"]
296297
},
297298
"native-ssh" => {
298299
type: [TrueClass, FalseClass],

schemas/bolt-defaults.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@
21672167
]
21682168
},
21692169
"nats-servers": {
2170-
"description": "One or more NATS server addresses for the Choria transport. Overrides the middleware hosts from the Choria client configuration file. Can be a single string or an array.",
2170+
"description": "One or more NATS server addresses in host:port format for the Choria transport. Do not use the nats:// prefix. Overrides the middleware hosts from the Choria client configuration file. Can be a single string or an array.",
21712171
"oneOf": [
21722172
{
21732173
"type": [

schemas/bolt-inventory.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
]
164164
},
165165
"nats-servers": {
166-
"description": "One or more NATS server addresses for the Choria transport. Overrides the middleware hosts from the Choria client configuration file. Can be a single string or an array.",
166+
"description": "One or more NATS server addresses in host:port format for the Choria transport. Do not use the nats:// prefix. Overrides the middleware hosts from the Choria client configuration file. Can be a single string or an array.",
167167
"oneOf": [
168168
{
169169
"type": [

spec/unit/config/transport/choria_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
end
3838

3939
it 'nats-servers accepts a string' do
40-
data['nats-servers'] = 'nats://broker:4222'
40+
data['nats-servers'] = 'broker:4222'
4141
expect { transport.new(data) }.not_to raise_error
4242
end
4343

4444
it 'nats-servers accepts an array' do
45-
data['nats-servers'] = ['nats://broker1:4222', 'nats://broker2:4222']
45+
data['nats-servers'] = ['broker1:4222', 'broker2:4222']
4646
expect { transport.new(data) }.not_to raise_error
4747
end
4848

spec/unit/transport/choria/client_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@
7575
end
7676

7777
it 'applies NATS server overrides to pluginconf' do
78-
inventory.set_config(target, %w[choria nats-servers], %w[nats://broker1:4222 nats://broker2:4222])
78+
inventory.set_config(target, %w[choria nats-servers], %w[broker1:4222 broker2:4222])
7979

8080
transport.configure_client(target)
8181

8282
mc_config = MCollective::Config.instance
83-
expect(mc_config.pluginconf['choria.middleware_hosts']).to eq('nats://broker1:4222,nats://broker2:4222')
83+
expect(mc_config.pluginconf['choria.middleware_hosts']).to eq('broker1:4222,broker2:4222')
8484
end
8585

8686
it 'applies TLS overrides to pluginconf' do

0 commit comments

Comments
 (0)