Manager: allow setup to finish without Blender #104306
@ -182,12 +182,11 @@ func (f *Flamenco) FindBlenderExePath(e echo.Context) error {
|
||||
logger.Warn().AnErr("cause", err).Msg("there was an issue finding Blender")
|
||||
return sendAPIError(e, http.StatusInternalServerError, "there was an issue finding Blender: %v", err)
|
||||
default:
|
||||
isUsable := true
|
||||
response = append(response, api.BlenderPathCheckResult{
|
||||
IsUsable: &isUsable,
|
||||
Input: &result.Input,
|
||||
Path: &result.FoundLocation,
|
||||
Cause: &result.BlenderVersion,
|
||||
IsUsable: true,
|
||||
Input: result.Input,
|
||||
Path: result.FoundLocation,
|
||||
Cause: result.BlenderVersion,
|
||||
Source: result.Source,
|
||||
})
|
||||
}
|
||||
@ -201,12 +200,11 @@ func (f *Flamenco) FindBlenderExePath(e echo.Context) error {
|
||||
case err != nil:
|
||||
logger.Info().AnErr("cause", err).Msg("there was an issue finding Blender as 'blender' on $PATH")
|
||||
default:
|
||||
isUsable := true
|
||||
response = append(response, api.BlenderPathCheckResult{
|
||||
IsUsable: &isUsable,
|
||||
Input: &result.Input,
|
||||
Path: &result.FoundLocation,
|
||||
Cause: &result.BlenderVersion,
|
||||
IsUsable: true,
|
||||
Input: result.Input,
|
||||
Path: result.FoundLocation,
|
||||
Cause: result.BlenderVersion,
|
||||
Source: result.Source,
|
||||
})
|
||||
}
|
||||
@ -225,39 +223,32 @@ func (f *Flamenco) CheckBlenderExePath(e echo.Context) error {
|
||||
}
|
||||
|
||||
command := toCheck.Path
|
||||
var cause string
|
||||
var isUsable bool
|
||||
var path string
|
||||
|
||||
logger = logger.With().Str("command", command).Logger()
|
||||
logger.Info().Msg("checking whether this command leads to Blender")
|
||||
|
||||
ctx := e.Request().Context()
|
||||
checkResult, err := find_blender.CheckBlender(ctx, command)
|
||||
response := api.BlenderPathCheckResult{
|
||||
Input: &command,
|
||||
Source: checkResult.Source,
|
||||
Path: &path,
|
||||
IsUsable: &isUsable,
|
||||
Cause: &cause,
|
||||
Input: command,
|
||||
Source: checkResult.Source,
|
||||
}
|
||||
|
||||
switch {
|
||||
case errors.Is(err, exec.ErrNotFound):
|
||||
*response.Cause = "Blender could not be found"
|
||||
response.Cause = "Blender could not be found"
|
||||
case err != nil:
|
||||
*response.Cause = fmt.Sprintf("There was an error running the command: %v", err)
|
||||
response.Cause = fmt.Sprintf("There was an error running the command: %v", err)
|
||||
default:
|
||||
*response.IsUsable = true
|
||||
*response.Path = checkResult.FoundLocation
|
||||
*response.Cause = fmt.Sprintf("Found %v", checkResult.BlenderVersion)
|
||||
response.IsUsable = true
|
||||
response.Path = checkResult.FoundLocation
|
||||
response.Cause = fmt.Sprintf("Found %v", checkResult.BlenderVersion)
|
||||
}
|
||||
|
||||
logger.Info().
|
||||
Str("input", *response.Input).
|
||||
Str("foundLocation", *response.Path).
|
||||
Str("result", *response.Cause).
|
||||
Bool("isUsable", *response.IsUsable).
|
||||
Str("input", response.Input).
|
||||
Str("foundLocation", response.Path).
|
||||
Str("result", response.Cause).
|
||||
Bool("isUsable", response.IsUsable).
|
||||
Msg("result of command check")
|
||||
|
||||
return e.JSON(http.StatusOK, response)
|
||||
@ -274,15 +265,13 @@ func (f *Flamenco) SaveSetupAssistantConfig(e echo.Context) error {
|
||||
|
||||
logger = logger.With().Interface("config", setupAssistantCfg).Logger()
|
||||
|
||||
isConfigInvalid := setupAssistantCfg.StorageLocation == "" ||
|
||||
setupAssistantCfg.BlenderExecutable.IsUsable == nil
|
||||
isConfigIncomplete := setupAssistantCfg.StorageLocation == "" ||
|
||||
!setupAssistantCfg.BlenderExecutable.IsUsable ||
|
||||
abelli marked this conversation as resolved
Outdated
|
||||
setupAssistantCfg.BlenderExecutable.Path == ""
|
||||
abelli marked this conversation as resolved
Outdated
Sybren A. Stüvel
commented
It's fine to include the actual error message in the response as well, so that the caller knows what's wrong without checking the Manager log. It's fine to include the actual error message in the response as well, so that the caller knows what's wrong without checking the Manager log.
|
||||
|
||||
isConfigIncomplete := setupAssistantCfg.BlenderExecutable.Path == nil ||
|
||||
setupAssistantCfg.BlenderExecutable.Input == nil
|
||||
|
||||
if isConfigInvalid || setupAssistantCfg.BlenderExecutable.Source != "default" && isConfigIncomplete {
|
||||
logger.Warn().Msg("setup assistant: configuration is invalid or incomplete, unable to accept")
|
||||
return sendAPIError(e, http.StatusBadRequest, "configuration is invalid or incomplete")
|
||||
if isConfigIncomplete && setupAssistantCfg.BlenderExecutable.Source != "default" {
|
||||
logger.Warn().Msg("setup assistant: configuration is incomplete, unable to accept")
|
||||
return sendAPIError(e, http.StatusBadRequest, "configuration is incomplete")
|
||||
}
|
||||
|
||||
conf := f.config.Get()
|
||||
@ -297,10 +286,10 @@ func (f *Flamenco) SaveSetupAssistantConfig(e echo.Context) error {
|
||||
case api.BlenderPathSourcePathEnvvar:
|
||||
// The input command can be found on $PATH, and thus we don't need to save
|
||||
// the absolute path to Blender here.
|
||||
executable = *setupAssistantCfg.BlenderExecutable.Input
|
||||
executable = setupAssistantCfg.BlenderExecutable.Input
|
||||
case api.BlenderPathSourceInputPath:
|
||||
// The path should be used as-is.
|
||||
executable = *setupAssistantCfg.BlenderExecutable.Path
|
||||
executable = setupAssistantCfg.BlenderExecutable.Path
|
||||
}
|
||||
if commandNeedsQuoting(executable) {
|
||||
executable = strconv.Quote(executable)
|
||||
|
Loading…
Reference in New Issue
Block a user
The work cannot be done, and so this should be logged as an error, not a warning.
I usually log errors as a 'cause' field:
Alternatively, if you want to keep the error message as part of the log message, you could use
.Msgf(...)
instead:%v
is Go's generic "put the thing's value here", and should result in the value oferr.Error()
.