add rpc_public_addr_subnet config option #817

Merged
lx merged 1 commit from flokli/garage:rpc_public_addr_subnet into main 2024-06-18 12:40:08 +00:00
Contributor

In case rpc_public_addr is not set, but autodiscovery is used, this
allows filtering the list of automatically discovered IPs to a specific
subnet.

For example, if nodes should pick their IP inside a specific subnet,
but you don't want to explicitly write the IP down (as it's dynamic, or
you want to share configs across nodes), you can use this option.

Fixes #811.

In case `rpc_public_addr` is not set, but autodiscovery is used, this allows filtering the list of automatically discovered IPs to a specific subnet. For example, if nodes should pick *their* IP inside a specific subnet, but you don't want to explicitly write the IP down (as it's dynamic, or you want to share configs across nodes), you can use this option. Fixes https://git.deuxfleurs.fr/Deuxfleurs/garage/issues/811.
flokli changed title from add rpc_public_addr_subnet config option to WIP: add rpc_public_addr_subnet config option 2024-04-23 09:18:25 +00:00
flokli reviewed 2024-04-23 09:24:56 +00:00
Cargo.toml Outdated
@ -55,6 +55,7 @@ hexdump = "0.1"
hmac = "0.12"
idna = "0.5"
itertools = "0.12"
ipnet = "2.9.0"
Author
Contributor

This was already in the list of dependencies (through reqwest), but we now explicitly depend on it, too.

This was already in the list of dependencies (through `reqwest`), but we now explicitly depend on it, too.
flokli force-pushed rpc_public_addr_subnet from 79729da4af to 3dc836afcb 2024-04-23 09:38:18 +00:00 Compare
flokli force-pushed rpc_public_addr_subnet from 3dc836afcb to 6d0b343232 2024-05-07 08:23:50 +00:00 Compare
flokli changed title from WIP: add rpc_public_addr_subnet config option to add rpc_public_addr_subnet config option 2024-05-07 08:23:56 +00:00
Author
Contributor

I applied this to all cluster nodes, then set my desired netmask in the option provided above, and indeed I don't see any other IP addresses anymore.

Happy to keep it running for some more time, but I think this is ready for review now :-)

I applied this to all cluster nodes, then set my desired netmask in the option provided above, and indeed I don't see any other IP addresses anymore. Happy to keep it running for some more time, but I think this is ready for review now :-)
lx requested changes 2024-05-24 16:25:58 +00:00
Dismissed
@ -543,6 +543,14 @@ RPC calls. **This parameter is optional but recommended.** In case you have
a NAT that binds the RPC port to a port that is different on your public IP,
this field might help making it work.
#### `rpc_public_addr_subnet` {#rpc_public_addr_subnet}
Owner

New options should also be added in the example config file at the beginning of the page (that contains an instance of all configuration parameters), as well as in the index/list of everything at the beginning of "available configuration options".

New options should also be added in the example config file at the beginning of the page (that contains an instance of all configuration parameters), as well as in the index/list of everything at the beginning of "available configuration options".
Author
Contributor

rpc_public_addr_subnet only applies if rpc_public_addr is not set (as it influences autodiscovery), which only happens if that is not set.

I added a comment, and a commented-out example value.

`rpc_public_addr_subnet` only applies if `rpc_public_addr` is not set (as it influences autodiscovery), which only happens if that is not set. I added a comment, and a commented-out example value.
@ -881,0 +901,4 @@
error!(
"Cannot parse rpc_public_addr_subnet {} from config file: {}. Ignoring.",
filter_subnet_str, e
);
Owner

I think we probably want this to be a hard error that makes garage exit immediately, because the only reason for this is a syntax error in the config file which is the admin's fault

I think we probably want this to be a hard error that makes garage exit immediately, because the only reason for this is a syntax error in the config file which is the admin's fault
Author
Contributor

I made this a panic!. This function doesn't return errors, and threading that through would be a bit more of a diff.
It seems panic! is also commonly used in other places that deal with config parsing.

Long-term, we probably want to move these parsing concerns to much earlier into the CLI code, not that late, but that also feels out of scope for this PR.

I made this a `panic!`. This function doesn't return errors, and threading that through would be a bit more of a diff. It seems `panic!` is also commonly used in other places that deal with config parsing. Long-term, we probably want to move these parsing concerns to much earlier into the CLI code, not that late, but that also feels out of scope for this PR.
flokli force-pushed rpc_public_addr_subnet from 6d0b343232 to 600f8c5c90 2024-05-24 19:30:43 +00:00 Compare
flokli requested review from lx 2024-05-25 11:23:29 +00:00
lx requested changes 2024-05-29 14:42:29 +00:00
Dismissed
lx left a comment
Owner

Tiny changes, thanks for your patience

Tiny changes, thanks for your patience
@ -543,6 +546,14 @@ RPC calls. **This parameter is optional but recommended.** In case you have
a NAT that binds the RPC port to a port that is different on your public IP,
this field might help making it work.
#### `rpc_public_addr_subnet` {#rpc_public_addr_subnet}
Owner

A reference should also be added in the list that starts on line 93

A reference should also be added in the list that starts on line 93
Author
Contributor

Done

Done
flokli marked this conversation as resolved
@ -881,0 +892,4 @@
.and_then(|filter_subnet_str| match filter_subnet_str.parse::<ipnet::IpNet>() {
Ok(filter_subnet) => {
let filter_subnet_trunc = filter_subnet.trunc();
if filter_subnet.trunc() != filter_subnet {
Owner

this code calls .trunc() again instead of using the filter_subnet_trunc variable

this code calls `.trunc()` again instead of using the `filter_subnet_trunc` variable
Author
Contributor

Good catch! Might have missed while moving things around. Updated.

Good catch! Might have missed while moving things around. Updated.
flokli marked this conversation as resolved
flokli force-pushed rpc_public_addr_subnet from 600f8c5c90 to a0f6bc5b7f 2024-06-05 06:42:23 +00:00 Compare
flokli requested review from lx 2024-06-09 11:15:15 +00:00
lx approved these changes 2024-06-18 12:39:59 +00:00
lx left a comment
Owner

Thanks!

Thanks!
lx merged commit 770384cae1 into main 2024-06-18 12:40:08 +00:00
flokli deleted branch rpc_public_addr_subnet 2024-07-10 13:38:17 +00:00
Sign in to join this conversation.
No reviewers
lx
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Deuxfleurs/garage#817
No description provided.