add better messaging for 504 responses in fleetctl when running a script synchronously (#19680)

relates to #19378

This adds better error messaging in fleetctl for a 504 response (Gateway
timeout) when we run a script synchronously.


- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
- [ ] Added/updated tests
- [x] Manual QA for all new/changed functionality
This commit is contained in:
Gabriel Hernandez 2024-06-14 17:07:08 +01:00 committed by GitHub
parent 5d93f27f20
commit a453d4ad36
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View file

@ -538,11 +538,11 @@ func (e OrbitError) Error() string {
const (
// Scripts
RunScriptInvalidTypeErrMsg = "File type not supported. Only .sh (Bash) and .ps1 (PowerShell) file types are allowed."
RunScriptHostOfflineErrMsg = "Script cant run on offline host."
RunScriptHostNotFoundErrMsg = "Host doesnt exist. Make sure you provide a valid hostname, UUID, osquery host ID, or node key."
RunScriptForbiddenErrMsg = "You dont have the right permissions in Fleet to run the script."
RunScriptHostOfflineErrMsg = "Script can't run on offline host."
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 5 minutes to let it finish."
RunScriptHostTimeoutErrMsg = "Fleet didnt hear back from the host in under 5 minutes (timeout for live scripts). Fleet doesnt know if the script ran because it didnt receive the result. Please try again."
RunScriptHostTimeoutErrMsg = "Fleet didn't hear back from the host in under 5 minutes (timeout for live scripts). Fleet doesn't know if the script ran because it didn't receive the result. Please try again."
RunScriptScriptsDisabledGloballyErrMsg = "Running scripts is disabled in organization settings."
RunScriptDisabledErrMsg = "Scripts are disabled for this host. To run scripts, deploy the fleetd agent with scripts enabled."
RunScriptsOrbitDisabledErrMsg = "Couldn't run script. To run a script, deploy the fleetd agent with --enable-scripts."
@ -550,6 +550,7 @@ const (
RunScriptAsyncScriptEnqueuedErrMsg = "Script is running or will run when the host comes online."
RunScripSavedMaxLenErrMsg = "Script is too large. It's limited to 500,000 characters (approximately 10,000 lines)."
RunScripUnsavedMaxLenErrMsg = "Script is too large. It's limited to 10,000 characters (approximately 125 lines)."
RunScriptGatewayTimeoutErrMsg = "Gateway timeout. Fleet didn't hear back from the host and doesn't know if the script ran. Please make sure your load balancer timeout isn't shorter than the Fleet server timeout."
// End user authentication
EndUserAuthDEPWebURLConfiguredErrMsg = `End user authentication can't be configured when the configured automatic enrollment (DEP) profile specifies a configuration_web_url.` // #nosec G101

View file

@ -57,6 +57,11 @@ func (c *Client) runHostScript(verb, path string, hostID uint, scriptContents []
return nil, errors.New(fleet.RunScriptScriptsDisabledGloballyErrMsg)
}
return nil, errors.New(fleet.RunScriptForbiddenErrMsg)
// It's possible we get a GatewayTimeout error message from nginx or another
// proxy server, so we want to return a more helpful error message in that
// case.
case http.StatusGatewayTimeout:
return nil, errors.New(fleet.RunScriptGatewayTimeoutErrMsg)
case http.StatusPaymentRequired:
if teamID > 0 {
return nil, errors.New("Team id parameter requires Fleet Premium license.")