Skip to content
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

Remove default WriteTimeout on server #22146

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/22069-remove-write-timeout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Remove 100s write timeout on the server (to allow for long running `POST /api/latest/fleet/software/batch` requests).
21 changes: 0 additions & 21 deletions cmd/fleet/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -1208,32 +1208,11 @@ the way that the Fleet server works.
rootMux = prefixMux
}

liveQueryRestPeriod := 90 * time.Second // default (see #1798)
if v := os.Getenv("FLEET_LIVE_QUERY_REST_PERIOD"); v != "" {
duration, err := time.ParseDuration(v)
if err != nil {
level.Error(logger).Log("live_query_rest_period_err", err)
} else {
liveQueryRestPeriod = duration
}
}

// The "GET /api/latest/fleet/queries/run" API requires
// WriteTimeout to be higher than the live query rest period
// (otherwise the response is not sent back to the client).
//
// We add 10s to the live query rest period to allow the writing
// of the response.
liveQueryRestPeriod += 10 * time.Second

// Create the handler based on whether tracing should be there
var handler http.Handler
handler = launcher.Handler(rootMux)

srv := config.Server.DefaultHTTPServer(ctx, handler)
if liveQueryRestPeriod > srv.WriteTimeout {
srv.WriteTimeout = liveQueryRestPeriod
}
srv.SetKeepAlivesEnabled(config.Server.Keepalive)
errs := make(chan error, 2)
go func() {
Expand Down
1 change: 0 additions & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func (s *ServerConfig) DefaultHTTPServer(ctx context.Context, handler http.Handl
Addr: s.Address,
Handler: handler,
ReadTimeout: 25 * time.Second,
WriteTimeout: 40 * time.Second,
ReadHeaderTimeout: 5 * time.Second,
IdleTimeout: 5 * time.Minute,
MaxHeaderBytes: 1 << 18, // 0.25 MB (262144 bytes)
Expand Down
Loading