[#2164] neofs-node: Allow to set reconnect interval
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
6f5edac730
commit
741482c26f
10 changed files with 34 additions and 8 deletions
|
@ -15,6 +15,7 @@ Changelog for NeoFS Node
|
||||||
- `neofs_node_object_*_req_count_success` prometheus metrics for tracking successfully executed requests (#1984)
|
- `neofs_node_object_*_req_count_success` prometheus metrics for tracking successfully executed requests (#1984)
|
||||||
- Metric 'readonly' to get shards mode (#2022)
|
- Metric 'readonly' to get shards mode (#2022)
|
||||||
- Tree service replication timeout (#2159)
|
- Tree service replication timeout (#2159)
|
||||||
|
- `apiclient.reconnect_timeout` setting allowing to ignore failed clients for some time (#2164)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- `object lock` command reads CID and OID the same way other commands do (#1971)
|
- `object lock` command reads CID and OID the same way other commands do (#1971)
|
||||||
|
|
|
@ -565,6 +565,7 @@ func initCfg(appCfg *config.Config) *cfg {
|
||||||
StreamTimeout: apiclientconfig.StreamTimeout(appCfg),
|
StreamTimeout: apiclientconfig.StreamTimeout(appCfg),
|
||||||
Key: &key.PrivateKey,
|
Key: &key.PrivateKey,
|
||||||
AllowExternal: apiclientconfig.AllowExternal(appCfg),
|
AllowExternal: apiclientconfig.AllowExternal(appCfg),
|
||||||
|
ReconnectTimeout: apiclientconfig.ReconnectTimeout(appCfg),
|
||||||
}
|
}
|
||||||
c.shared = shared{
|
c.shared = shared{
|
||||||
key: key,
|
key: key,
|
||||||
|
|
|
@ -42,6 +42,19 @@ func StreamTimeout(c *config.Config) time.Duration {
|
||||||
return StreamTimeoutDefault
|
return StreamTimeoutDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReconnectTimeout returns the value of "reconnect_timeout" config parameter
|
||||||
|
// from "apiclient" section.
|
||||||
|
//
|
||||||
|
// Returns 0 if the value is not positive duration.
|
||||||
|
func ReconnectTimeout(c *config.Config) time.Duration {
|
||||||
|
v := config.DurationSafe(c.Sub(subsection), "reconnect_timeout")
|
||||||
|
if v > 0 {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
// AllowExternal returns the value of "allow_external" config parameter
|
// AllowExternal returns the value of "allow_external" config parameter
|
||||||
// from "apiclient" section.
|
// from "apiclient" section.
|
||||||
//
|
//
|
||||||
|
|
|
@ -16,6 +16,7 @@ func TestApiclientSection(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, apiclientconfig.DialTimeoutDefault, apiclientconfig.DialTimeout(empty))
|
require.Equal(t, apiclientconfig.DialTimeoutDefault, apiclientconfig.DialTimeout(empty))
|
||||||
require.Equal(t, apiclientconfig.StreamTimeoutDefault, apiclientconfig.StreamTimeout(empty))
|
require.Equal(t, apiclientconfig.StreamTimeoutDefault, apiclientconfig.StreamTimeout(empty))
|
||||||
|
require.Equal(t, time.Duration(0), apiclientconfig.ReconnectTimeout(empty))
|
||||||
require.False(t, apiclientconfig.AllowExternal(empty))
|
require.False(t, apiclientconfig.AllowExternal(empty))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ func TestApiclientSection(t *testing.T) {
|
||||||
var fileConfigTest = func(c *config.Config) {
|
var fileConfigTest = func(c *config.Config) {
|
||||||
require.Equal(t, 15*time.Second, apiclientconfig.DialTimeout(c))
|
require.Equal(t, 15*time.Second, apiclientconfig.DialTimeout(c))
|
||||||
require.Equal(t, 20*time.Second, apiclientconfig.StreamTimeout(c))
|
require.Equal(t, 20*time.Second, apiclientconfig.StreamTimeout(c))
|
||||||
|
require.Equal(t, 30*time.Second, apiclientconfig.ReconnectTimeout(c))
|
||||||
require.True(t, apiclientconfig.AllowExternal(c))
|
require.True(t, apiclientconfig.AllowExternal(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ NEOFS_MORPH_RPC_ENDPOINT_1_PRIORITY=2
|
||||||
# API Client section
|
# API Client section
|
||||||
NEOFS_APICLIENT_DIAL_TIMEOUT=15s
|
NEOFS_APICLIENT_DIAL_TIMEOUT=15s
|
||||||
NEOFS_APICLIENT_STREAM_TIMEOUT=20s
|
NEOFS_APICLIENT_STREAM_TIMEOUT=20s
|
||||||
|
NEOFS_APICLIENT_RECONNECT_TIMEOUT=30s
|
||||||
NEOFS_APICLIENT_ALLOW_EXTERNAL=true
|
NEOFS_APICLIENT_ALLOW_EXTERNAL=true
|
||||||
|
|
||||||
# Policer section
|
# Policer section
|
||||||
|
|
|
@ -117,6 +117,7 @@
|
||||||
"apiclient": {
|
"apiclient": {
|
||||||
"dial_timeout": "15s",
|
"dial_timeout": "15s",
|
||||||
"stream_timeout": "20s",
|
"stream_timeout": "20s",
|
||||||
|
"reconnect_timeout": "30s",
|
||||||
"allow_external": true
|
"allow_external": true
|
||||||
},
|
},
|
||||||
"policer": {
|
"policer": {
|
||||||
|
|
|
@ -97,6 +97,7 @@ apiclient:
|
||||||
dial_timeout: 15s # timeout for NEOFS API client connection
|
dial_timeout: 15s # timeout for NEOFS API client connection
|
||||||
stream_timeout: 20s # timeout for individual operations in a streaming RPC
|
stream_timeout: 20s # timeout for individual operations in a streaming RPC
|
||||||
allow_external: true # allow to fallback to addresses in `ExternalAddr` attribute
|
allow_external: true # allow to fallback to addresses in `ExternalAddr` attribute
|
||||||
|
reconnect_timeout: 30s # time to wait before reconnecting to a failed node
|
||||||
|
|
||||||
policer:
|
policer:
|
||||||
head_timeout: 15s # timeout for the Policer HEAD remote operation
|
head_timeout: 15s # timeout for the Policer HEAD remote operation
|
||||||
|
|
|
@ -378,11 +378,13 @@ Configuration for the NeoFS API client used for communication with other NeoFS n
|
||||||
apiclient:
|
apiclient:
|
||||||
dial_timeout: 15s
|
dial_timeout: 15s
|
||||||
stream_timeout: 20s
|
stream_timeout: 20s
|
||||||
|
reconnect_timeout: 30s
|
||||||
```
|
```
|
||||||
| Parameter | Type | Default value | Description |
|
| Parameter | Type | Default value | Description |
|
||||||
|----------------|----------|---------------|-----------------------------------------------------------------------|
|
|-------------------|----------|---------------|-----------------------------------------------------------------------|
|
||||||
| dial_timeout | duration | `5s` | Timeout for dialing connections to other storage or inner ring nodes. |
|
| dial_timeout | duration | `5s` | Timeout for dialing connections to other storage or inner ring nodes. |
|
||||||
| stream_timeout | duration | `15s` | Timeout for individual operations in a streaming RPC. |
|
| stream_timeout | duration | `15s` | Timeout for individual operations in a streaming RPC. |
|
||||||
|
| reconnect_timeout | duration | `30s` | Time to wait before reconnecting to a failed node. |
|
||||||
|
|
||||||
# `policer` section
|
# `policer` section
|
||||||
|
|
||||||
|
|
1
pkg/network/cache/client.go
vendored
1
pkg/network/cache/client.go
vendored
|
@ -21,6 +21,7 @@ type (
|
||||||
ClientCacheOpts struct {
|
ClientCacheOpts struct {
|
||||||
DialTimeout time.Duration
|
DialTimeout time.Duration
|
||||||
StreamTimeout time.Duration
|
StreamTimeout time.Duration
|
||||||
|
ReconnectTimeout time.Duration
|
||||||
Key *ecdsa.PrivateKey
|
Key *ecdsa.PrivateKey
|
||||||
ResponseCallback func(client.ResponseMetaInfo) error
|
ResponseCallback func(client.ResponseMetaInfo) error
|
||||||
AllowExternal bool
|
AllowExternal bool
|
||||||
|
|
3
pkg/network/cache/multi.go
vendored
3
pkg/network/cache/multi.go
vendored
|
@ -36,6 +36,9 @@ type multiClient struct {
|
||||||
const defaultReconnectInterval = time.Second * 30
|
const defaultReconnectInterval = time.Second * 30
|
||||||
|
|
||||||
func newMultiClient(addr network.AddressGroup, opts ClientCacheOpts) *multiClient {
|
func newMultiClient(addr network.AddressGroup, opts ClientCacheOpts) *multiClient {
|
||||||
|
if opts.ReconnectTimeout <= 0 {
|
||||||
|
opts.ReconnectTimeout = defaultReconnectInterval
|
||||||
|
}
|
||||||
return &multiClient{
|
return &multiClient{
|
||||||
clients: make(map[string]*singleClient),
|
clients: make(map[string]*singleClient),
|
||||||
addr: addr,
|
addr: addr,
|
||||||
|
|
Loading…
Reference in a new issue