Make worker name configurable

Worker name can be set via the flamenco-worker.yaml file now.
This commit is contained in:
Sybren A. Stüvel 2023-10-27 13:11:39 +02:00
parent 7428a2a0f3
commit eb269d63fb
3 changed files with 13 additions and 3 deletions

@ -13,6 +13,7 @@ bugs in actually-released versions.
- Job settings: add a description for the `eval` field. This is shown in the tooltip of the 'set to automatic value' button, to make it clear what that button will do.
- Database integrity tests. These are always run at startup of Flamenco Manager, and by default run periodically every hour. This can be configured by adding/changing the `database_check_period: 1h` setting in `flamenco-manager.yaml`. Setting it to `0` will disable the periodic check. When a database consistency error is found, Flamenco Manager will immediately shut down.
- Workers can be marked as 'restartable' by using the `-restart-exit-code N` commandline option. More info in the [Worker Actions documentation](https://flamenco.blender.org/usage/worker-actions/).
- Worker name can be configured via `flamenco_worker.yaml` via `worker_name = "somename"`.
- Upgrade bundled FFmpeg from 5.0 to 5.1.
- Rename the add-on download to `flamenco-addon.zip` (it used to be `flamenco3-addon.zip`). It still contains the same files as before, and in Blender the name of the add-on has not changed.
- Improve speed of queueing up >100 simultaneous job deletions.

@ -39,6 +39,8 @@ var defaultConfig = WorkerConfig{
// WorkerConfig represents the configuration of a single worker.
// It does not include authentication credentials.
type WorkerConfig struct {
WorkerName string `yaml:"worker_name"`
// ConfiguredManager is the Manager URL that's in the configuration file.
ConfiguredManager string `yaml:"manager_url"`

@ -92,7 +92,7 @@ func register(ctx context.Context, cfg WorkerConfig, client FlamencoClient) Work
secretKey := hex.EncodeToString(secret)
req := api.RegisterWorkerJSONRequestBody{
Name: workerName(),
Name: workerName(cfg),
Platform: runtime.GOOS,
Secret: secretKey,
SupportedTaskTypes: cfg.TaskTypes,
@ -152,7 +152,7 @@ func signOn(ctx context.Context, cfg WorkerConfig, client FlamencoClient) (api.W
canRestart := cfg.RestartExitCode != 0
req := api.SignOnJSONRequestBody{
Name: workerName(),
Name: workerName(cfg),
SupportedTaskTypes: cfg.TaskTypes,
SoftwareVersion: appinfo.ExtendedVersion(),
CanRestart: &canRestart,
@ -189,7 +189,14 @@ func signOn(ctx context.Context, cfg WorkerConfig, client FlamencoClient) (api.W
}
// workerName returns a suitable name for the worker. Errors are fatal.
func workerName() string {
func workerName(cfg WorkerConfig) string {
name := strings.TrimSpace(cfg.WorkerName)
if name != "" {
log.Info().
Str("name", name).
Msg("worker name obtained from worker configuration instead of using the hostname")
return name
}
name, ok := os.LookupEnv(workerNameEnvVariable)
if ok && name != "" {
name = strings.TrimSpace(name)