703 Commits

Author SHA1 Message Date
Sybren A. Stüvel
e7c4285ac6 Manager: Adjust code for renaming SocketIO... types to Event...
No functional changes, just adjusting to the OpenAPI renames.
2024-02-05 09:25:43 +01:00
Sybren A. Stüvel
3326f683da Manager: consistent MQTT server/broker naming
Consistently log about the MQTT "broker", not the "server". The former
is common MQTT terminology.
2024-02-04 18:28:12 +01:00
Sybren A. Stüvel
91d15df765 Manager Cleanup: consistent variable name for MQTTClient receiver pointer
No functional changes.
2024-02-04 17:03:38 +01:00
Sybren A. Stüvel
44bfe58891 Manager: friendlier log message when MQTT server connection cannot be made 2024-02-04 16:32:36 +01:00
Sybren A. Stüvel
f0c7acd903 Manager: fix web interface not showing last-rendered images on job view
Fix SocketIO subscriptions so that the client also subscribes to
job-specific last-rendered images whenever subscribing to job-specific
events. These are sent to another event topic, and thus need some extra
care. Before the introduction of the generic event bus, both message types
were sent to the same topic, but that's not supported by MQTT, and so things
had to change.
2024-02-04 16:12:16 +01:00
Sybren A. Stüvel
4f804958e5 Manager: add unittest for eventbus topics
The code was doing its work just fine, but I wanted to be sure.
2024-02-04 16:12:16 +01:00
Sybren A. Stüvel
dd98c7471d Manager: don't log event payload in event logging
Don't log event payload in MQTT/SocketIO debug logs. It's getting too
noisy.
2024-02-04 16:11:58 +01:00
Sybren A. Stüvel
740ede80fa Manager: log eventbus events with 'eventbus' prefix instead of 'socketio'
These messages are now no longer SocketIO-specific, so should use the
'eventbus' prefix.
2024-02-04 16:08:45 +01:00
Sybren A. Stüvel
b375acb1a1 Cleanup: add SPDX license identifiers 2024-02-03 23:42:51 +01:00
Sybren A. Stüvel
4fe8605744 Manager: Add MQTT client for sending events
Add an MQTT client to send events from the event bus to an MQTT broker.
2024-02-03 23:20:15 +01:00
Sybren A. Stüvel
76a24243f0 Manager: Introduce event bus system
Introduce an "event bus"-like system. It's more like a fan-out
broadcaster for certain events. Instead of directly sending events to
SocketIO, they are now sent to the broker, which in turn sends it to any
registered "forwarder". Currently there is ony one forwarder, for
SocketIO.

This opens the door for a proper MQTT client that sends the same events
to an MQTT server.
2024-02-03 22:55:23 +01:00
Sybren A. Stüvel
f464aea137 Manager & website: provide more helpful info when Worker auth fails
Provide more useful info when a Worker tries to communicate but fails
the authentication check. The message about this is now more friendly
and links to a new FAQ entry at
https://flamenco.blender.org/faq/#what-does-unknown-worker-is-trying-to-communicate-mean
2024-01-25 14:19:24 +01:00
Sybren A. Stüvel
9afd79d8c0 Manager: prevent logging an error when fetching unknown worker
Prevent logging an error in the persistence layer when an unknown worker
is requested.

This reduces the noise & confusion when the web interface is showing the
details of a worker, but the worker gets removed by someone else. Or when
the Manager doesn't know about a Worker and it's trying to connect.

See #104282.
2024-01-25 12:38:13 +01:00
Sybren A. Stüvel
70faa4e225 Move URLs to the Flamenco website to constants in a dedicated package
Create a dedicated package `.../pkg/website` to contain constants for the
URLs of documentation, bug reporting, etc. That way it's easier to see
which parts of the website are being referred to from the Flamenco
binaries, and updates can happen in a central spot.

