-
Notifications
You must be signed in to change notification settings - Fork 124
Feat/configurable server timeouts #1310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/configurable server timeouts #1310
Conversation
This change introduces configurable server-side timeouts for the HTTP interceptor proxy. The following timeouts can now be set via environment variables: - KEDA_HTTP_SERVER_READ_TIMEOUT: Sets the ReadTimeout for the proxy server. - KEDA_HTTP_SERVER_WRITE_TIMEOUT: Sets the WriteTimeout for the proxy server. - KEDA_HTTP_SERVER_IDLE_TIMEOUT: Sets the IdleTimeout for the proxy server. These timeouts provide more granular control over the connection behavior between clients and the interceptor, allowing for longer timeout capabilities as you requested. The default for these timeouts is "0s", which means: - For ReadTimeout: No timeout. - For WriteTimeout: No timeout. - For IdleTimeout: Go's default http.Server behavior (uses TCP keep-alives). Validation has been added to ensure these timeout values cannot be negative.
Signed-off-by: bazooka720 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work, thank you!
Happy to aprove but would prefer if the defaults remained as they were unless there is a good justification for changing them too
ServerReadTimeout time.Duration `envconfig:"KEDA_HTTP_SERVER_READ_TIMEOUT" default:"120s"` | ||
// ServerWriteTimeout is the maximum duration before timing out writes of the response. | ||
ServerWriteTimeout time.Duration `envconfig:"KEDA_HTTP_SERVER_WRITE_TIMEOUT" default:"120s"` | ||
// ServerIdleTimeout is the maximum amount of time to wait for the next request when keep-alives are enabled. | ||
ServerIdleTimeout time.Duration `envconfig:"KEDA_HTTP_SERVER_IDLE_TIMEOUT" default:"120s"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the defaults be 0? That way, the default behaviour remains the same and it won't be a potentially breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, looks like this actually doesn't compile, there are some function calls affected by this change
interceptor/forward_wait_func.go:1: : # github.com/kedacore/http-add-on/interceptor [github.com/kedacore/http-add-on/interceptor.test]
Error: interceptor/main.go:256:55: not enough arguments in call to kedahttp.ServeContext
have (context.Context, string, *"net/http".ServeMux, nil)
want (context.Context, string, "net/http".Handler, *tls.Config, *"github.com/kedacore/http-add-on/interceptor/config".Timeouts)
Error: interceptor/main.go:266:62: not enough arguments in call to kedahttp.ServeContext
have (context.Context, string, "net/http".Handler, nil)
want (context.Context, string, "net/http".Handler, *tls.Config, *"github.com/kedacore/http-add-on/interceptor/config".Timeouts) (typecheck)
package main
pkg/http/server.go:1: : # github.com/kedacore/http-add-on/pkg/http [github.com/kedacore/http-add-on/pkg/http.test]
Error: pkg/http/server_test.go:33:38: not enough arguments in call to ServeContext
have (context.Context, string, "net/http".HandlerFunc, nil)
want (context.Context, string, "net/http".Handler, *tls.Config, *config.Timeouts)
Error: pkg/http/server_test.go:67:38: not enough arguments in call to ServeContext
have (context.Context, string, "net/http".HandlerFunc, *tls.Config)
want (context.Context, string, "net/http".Handler, *tls.Config, *config.Timeouts) (typecheck)
Provide a description of what has been changed
Checklist
README.md
docs/
directoryFixes #