Extend script execution timeout (#15779)
#15196 This is the work of @ghernandez345 except for adding the `ResponseController` thing in Go to override the server timeout for that specific sync endpoint so that the calls don't timeout waiting for a script response (the default HTTP server timeout was 90s for our server). # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [x] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated tests - [x] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [x] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [x] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)). --------- Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com> Co-authored-by: Roberto Dip <me@roperzh.com> Co-authored-by: Roberto Dip <dip.jesusr@gmail.com>
This commit is contained in:
co-authored by
Gabriel Hernandez
Roberto Dip
Roberto Dip
parent
a8a8080b3b
commit
d943fbbf8e
@@ -541,7 +541,8 @@ const (
|
||||
RunScriptHostNotFoundErrMsg = "Host doesn’t exist. Make sure you provide a valid hostname, UUID, osquery host ID, or node key."
|
||||
RunScriptForbiddenErrMsg = "You don’t have the right permissions in Fleet to run the script."
|
||||
RunScriptAlreadyRunningErrMsg = "A script is already running on this host. Please wait about 1 minute to let it finish."
|
||||
RunScriptHostTimeoutErrMsg = "Fleet hasn’t heard from the host in over 1 minute. Fleet doesn’t know if the script ran because the host went offline."
|
||||
RunScriptHostTimeoutErrMsg = "Fleet hasn’t heard from the host in over 5 minutes. Fleet doesn’t know if the script ran because the host went offline."
|
||||
RunScriptScriptTimeoutErrMsg = "Timeout. Fleet stopped the script after 5 minutes to protect host performance."
|
||||
)
|
||||
|
||||
// ConflictError is used to indicate a conflict, such as a UUID conflict in the DB.
|
||||
|
||||
@@ -203,7 +203,7 @@ func (hsr HostScriptResult) UserMessage(hostTimeout bool) string {
|
||||
}
|
||||
|
||||
if hsr.ExitCode == nil {
|
||||
if hsr.HostTimeout(1 * time.Minute) {
|
||||
if hsr.HostTimeout(5 * time.Minute) {
|
||||
return RunScriptHostTimeoutErrMsg
|
||||
}
|
||||
return RunScriptAlreadyRunningErrMsg
|
||||
@@ -211,7 +211,7 @@ func (hsr HostScriptResult) UserMessage(hostTimeout bool) string {
|
||||
|
||||
switch *hsr.ExitCode {
|
||||
case -1:
|
||||
return "Timeout. Fleet stopped the script after 30 seconds to protect host performance."
|
||||
return RunScriptScriptTimeoutErrMsg
|
||||
case -2:
|
||||
return "Scripts are disabled for this host. To run scripts, deploy a Fleet installer with scripts enabled."
|
||||
default:
|
||||
|
||||
@@ -594,6 +594,7 @@ func (e *authEndpointer) makeEndpoint(f handlerFunc, v interface{}) http.Handler
|
||||
mw := e.customMiddleware[i]
|
||||
endp = mw(endp)
|
||||
}
|
||||
|
||||
return newServer(endp, makeDecoder(v), e.opts)
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,9 @@ func (r runScriptSyncResponse) Status() int {
|
||||
var testRunScriptWaitForResult time.Duration
|
||||
|
||||
// waitForResultTime is the default timeout for the synchronous script execution.
|
||||
const waitForResultTime = time.Minute
|
||||
// The extra seconds is to give a little extra time on top of the script
|
||||
// execution time.
|
||||
const waitForResultTime = (5 * time.Minute) + (30 * time.Second)
|
||||
|
||||
func runScriptSyncEndpoint(ctx context.Context, request interface{}, svc fleet.Service) (errorer, error) {
|
||||
waitForResult := waitForResultTime
|
||||
|
||||
Reference in New Issue
Block a user