[#1422] config: Add multinet config
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
b42bcdc6fa
commit
3304afa9d1
8 changed files with 219 additions and 5 deletions
62
cmd/frostfs-node/config/multinet/config.go
Normal file
62
cmd/frostfs-node/config/multinet/config.go
Normal file
|
@ -0,0 +1,62 @@
|
|||
package multinet
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
|
||||
)
|
||||
|
||||
const (
|
||||
subsection = "multinet"
|
||||
|
||||
FallbackDelayDefault = 300 * time.Millisecond
|
||||
)
|
||||
|
||||
// Enabled returns the value of "enabled" config parameter from "multinet" section.
|
||||
func Enabled(c *config.Config) bool {
|
||||
return config.BoolSafe(c.Sub(subsection), "enabled")
|
||||
}
|
||||
|
||||
type Subnet struct {
|
||||
Mask string
|
||||
SourceIPs []string
|
||||
}
|
||||
|
||||
// Subnets returns the value of "subnets" config parameter from "multinet" section.
|
||||
func Subnets(c *config.Config) []Subnet {
|
||||
var result []Subnet
|
||||
sub := c.Sub(subsection).Sub("subnets")
|
||||
for i := 0; ; i++ {
|
||||
s := sub.Sub(strconv.FormatInt(int64(i), 10))
|
||||
mask := config.StringSafe(s, "mask")
|
||||
if mask == "" {
|
||||
break
|
||||
}
|
||||
sourceIPs := config.StringSliceSafe(s, "source_ips")
|
||||
result = append(result, Subnet{
|
||||
Mask: mask,
|
||||
SourceIPs: sourceIPs,
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Balancer returns the value of "balancer" config parameter from "multinet" section.
|
||||
func Balancer(c *config.Config) string {
|
||||
return config.StringSafe(c.Sub(subsection), "balancer")
|
||||
}
|
||||
|
||||
// Restrict returns the value of "restrict" config parameter from "multinet" section.
|
||||
func Restrict(c *config.Config) bool {
|
||||
return config.BoolSafe(c.Sub(subsection), "restrict")
|
||||
}
|
||||
|
||||
// FallbackDelay returns the value of "fallback_delay" config parameter from "multinet" section.
|
||||
func FallbackDelay(c *config.Config) time.Duration {
|
||||
fd := config.DurationSafe(c.Sub(subsection), "fallback_delay")
|
||||
if fd != 0 { // negative value means no fallback
|
||||
return fd
|
||||
}
|
||||
return FallbackDelayDefault
|
||||
}
|
52
cmd/frostfs-node/config/multinet/config_test.go
Normal file
52
cmd/frostfs-node/config/multinet/config_test.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package multinet
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
|
||||
configtest "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMultinetSection(t *testing.T) {
|
||||
t.Run("defaults", func(t *testing.T) {
|
||||
empty := configtest.EmptyConfig()
|
||||
require.Equal(t, false, Enabled(empty))
|
||||
require.Equal(t, ([]Subnet)(nil), Subnets(empty))
|
||||
require.Equal(t, "", Balancer(empty))
|
||||
require.Equal(t, false, Restrict(empty))
|
||||
require.Equal(t, FallbackDelayDefault, FallbackDelay(empty))
|
||||
})
|
||||
|
||||
const path = "../../../../config/example/node"
|
||||
|
||||
fileConfigTest := func(c *config.Config) {
|
||||
require.Equal(t, true, Enabled(c))
|
||||
require.Equal(t, []Subnet{
|
||||
{
|
||||
Mask: "192.168.219.174/24",
|
||||
SourceIPs: []string{
|
||||
"192.168.218.185",
|
||||
"192.168.219.185",
|
||||
},
|
||||
},
|
||||
{
|
||||
Mask: "10.78.70.74/24",
|
||||
SourceIPs: []string{
|
||||
"10.78.70.185",
|
||||
"10.78.71.185",
|
||||
},
|
||||
},
|
||||
}, Subnets(c))
|
||||
require.Equal(t, "roundrobin", Balancer(c))
|
||||
require.Equal(t, false, Restrict(c))
|
||||
require.Equal(t, 350*time.Millisecond, FallbackDelay(c))
|
||||
}
|
||||
|
||||
configtest.ForEachFileType(path, fileConfigTest)
|
||||
|
||||
t.Run("ENV", func(t *testing.T) {
|
||||
configtest.ForEnvFileType(t, path, fileConfigTest)
|
||||
})
|
||||
}
|
|
@ -80,3 +80,12 @@ FROSTFS_IR_PPROF_MUTEX_RATE=10000
|
|||
FROSTFS_IR_PROMETHEUS_ENABLED=true
|
||||
FROSTFS_IR_PROMETHEUS_ADDRESS=localhost:9090
|
||||
FROSTFS_IR_PROMETHEUS_SHUTDOWN_TIMEOUT=30s
|
||||
|
||||
FROSTFS_MULTINET_ENABLED=true
|
||||
FROSTFS_MULTINET_SUBNETS_0_MASK="192.168.219.174/24"
|
||||
FROSTFS_MULTINET_SUBNETS_0_SOURCE_IPS="192.168.218.185 192.168.219.185"
|
||||
FROSTFS_MULTINET_SUBNETS_1_MASK="10.78.70.74/24"
|
||||
FROSTFS_MULTINET_SUBNETS_1_SOURCE_IPS="10.78.70.185 10.78.71.185"
|
||||
FROSTFS_MULTINET_BALANCER=roundrobin
|
||||
FROSTFS_MULTINET_RESTRICT=false
|
||||
FROSTFS_MULTINET_FALLBACK_DELAY=350ms
|
||||
|
|
|
@ -123,3 +123,18 @@ prometheus:
|
|||
|
||||
systemdnotify:
|
||||
enabled: true
|
||||
|
||||
multinet:
|
||||
enabled: true
|
||||
subnets:
|
||||
- mask: 192.168.219.174/24
|
||||
source_ips:
|
||||
- 192.168.218.185
|
||||
- 192.168.219.185
|
||||
- mask: 10.78.70.74/24
|
||||
source_ips:
|
||||
- 10.78.70.185
|
||||
- 10.78.71.185
|
||||
balancer: roundrobin
|
||||
restrict: false
|
||||
fallback_delay: 350ms
|
||||
|
|
|
@ -206,3 +206,13 @@ FROSTFS_RUNTIME_SOFT_MEMORY_LIMIT=1073741824
|
|||
|
||||
# AUDIT section
|
||||
FROSTFS_AUDIT_ENABLED=true
|
||||
|
||||
# MULTINET section
|
||||
FROSTFS_MULTINET_ENABLED=true
|
||||
FROSTFS_MULTINET_SUBNETS_0_MASK="192.168.219.174/24"
|
||||
FROSTFS_MULTINET_SUBNETS_0_SOURCE_IPS="192.168.218.185 192.168.219.185"
|
||||
FROSTFS_MULTINET_SUBNETS_1_MASK="10.78.70.74/24"
|
||||
FROSTFS_MULTINET_SUBNETS_1_SOURCE_IPS="10.78.70.185 10.78.71.185"
|
||||
FROSTFS_MULTINET_BALANCER=roundrobin
|
||||
FROSTFS_MULTINET_RESTRICT=false
|
||||
FROSTFS_MULTINET_FALLBACK_DELAY=350ms
|
||||
|
|
|
@ -264,5 +264,27 @@
|
|||
},
|
||||
"audit": {
|
||||
"enabled": true
|
||||
},
|
||||
"multinet": {
|
||||
"enabled": true,
|
||||
"subnets": [
|
||||
{
|
||||
"mask": "192.168.219.174/24",
|
||||
"source_ips": [
|
||||
"192.168.218.185",
|
||||
"192.168.219.185"
|
||||
]
|
||||
},
|
||||
{
|
||||
"mask": "10.78.70.74/24",
|
||||
"source_ips":[
|
||||
"10.78.70.185",
|
||||
"10.78.71.185"
|
||||
]
|
||||
}
|
||||
],
|
||||
"balancer": "roundrobin",
|
||||
"restrict": false,
|
||||
"fallback_delay": "350ms"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,3 +240,18 @@ runtime:
|
|||
|
||||
audit:
|
||||
enabled: true
|
||||
|
||||
multinet:
|
||||
enabled: true
|
||||
subnets:
|
||||
- mask: 192.168.219.174/24
|
||||
source_ips:
|
||||
- 192.168.218.185
|
||||
- 192.168.219.185
|
||||
- mask: 10.78.70.74/24
|
||||
source_ips:
|
||||
- 10.78.70.185
|
||||
- 10.78.71.185
|
||||
balancer: roundrobin
|
||||
restrict: false
|
||||
fallback_delay: 350ms
|
||||
|
|
|
@ -25,8 +25,8 @@ There are some custom types used for brevity:
|
|||
| `replicator` | [Replicator service configuration](#replicator-section) |
|
||||
| `storage` | [Storage engine configuration](#storage-section) |
|
||||
| `runtime` | [Runtime configuration](#runtime-section) |
|
||||
| `audit` | [Audit configuration](#audit-section) |
|
||||
|
||||
| `audit` | [Audit configuration](#audit-section) |
|
||||
| `multinet` | [Multinet configuration](#multinet-section) |
|
||||
|
||||
# `control` section
|
||||
```yaml
|
||||
|
@ -435,6 +435,35 @@ audit:
|
|||
enabled: true
|
||||
```
|
||||
|
||||
| Parameter | Type | Default value | Description |
|
||||
|---------------------|--------|---------------|---------------------------------------------------|
|
||||
| `soft_memory_limit` | `bool` | false | If `true` then audit event logs will be recorded. |
|
||||
| Parameter | Type | Default value | Description |
|
||||
|-----------|--------|---------------|---------------------------------------------------|
|
||||
| `enabled` | `bool` | false | If `true` then audit event logs will be recorded. |
|
||||
|
||||
|
||||
# `multinet` section
|
||||
Contains multinet parameters.
|
||||
|
||||
```yaml
|
||||
multinet:
|
||||
enabled: true
|
||||
subnets:
|
||||
- mask: 192.168.219.174/24
|
||||
source_ips:
|
||||
- 192.168.218.185
|
||||
- 192.168.219.185
|
||||
- mask: 10.78.70.74/24
|
||||
source_ips:
|
||||
- 10.78.70.185
|
||||
- 10.78.71.185
|
||||
balancer: roundrobin
|
||||
restrict: false
|
||||
fallback_delay: 350ms
|
||||
```
|
||||
|
||||
| Parameter | Type | Default value | Description |
|
||||
| ---------------- | ---------- | ------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `enabled` | `bool` | false | If `true` then source-based routing is enabled. |
|
||||
| `subnets` | `subnet` | empty | Resulting subnets. |
|
||||
| `balancer` | `string` | "" | Balancer to select network interfaces, allowed values are "" (no balancing, use first suitable interface) or "roundrobin". |
|
||||
| `restrict` | `bool` | false | If `true` then any requests that do not match `subnets` will fail. |
|
||||
| `fallback_delay` | `duration` | 350ms | Delay before fallback to secondary IP addresses in case of hostname resolve. |
|
||||
|
|
Loading…
Reference in a new issue