Increase software installer upload timeout (#20479)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
* Increased the timeout of the upload software installer endpoint to 4 minutes.
|
||||
+9
-6
@@ -75,7 +75,7 @@ import (
|
||||
|
||||
var allowedURLPrefixRegexp = regexp.MustCompile("^(?:/[a-zA-Z0-9_.~-]+)+$")
|
||||
|
||||
const softwareInstallerUploadTimeout = 2 * time.Minute
|
||||
const softwareInstallerUploadTimeout = 4 * time.Minute
|
||||
|
||||
type initializer interface {
|
||||
// Initialize is used to populate a datastore with
|
||||
@@ -1073,16 +1073,19 @@ the way that the Fleet server works.
|
||||
// when uploading a software installer, the file might be large so
|
||||
// the read timeout (to read the full request body) must be extended.
|
||||
rc := http.NewResponseController(rw)
|
||||
// the frontend times out waiting for the upload after 2 minutes, so
|
||||
// the frontend times out waiting for the upload after 4 minutes,
|
||||
// use that same timeout:
|
||||
// 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
|
||||
if err := rc.SetReadDeadline(time.Now().Add(softwareInstallerUploadTimeout)); err != nil {
|
||||
level.Error(logger).Log("msg", "http middleware failed to override endpoint read timeout", "err", err)
|
||||
}
|
||||
// the write timeout should be extended as well to give the server time to
|
||||
// write a response body with the right error, otherwise the connection is
|
||||
// terminated abruptly.
|
||||
if err := rc.SetWriteDeadline(time.Now().Add(softwareInstallerUploadTimeout + 30*time.Second)); err != nil {
|
||||
// the write timeout should be extended to give the server time to
|
||||
// store the installer to S3 (or the configured storage location) and
|
||||
// write a response body, otherwise the connection is terminated
|
||||
// abruptly. Give it twice the read timeout, so that if it takes
|
||||
// 3m59s to upload an installer, we don't fail because of a lack of
|
||||
// time to store to S3.
|
||||
if err := rc.SetWriteDeadline(time.Now().Add(2 * softwareInstallerUploadTimeout)); err != nil {
|
||||
level.Error(logger).Log("msg", "http middleware failed to override endpoint write timeout", "err", err)
|
||||
}
|
||||
req.Body = http.MaxBytesReader(rw, req.Body, service.MaxSoftwareInstallerSize)
|
||||
|
||||
@@ -16,8 +16,8 @@ import AddSoftwareForm from "../AddSoftwareForm";
|
||||
import { IAddSoftwareFormData } from "../AddSoftwareForm/AddSoftwareForm";
|
||||
import { getErrorMessage } from "./helpers";
|
||||
|
||||
// 2 minutes + 15 seconds to account for extra roundtrip time.
|
||||
const UPLOAD_TIMEOUT = (2 * 60 + 15) * 1000;
|
||||
// 8 minutes + 15 seconds to account for extra roundtrip time.
|
||||
const UPLOAD_TIMEOUT = (8 * 60 + 15) * 1000;
|
||||
const MAX_FILE_SIZE_MB = 500;
|
||||
const MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user