No functional changes.
2024-01-25 12:25:06 +01:00
Sybren A. Stüvel
b39f116b0e Manager: after deleting a job, perform a database consistency check
Deleting jobs from the database can still sometimes cause consistency
errors, as if foreign key constraints aren't enabled. This check is there
to try and get a grip on things.
2024-01-11 20:03:53 +01:00
Sybren A. Stüvel
aac2ec7bf6 Manager: when requesting job deletion, also log its low-level database ID
When an API request comes in to delete a job, not only log the job's UUID,
but also include its database ID. This can help in figuring out database
issues, as when the job is deleted, it's unknown what UUID it had. Database
relations use the ID, and not the UUID.
2024-01-11 17:17:56 +01:00
Sybren A. Stüvel
6777e89589 Manager: refuse to delete job when foreign keys are disabled
Just as a safety measure, before deleting a job, check that foreign key
constraints are enabled. These are optional in SQLite, and the deletion
function assumes that they are on.
2024-01-11 17:17:56 +01:00
Sybren A. Stüvel
3e46322d14 Manager: reduce log level when last-rendered image was accepted
Reduce the log level when a last-rendered image was accepted from a Worker.
2024-01-11 17:17:56 +01:00
Sybren A. Stüvel
17b664f152 Worker: log copy-pastable commandline invocation
Log any CLI command that's run in a way that can be easily copy-pasted
from the task log. This can help a lot in determining whether an issue
is caused by Flamenco or by the CLI program itself.
2023-12-25 15:07:18 +01:00
Sybren A. Stüvel
8ae0bc37dd Worker: reduce double logging
Remove double logging of 'command exited succesfully' message.
2023-12-25 14:55:35 +01:00
Sybren A. Stüvel
fe26a026e6 Refactor: rename command_exe.go to cmd_executor.go
Rename the file containing the command executor from `command_exe.go` to
`cmd_executor.go`), to distinguish it from the implementation of the
`exec` command (`command_exec.go`).

No functional changes.
2023-12-25 14:14:53 +01:00
Sybren A. Stüvel
246916475f Manager: Implement mass mark-for-deletion of jobs
Implement the API function to mass-mark jobs for deletion, based on
their 'updated_at' timestamp.

Note that the `last_updated_max` parameter is rounded up to entire
seconds. This may mark more jobs for deletion than you expect, if their
`updated_at` timestamps differ by less than a second.
2023-12-16 23:05:52 +01:00
Sybren A. Stüvel
b9e41065c1 OAPI: regenerate code 2023-12-16 23:03:53 +01:00
Sybren A. Stüvel
0ea3cf8c3f Worker: perform database migrations with Goose
Replace the GORM auto-migration with Goose. The latter uses hand-written
SQL files to migrate the database with understandable, explicit queries.
2023-12-14 10:13:42 +01:00
Sybren A. Stüvel
acc9499f2a Manager: drop the job_storage_infos database table
GORM Automigration created a separate `job_storage_infos` table (because
we used it wrong, to be fair), which is actually only used as an
embedded struct in the `jobs` table. This means this table itself can be
dropped.
2023-12-14 10:13:42 +01:00
Sybren A. Stüvel
a65f234bea Manager: replace GORM database migration with Goose
Replace GORM's auto-migration with Goose. The latter uses hand-written
SQL queries to apply database schema changes, which is safer and easier to
understand than what GORM is doing.
2023-12-14 10:13:40 +01:00
Sybren A. Stüvel
d260a308bd Worker: enable write-ahead logging on the database
Now the Worker and the Manager share the same database initialisation
code (enabling foreign key constraints + write-ahead logging).

The foreign key constraints were already enabled before, but now it's done
with (a copy of) the same code as the Manager.
2023-12-14 10:10:03 +01:00
Sybren A. Stüvel
70c88a95e3 Worker: fix timezone-dependent tests
The tests were already made timezone-independent, but in a way that assumed
the day would still be the same and only the time would be different.
Now that assumption is removed as well.
2023-11-27 12:01:44 +07:00
Sybren A. Stüvel
06f2a2bc29 Rename cli command to exec and document it
The `cli` word, to me, implies too much that it's run via a shell, which
it isn't. Renaming to `exec` resolves that.
2023-10-31 10:17:16 +01:00
Sybren A. Stüvel
5dd3939969 Add "cli" command
Add arbitrary command runner. This still needs some docs ;-)
2023-10-27 21:57:57 +02:00
Sybren A. Stüvel
eb269d63fb Make worker name configurable
Worker name can be set via the flamenco-worker.yaml file now.
2023-10-27 13:11:39 +02:00
Sybren A. Stüvel
60fb20c0ff Fix #104245: Incorrect frame range formatting when crafting blender's cmd
Fix a bug in the translation from 'human' frame ranges ('A-B,C-D') to
'Blender' frame ranges ('A..B,C..D'). It required calling
`string.replaceAll()` instead of `string.replace()` in the job compiler
script, which in turn required an upgrade of the JavaScript engine Goja.
2023-08-23 19:55:49 +02:00
Michael Cook
bc7b434121 Always use local time for job compiler timestamp variable
The 'Simple Blender Render' job compiler script uses a `{timestamp}`
variable to determine the render output path. This variable is now set
to the local time, rather than UTC.

This fixes #104219: Unit tests are timezone-dependent

The solution uses Go `time.Local` timezone to satisfy unit tests
assertions using a Mock clock. The timezone of the local workstation
running the tests.
2023-08-23 16:08:01 +02:00
Sybren A. Stüvel
eb9f46dc9b Manager: fix sleep scheduler time zone handling
The sleep scheduler now always works in the local time zone.

