Worker: log which config paths are used at startup
To aid in debugging configuration loading issues, log the paths to config files at startup.
This commit is contained in:
parent
b84523c0ae
commit
ed014ccc2a
@ -19,6 +19,7 @@ bugs in actually-released versions.
|
|||||||
- [GO-2024-3106: Stack exhaustion in Decoder.Decode in encoding/gob](https://pkg.go.dev/vuln/GO-2024-3106)
|
- [GO-2024-3106: Stack exhaustion in Decoder.Decode in encoding/gob](https://pkg.go.dev/vuln/GO-2024-3106)
|
||||||
- Fix bug where database foreign key constraints could be deactivated ([#104305](https://projects.blender.org/studio/flamenco/issues/104305)).
|
- Fix bug where database foreign key constraints could be deactivated ([#104305](https://projects.blender.org/studio/flamenco/issues/104305)).
|
||||||
- Fix bug when submitting a file with a non-ASCII name via Shaman ([#104338](https://projects.blender.org/studio/flamenco/issues/104338)).
|
- Fix bug when submitting a file with a non-ASCII name via Shaman ([#104338](https://projects.blender.org/studio/flamenco/issues/104338)).
|
||||||
|
- Worker: log the configuration file locations at startup.
|
||||||
|
|
||||||
## 3.5 - released 2024-04-16
|
## 3.5 - released 2024-04-16
|
||||||
|
|
||||||
|
@ -95,6 +95,11 @@ func main() {
|
|||||||
|
|
||||||
// Load configuration, and override things from the CLI arguments if necessary.
|
// Load configuration, and override things from the CLI arguments if necessary.
|
||||||
configWrangler := worker.NewConfigWrangler()
|
configWrangler := worker.NewConfigWrangler()
|
||||||
|
configPaths := configWrangler.ConfigPaths()
|
||||||
|
log.Info().
|
||||||
|
Str("main", configPaths.Main).
|
||||||
|
Str("credentials", configPaths.Credentials).
|
||||||
|
Msg("will load configuration from these paths")
|
||||||
|
|
||||||
// Before the config can be overridden, it has to be loaded.
|
// Before the config can be overridden, it has to be loaded.
|
||||||
if _, err := configWrangler.WorkerConfig(); err != nil {
|
if _, err := configWrangler.WorkerConfig(); err != nil {
|
||||||
|
@ -89,6 +89,41 @@ func NewConfigWrangler() FileConfigWrangler {
|
|||||||
return FileConfigWrangler{}
|
return FileConfigWrangler{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WorkerConfigPaths struct {
|
||||||
|
Main string
|
||||||
|
Credentials string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigPaths returns the absolute file paths Flamenco Worker will use to load
|
||||||
|
// its configuration. If the path cannot be made absolute, an error will be
|
||||||
|
// logged and a relative path will be returned instead.
|
||||||
|
func (fcw *FileConfigWrangler) ConfigPaths() WorkerConfigPaths {
|
||||||
|
var err error
|
||||||
|
paths := WorkerConfigPaths{}
|
||||||
|
|
||||||
|
// configFilename is used as-is.
|
||||||
|
paths.Main, err = filepath.Abs(configFilename)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().
|
||||||
|
AnErr("cause", err).
|
||||||
|
Str("filepath", configFilename).
|
||||||
|
Msg("could not make the main configuration file path an absolute path")
|
||||||
|
paths.Main = configFilename
|
||||||
|
}
|
||||||
|
|
||||||
|
// credentialsFilename is always looked up somewhere in the user's home dir.
|
||||||
|
paths.Credentials, err = fcw.credentialsAbsPath()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().
|
||||||
|
AnErr("cause", err).
|
||||||
|
Str("filepath", credentialsFilename).
|
||||||
|
Msg("could not make the credentials configuration file path an absolute path")
|
||||||
|
paths.Credentials = credentialsFilename
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths
|
||||||
|
}
|
||||||
|
|
||||||
// WorkerConfig returns the worker configuration, or the default config if
|
// WorkerConfig returns the worker configuration, or the default config if
|
||||||
// there is no config file. Configuration is only loaded from disk once;
|
// there is no config file. Configuration is only loaded from disk once;
|
||||||
// subsequent calls return the same config.
|
// subsequent calls return the same config.
|
||||||
@ -150,7 +185,7 @@ func (fcw *FileConfigWrangler) WorkerCredentials() (WorkerCredentials, error) {
|
|||||||
func (fcw *FileConfigWrangler) SaveCredentials(creds WorkerCredentials) error {
|
func (fcw *FileConfigWrangler) SaveCredentials(creds WorkerCredentials) error {
|
||||||
fcw.creds = &creds
|
fcw.creds = &creds
|
||||||
|
|
||||||
filepath, err := appinfo.InFlamencoHome(credentialsFilename)
|
filepath, err := fcw.credentialsAbsPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -162,6 +197,11 @@ func (fcw *FileConfigWrangler) SaveCredentials(creds WorkerCredentials) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fcw *FileConfigWrangler) credentialsAbsPath() (string, error) {
|
||||||
|
filepath, err := appinfo.InFlamencoHome(credentialsFilename)
|
||||||
|
return filepath, err
|
||||||
|
}
|
||||||
|
|
||||||
// SetManagerURL overwrites the Manager URL in the cached configuration.
|
// SetManagerURL overwrites the Manager URL in the cached configuration.
|
||||||
// This is an in-memory change only, and will not be written to the config file.
|
// This is an in-memory change only, and will not be written to the config file.
|
||||||
func (fcw *FileConfigWrangler) SetManagerURL(managerURL string) {
|
func (fcw *FileConfigWrangler) SetManagerURL(managerURL string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user