@@ -75,7 +75,7 @@ import (
75
75
76
76
var allowedURLPrefixRegexp = regexp .MustCompile ("^(?:/[a-zA-Z0-9_.~-]+)+$" )
77
77
78
- const softwareInstallerUploadTimeout = 2 * time .Minute
78
+ const softwareInstallerUploadTimeout = 4 * time .Minute
79
79
80
80
type initializer interface {
81
81
// Initialize is used to populate a datastore with
@@ -1073,16 +1073,19 @@ the way that the Fleet server works.
1073
1073
// when uploading a software installer, the file might be large so
1074
1074
// the read timeout (to read the full request body) must be extended.
1075
1075
rc := http .NewResponseController (rw )
1076
- // the frontend times out waiting for the upload after 2 minutes, so
1076
+ // the frontend times out waiting for the upload after 4 minutes,
1077
1077
// use that same timeout:
1078
1078
// https://www.figma.com/design/oQl2oQUG0iRkUy0YOxc307/%2314921-Deploy-security-agents-to-macOS%2C-Windows%2C-and-Linux-hosts?node-id=773-18032&t=QjEU6tc73tddNSqn-0
1079
1079
if err := rc .SetReadDeadline (time .Now ().Add (softwareInstallerUploadTimeout )); err != nil {
1080
1080
level .Error (logger ).Log ("msg" , "http middleware failed to override endpoint read timeout" , "err" , err )
1081
1081
}
1082
- // the write timeout should be extended as well to give the server time to
1083
- // write a response body with the right error, otherwise the connection is
1084
- // terminated abruptly.
1085
- if err := rc .SetWriteDeadline (time .Now ().Add (softwareInstallerUploadTimeout + 30 * time .Second )); err != nil {
1082
+ // the write timeout should be extended to give the server time to
1083
+ // store the installer to S3 (or the configured storage location) and
1084
+ // write a response body, otherwise the connection is terminated
1085
+ // abruptly. Give it twice the read timeout, so that if it takes
1086
+ // 3m59s to upload an installer, we don't fail because of a lack of
1087
+ // time to store to S3.
1088
+ if err := rc .SetWriteDeadline (time .Now ().Add (2 * softwareInstallerUploadTimeout )); err != nil {
1086
1089
level .Error (logger ).Log ("msg" , "http middleware failed to override endpoint write timeout" , "err" , err )
1087
1090
}
1088
1091
req .Body = http .MaxBytesReader (rw , req .Body , service .MaxSoftwareInstallerSize )
0 commit comments