From d1825f97fb264edb0bc533cdc994f450da48a1c2 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Tue, 15 Nov 2022 17:19:21 +0300 Subject: [PATCH] [#750] Update SDK to support timeout for stream Signed-off-by: Denis Kirillov --- CHANGELOG.md | 1 + cmd/s3-gw/app.go | 8 +++++++- cmd/s3-gw/app_settings.go | 3 +++ config/config.env | 2 ++ config/config.yaml | 2 ++ docs/configuration.md | 2 ++ go.mod | 2 +- go.sum | 4 ++-- 8 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a84455..8c8ca88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This document outlines major changes between releases. ### Added - Use client time as `now` in some requests (#726) +- Timeout for individual operations in streaming RPC (#740) ### Changed - Placement policy configuration (#568) diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index f042c3e..8ccb3f9 100644 --- a/cmd/s3-gw/app.go +++ b/cmd/s3-gw/app.go @@ -246,11 +246,17 @@ func getPool(ctx context.Context, logger *zap.Logger, cfg *viper.Viper) (*pool.P } prm.SetNodeDialTimeout(connTimeout) + streamTimeout := cfg.GetDuration(cfgStreamTimeout) + if streamTimeout <= 0 { + streamTimeout = defaultStreamTimeout + } + prm.SetNodeStreamTimeout(streamTimeout) + healthCheckTimeout := cfg.GetDuration(cfgHealthcheckTimeout) if healthCheckTimeout <= 0 { healthCheckTimeout = defaultHealthcheckTimeout } - prm.SetNodeDialTimeout(healthCheckTimeout) + prm.SetHealthcheckTimeout(healthCheckTimeout) rebalanceInterval := cfg.GetDuration(cfgRebalanceInterval) if rebalanceInterval <= 0 { diff --git a/cmd/s3-gw/app_settings.go b/cmd/s3-gw/app_settings.go index 5a60aa1..c19b500 100644 --- a/cmd/s3-gw/app_settings.go +++ b/cmd/s3-gw/app_settings.go @@ -22,6 +22,7 @@ const ( defaultRebalanceInterval = 60 * time.Second defaultHealthcheckTimeout = 15 * time.Second defaultConnectTimeout = 10 * time.Second + defaultStreamTimeout = 10 * time.Second defaultShutdownTimeout = 15 * time.Second defaultPoolErrorThreshold uint32 = 100 @@ -47,6 +48,7 @@ const ( // Settings. // Pool config. cfgConnectTimeout = "connect_timeout" + cfgStreamTimeout = "stream_timeout" cfgHealthcheckTimeout = "healthcheck_timeout" cfgRebalanceInterval = "rebalance_interval" cfgPoolErrorThreshold = "pool_error_threshold" @@ -214,6 +216,7 @@ func newSettings() *viper.Viper { // pool: v.SetDefault(cfgPoolErrorThreshold, defaultPoolErrorThreshold) + v.SetDefault(cfgStreamTimeout, defaultStreamTimeout) v.SetDefault(cfgPProfAddress, "localhost:8085") v.SetDefault(cfgPrometheusAddress, "localhost:8086") diff --git a/config/config.env b/config/config.env index 1c3b19d..345a3cc 100644 --- a/config/config.env +++ b/config/config.env @@ -53,6 +53,8 @@ S3_GW_PROMETHEUS_ADDRESS=localhost:8086 # Timeout to connect to a node S3_GW_CONNECT_TIMEOUT=10s +# Timeout for individual operations in streaming RPC. +S3_GW_STREAM_TIMEOUT=10s # Timeout to check node health during rebalance. S3_GW_HEALTHCHECK_TIMEOUT=15s # Interval to check node health diff --git a/config/config.yaml b/config/config.yaml index 79b9b6f..7fd413f 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -58,6 +58,8 @@ prometheus: # Timeout to connect to a node connect_timeout: 10s +# Timeout for individual operations in streaming RPC. +stream_timeout: 10s # Timeout to check node health during rebalance healthcheck_timeout: 15s # Interval to check node health diff --git a/docs/configuration.md b/docs/configuration.md index 7f4dee5..e28a1bc 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -180,6 +180,7 @@ resolve_order: - dns connect_timeout: 10s +stream_timeout: 10s healthcheck_timeout: 15s rebalance_interval: 60s pool_error_threshold: 100 @@ -199,6 +200,7 @@ allowed_access_key_id_prefixes: | `rpc_endpoint` | `string` | yes | | The address of the RPC host to which the gateway connects to resolve bucket names (required to use the `nns` resolver). | | `resolve_order` | `[]string` | yes | `[dns]` | Order of bucket name resolvers to use. Available resolvers: `dns`, `nns`. | | | `connect_timeout` | `duration` | | `10s` | Timeout to connect to a node. | +| `stream_timeout` | `duration` | | `10s` | Timeout for individual operations in streaming RPC. | | `healthcheck_timeout` | `duration` | | `15s` | Timeout to check node health during rebalance. | | `rebalance_interval` | `duration` | | `60s` | Interval to check node health. | | `pool_error_threshold` | `uint32` | | `100` | The number of errors on connection after which node is considered as unhealthy. | diff --git a/go.mod b/go.mod index 7ddeed3..f2b6b34 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/nats-io/nats.go v1.13.1-0.20220121202836-972a071d373d github.com/nspcc-dev/neo-go v0.99.4 github.com/nspcc-dev/neofs-api-go/v2 v2.14.0 - github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221114144617-d047289182a1 + github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221115140820-b4b07a3c4e11 github.com/panjf2000/ants/v2 v2.5.0 github.com/prometheus/client_golang v1.13.0 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 0faf31f..5529c8c 100644 --- a/go.sum +++ b/go.sum @@ -374,8 +374,8 @@ github.com/nspcc-dev/neofs-crypto v0.4.0 h1:5LlrUAM5O0k1+sH/sktBtrgfWtq1pgpDs09f github.com/nspcc-dev/neofs-crypto v0.4.0/go.mod h1:6XJ8kbXgOfevbI2WMruOtI+qUJXNwSGM/E9eClXxPHs= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659/go.mod h1:/jay1lr3w7NQd/VDBkEhkJmDmyPNsu4W+QV2obsUV40= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221114144617-d047289182a1 h1:SAB+pu0aXXxOsBxBNZG9F5c1YLCpSAW5HhBI5Id43d8= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221114144617-d047289182a1/go.mod h1:7bH8zabbewpXstaXKoV0Tk3lV7KFYadi5edLU5yDERY= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221115140820-b4b07a3c4e11 h1:dcofGaVR6najaIdh0JOXoxqV1MLJWnJ3pPMhD5gowV4= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221115140820-b4b07a3c4e11/go.mod h1:7bH8zabbewpXstaXKoV0Tk3lV7KFYadi5edLU5yDERY= github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE= github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=