From 7d94c060844c348cbb9fa1ab7ad21ce640f1371e Mon Sep 17 00:00:00 2001 From: Thomas Poignant Date: Tue, 24 Dec 2024 18:47:19 +0100 Subject: [PATCH] fix(relayproxy): Remove Timeout middleware (#2864) * fix(relayproxy): Remove Timeout middleware Signed-off-by: Thomas Poignant * fix linter Signed-off-by: Thomas Poignant --------- Signed-off-by: Thomas Poignant --- cmd/relayproxy/api/server.go | 16 ---------------- cmd/relayproxy/config/config.go | 4 ---- cmd/relayproxy/config/config_test.go | 13 ------------- .../docs/relay_proxy/configure_relay_proxy.md | 1 - 4 files changed, 34 deletions(-) diff --git a/cmd/relayproxy/api/server.go b/cmd/relayproxy/api/server.go index 485424d61cb..42d6aeb076e 100644 --- a/cmd/relayproxy/api/server.go +++ b/cmd/relayproxy/api/server.go @@ -6,7 +6,6 @@ import ( "fmt" "net/http" "strings" - "time" "github.com/aws/aws-lambda-go/lambda" "github.com/labstack/echo-contrib/echoprometheus" @@ -55,21 +54,6 @@ func (s *Server) initRoutes() { s.apiEcho.HidePort = true s.apiEcho.Debug = s.config.IsDebugEnabled() s.apiEcho.Use(otelecho.Middleware("go-feature-flag")) - // Timeout middleware has to be the first middleware in the list - // (see: https://github.com/labstack/echo/blob/3b017855b4d331002e2b8b28e903679b875ae3e9/middleware/timeout.go#L17) - s.apiEcho.Use(middleware.TimeoutWithConfig( - middleware.TimeoutConfig{ - Skipper: func(c echo.Context) bool { - // ignore websocket in the timeout - return strings.HasPrefix(c.Request().URL.String(), "/ws") - }, - Timeout: time.Duration(s.config.RestAPITimeout) * time.Millisecond, - OnTimeoutRouteErrorHandler: func(err error, c echo.Context) { - s.zapLog.Error("Timeout on route", zap.String("route", c.Path()), zap.Error(err)) - }, - ErrorMessage: `Timeout on the server, please retry later`, - }), - ) s.apiEcho.Use(custommiddleware.ZapLogger(s.zapLog, s.config)) s.apiEcho.Use(middleware.BodyDumpWithConfig(middleware.BodyDumpConfig{ Skipper: func(c echo.Context) bool { diff --git a/cmd/relayproxy/config/config.go b/cmd/relayproxy/config/config.go index 604e30b63a3..73f7aa48245 100644 --- a/cmd/relayproxy/config/config.go +++ b/cmd/relayproxy/config/config.go @@ -66,7 +66,6 @@ func New(flagSet *pflag.FlagSet, log *zap.Logger, version string) (*Config, erro "listen": "1031", "host": "localhost", "fileFormat": "yaml", - "restApiTimeout": 5000, "pollingInterval": 60000, "logLevel": DefaultLogLevel, }, "."), nil) @@ -260,9 +259,6 @@ type Config struct { // Notifiers is the configuration on where to notify a flag change Notifiers []NotifierConf `mapstructure:"notifier" koanf:"notifier"` - // RestAPITimeout is the timeout on the API. - RestAPITimeout int `mapstructure:"restApiTimeout" koanf:"restapitimeout"` - // Version is the version of the relay-proxy Version string `mapstructure:"version" koanf:"version"` diff --git a/cmd/relayproxy/config/config_test.go b/cmd/relayproxy/config/config_test.go index 2a99f11c89d..d92d3f52b6f 100644 --- a/cmd/relayproxy/config/config_test.go +++ b/cmd/relayproxy/config/config_test.go @@ -37,7 +37,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) { Kind: "log", }, StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", EnableSwagger: true, AuthorizedKeys: config.APIKeys{ @@ -75,7 +74,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) { }, }, StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", EnableSwagger: true, AuthorizedKeys: config.APIKeys{ @@ -105,7 +103,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) { Kind: "log", }, StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", EnableSwagger: true, APIKeys: []string{ @@ -133,7 +130,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) { Kind: "log", }, StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", EnableSwagger: true, APIKeys: []string{ @@ -153,7 +149,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) { FileFormat: "yaml", Host: "localhost", StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", LogLevel: config.DefaultLogLevel, }, @@ -172,7 +167,6 @@ func TestParseConfig_fileFromPflag(t *testing.T) { PollingInterval: 60000, FileFormat: "yaml", Host: "localhost", - RestAPITimeout: 5000, LogLevel: config.DefaultLogLevel, Version: "1.X.X", Retrievers: &[]config.RetrieverConf{ @@ -238,7 +232,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) { Kind: "log", }, StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", EnableSwagger: true, AuthorizedKeys: config.APIKeys{ @@ -263,7 +256,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) { FileFormat: "yaml", Host: "localhost", StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", LogLevel: config.DefaultLogLevel, }, @@ -284,7 +276,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) { FileFormat: "yaml", Host: "localhost", StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", LogLevel: config.DefaultLogLevel, }, @@ -299,7 +290,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) { FileFormat: "yaml", Host: "localhost", StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", LogLevel: config.DefaultLogLevel, }, @@ -314,7 +304,6 @@ func TestParseConfig_fileFromFolder(t *testing.T) { FileFormat: "yaml", Host: "localhost", StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", LogLevel: config.DefaultLogLevel, }, @@ -837,7 +826,6 @@ func TestMergeConfig_FromOSEnv(t *testing.T) { Kind: "log", }, StartWithRetrieverError: false, - RestAPITimeout: 5000, Version: "1.X.X", EnableSwagger: true, AuthorizedKeys: config.APIKeys{ @@ -870,7 +858,6 @@ func TestMergeConfig_FromOSEnv(t *testing.T) { PollingInterval: 60000, FileFormat: "yaml", Host: "localhost", - RestAPITimeout: 5000, LogLevel: config.DefaultLogLevel, Version: "1.X.X", Retrievers: &[]config.RetrieverConf{ diff --git a/website/docs/relay_proxy/configure_relay_proxy.md b/website/docs/relay_proxy/configure_relay_proxy.md index 13960580a78..3709886e01f 100644 --- a/website/docs/relay_proxy/configure_relay_proxy.md +++ b/website/docs/relay_proxy/configure_relay_proxy.md @@ -42,7 +42,6 @@ ex: `AUTHORIZEDKEYS_EVALUATION=my-first-key,my-second-key`)_. | `hideBanner` | boolean | `false` | Should we display the beautiful **go-feature-flag** banner when starting the relay proxy | | `enableSwagger` | boolean | `false` | Enables Swagger for testing the APIs directly. If you are enabling Swagger you will have to provide the `host` configuration and the Swagger UI will be available at `http://:/swagger/`. | | `host` | string | `localhost` | This is the DNS you will use to access the relay proxy. This field is used by Swagger to query the API at the right place. | -| `restApiTimeout` | int | `5000` | Timeout in milliseconds for API calls. | | `logLevel` | string | `info` | The log level to use for the relay proxy.
Available values are `ERROR`, `WARN`, `INFO`, `DEBUG`. | | `logFormat` | string | `json` | The format to use for structured logs from the relay proxy.
Valid values are `json` and `logfmt`. | | `fileFormat` | string | `yaml` | This is the format of your `go-feature-flag` configuration file. Acceptable values are `yaml`, `json`, `toml`. |