This fixes the sleep scheduler part of #104219.
2023-08-23 13:54:02 +00:00
Sybren A. Stüvel
ef726da17b SocketIO broadcasting for worker tags CUD operations
Broadcast create/update/delete operations on worker tags via SocketIO.

Ref: #104204
2023-08-23 13:54:02 +00:00
Sybren A. Stüvel
e231f6f221 Manager: better logging of tag create/update/delete
Emit an info-level log message when worker tags are created, updated, or
deleted.
2023-08-15 10:36:54 +02:00
Sybren A. Stüvel
c477992467 Manager: tag update without description now keeps the description
Updating a tag without `description` field in the request body will keep
the tag's description as-is. Previously this caused it to become empty,
which is now still possible by using an explicit `description: ""`.
2023-08-15 10:29:44 +02:00
Sybren A. Stüvel
3e72391cbf Restartable workers
When the worker is started with `-restart-exit-code 47` or has
`restart_exit_code=47` in `flamenco-worker.yaml`, it's marked as
'restartable'. This will enable two worker actions 'Restart
(immediately)' and 'Restart (after task is finished)' in the Manager web
interface. When a worker is asked to restart, it will exit with exit
code `47`. Of course any positive exit code can be used here.
2023-08-14 16:00:09 +02:00
Sybren A. Stüvel
02fac6a4df Change Go package name from git.blender.org to projects.blender.org
Change the package base name of the Go code, from
`git.blender.org/flamenco` to `projects.blender.org/studio/flamenco`.

The old location, `git.blender.org`, has no longer been use since the
[migration to Gitea][1]. The new package names now reflect the actual
location where Flamenco is hosted.

[1]: https://code.blender.org/2023/02/new-blender-development-infrastructure/
2023-08-01 12:42:31 +02:00
Sybren A. Stüvel
dae5b1a571 Fix #104237: fix issue with drive-only paths on Windows
Fix an issue where a shared storage path on Linux, that maps via two-way
variables to a drive root on Windows, caused problems with the path
translation system.

Windows paths that consist only of a drive letter (`F:`) cannot just be
concatenated to a relative path, as that will result in `F:path\to\file`,
which is still a relative path of sorts. This is now handled correctly,
and should result in `F:\path\to\file`.

This fixes #104237.
2023-07-31 15:28:07 +02:00
Sybren A. Stüvel
7dc3def1d5 Manager: simplify variable expansion
Simplify the variable expansion code. Instead of using a separate goroutine
and two channels, use a struct + a simple function call.

No functional changes.
2023-07-31 15:15:20 +02:00
Sybren A. Stüvel
7d1ce8131a Manager: simplify value-to-variable replacement
Simplify the code for the two-way variables' value-to-variable replacement.

Instead of using a goroutine and two channels, use a separate struct and
call a function on that directly.

No functional changes.
2023-07-31 13:58:43 +02:00
Sybren A. Stüvel
7d72653c93 Extra tests for backslashed two-way variables 2023-07-31 12:32:42 +02:00
Sybren A. Stüvel
c7a709bbd3 Manager: change default name to 'Flamenco'
Change the default Manager name from "Flamenco Manager" to just "Flamneco".

The Manager is the central 'thing', and the web interface should just
show "Flamenco". There is no more Flamenco Server (which was a component
in Flamenco v2), and there is no other Flamenco component with a web
interface anyway.
2023-07-22 13:26:40 +02:00
Sybren A. Stüvel
ef68f71d54 Manager: actually include manager name in version API call
The API call `GetVersion` should return the Manager name, but it returned
the hard-coded application name `"Flamenco"` instead.
2023-07-21 17:08:10 +02:00
Sybren A. Stüvel
63634361ce Manager: make periodic database integrity check configurable
Instead of always performing the periodic integrity check, make it possible
to disable it or run it at different intervals.

Currently for the Blender Studio it's crunch time, so the check should
really only run when there is someone looking at the system (i.e. at
restarts for upgrade purposes).
2023-07-18 16:33:01 +02:00
Sybren A. Stüvel
1a79c19583 Manager: improve logging of database consistency checks
The log messages now all start with `database: `.

No functional changes.
2023-07-18 16:12:26 +02:00
Sybren A. Stüvel
4121c899c3 Manager: perform database integrity check every hour
Perform a database integrity check every hour. This check was already
performed at startup, in the main goroutine.
2023-07-18 16:10:17 +02:00
Sybren A. Stüvel
5eb57427fc Manager: better logging of schedule changes
Log more details of schedule changes, from within the sleep scheduler
(instead of the API implementation).
2023-07-18 15:55:51 +02:00
Sybren A. Stüvel
6994413ed6 Use new property names for 'use automatic values' button
Adjustment of the job settings property names, making them more widely
usable than just the 'use automatic values' button (also known as
'eval-on-submit').
2023-07-13 15:02:00 +02:00