[#1422] config: Add multinet config
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
936ebbb8e5
commit
4379e85994
6 changed files with 136 additions and 5 deletions
42
cmd/frostfs-node/config/multinet/config.go
Normal file
42
cmd/frostfs-node/config/multinet/config.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package multinet
|
||||
|
||||
import (
|
||||
"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")
|
||||
}
|
||||
|
||||
// Subnets returns the value of "subnets" config parameter from "multinet" section.
|
||||
func Subnets(c *config.Config) []string {
|
||||
return config.StringSliceSafe(c.Sub(subsection), "subnets")
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
40
cmd/frostfs-node/config/multinet/config_test.go
Normal file
40
cmd/frostfs-node/config/multinet/config_test.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
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, ([]string)(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, []string{
|
||||
"192.168.219.174/24",
|
||||
"10.78.70.74/23",
|
||||
}, 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)
|
||||
})
|
||||
}
|
|
@ -206,3 +206,10 @@ FROSTFS_RUNTIME_SOFT_MEMORY_LIMIT=1073741824
|
|||
|
||||
# AUDIT section
|
||||
FROSTFS_AUDIT_ENABLED=true
|
||||
|
||||
# MULTINET section
|
||||
FROSTFS_MULTINET_ENABLED=true
|
||||
FROSTFS_MULTINET_SUBNETS="192.168.219.174/24 10.78.70.74/23"
|
||||
FROSTFS_MULTINET_BALANCER=roundrobin
|
||||
FROSTFS_MULTINET_RESTRICT=false
|
||||
FROSTFS_MULTINET_FALLBACK_DELAY=350ms
|
||||
|
|
|
@ -264,5 +264,15 @@
|
|||
},
|
||||
"audit": {
|
||||
"enabled": true
|
||||
},
|
||||
"multinet": {
|
||||
"enabled": true,
|
||||
"subnets": [
|
||||
"192.168.219.174/24",
|
||||
"10.78.70.74/23"
|
||||
],
|
||||
"balancer": "roundrobin",
|
||||
"restrict": false,
|
||||
"fallback_delay": "350ms"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,3 +240,12 @@ runtime:
|
|||
|
||||
audit:
|
||||
enabled: true
|
||||
|
||||
multinet:
|
||||
enabled: true
|
||||
subnets:
|
||||
- 192.168.219.174/24
|
||||
- 10.78.70.74/23
|
||||
balancer: roundrobin
|
||||
restrict: false
|
||||
fallback_delay: 350ms
|
||||
|
|
|
@ -26,7 +26,7 @@ There are some custom types used for brevity:
|
|||
| `storage` | [Storage engine configuration](#storage-section) |
|
||||
| `runtime` | [Runtime configuration](#runtime-section) |
|
||||
| `audit` | [Audit configuration](#audit-section) |
|
||||
|
||||
| `multinet` | [Multinet configuration](#audit-section) |
|
||||
|
||||
# `control` section
|
||||
```yaml
|
||||
|
@ -436,5 +436,28 @@ audit:
|
|||
```
|
||||
|
||||
| Parameter | Type | Default value | Description |
|
||||
|---------------------|--------|---------------|---------------------------------------------------|
|
||||
| `soft_memory_limit` | `bool` | false | If `true` then audit event logs will be recorded. |
|
||||
|-----------|--------|---------------|---------------------------------------------------|
|
||||
| `enabled` | `bool` | false | If `true` then audit event logs will be recorded. |
|
||||
|
||||
|
||||
# `multinet` section
|
||||
Contains multinet parameters.
|
||||
|
||||
```yaml
|
||||
multinet:
|
||||
enabled: true
|
||||
subnets:
|
||||
- 192.168.219.174/24
|
||||
- 10.78.70.74/23
|
||||
balancer: roundrobin
|
||||
restrict: false
|
||||
fallback_delay: 350ms
|
||||
```
|
||||
|
||||
| Parameter | Type | Default value | Description |
|
||||
| ---------------- | ---------- | ------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `enabled` | `bool` | false | If `true` then source-based routing is enabled. |
|
||||
| `subnets` | `[]string` | 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