Skip to content

Commit b4b4498

Browse files
authored
Increase software installer upload timeout (#20479)
1 parent ffad2e7 commit b4b4498

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Increased the timeout of the upload software installer endpoint to 4 minutes.

cmd/fleet/serve.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import (
7575

7676
var allowedURLPrefixRegexp = regexp.MustCompile("^(?:/[a-zA-Z0-9_.~-]+)+$")
7777

78-
const softwareInstallerUploadTimeout = 2 * time.Minute
78+
const softwareInstallerUploadTimeout = 4 * time.Minute
7979

8080
type initializer interface {
8181
// Initialize is used to populate a datastore with
@@ -1073,16 +1073,19 @@ the way that the Fleet server works.
10731073
// when uploading a software installer, the file might be large so
10741074
// the read timeout (to read the full request body) must be extended.
10751075
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,
10771077
// use that same timeout:
10781078
// 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
10791079
if err := rc.SetReadDeadline(time.Now().Add(softwareInstallerUploadTimeout)); err != nil {
10801080
level.Error(logger).Log("msg", "http middleware failed to override endpoint read timeout", "err", err)
10811081
}
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 {
10861089
level.Error(logger).Log("msg", "http middleware failed to override endpoint write timeout", "err", err)
10871090
}
10881091
req.Body = http.MaxBytesReader(rw, req.Body, service.MaxSoftwareInstallerSize)

frontend/pages/SoftwarePage/components/AddSoftwareModal/AddSoftwareModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import AddSoftwareForm from "../AddSoftwareForm";
1616
import { IAddSoftwareFormData } from "../AddSoftwareForm/AddSoftwareForm";
1717
import { getErrorMessage } from "./helpers";
1818

19-
// 2 minutes + 15 seconds to account for extra roundtrip time.
20-
const UPLOAD_TIMEOUT = (2 * 60 + 15) * 1000;
19+
// 8 minutes + 15 seconds to account for extra roundtrip time.
20+
const UPLOAD_TIMEOUT = (8 * 60 + 15) * 1000;
2121
const MAX_FILE_SIZE_MB = 500;
2222
const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024;
2323

0 commit comments

Comments
 (0)