1879 Commits

Author SHA1 Message Date
Sybren A. Stüvel
63a2bce600 run go mod tidy
No functional changes.
2024-03-04 13:53:24 +01:00
Sybren A. Stüvel
3b4da656c9 Add-on: cache manager info in a JSON file
Instead of storing the cached manager info in the Blender preferences,
store the info in a JSON file. The file is located in the user prefs
folder (`~/.config/blender/{version}/config` on Linux).

This also reduces the number of 'refresh' operators to a single one, which
then fetches all necessary info from the Manager.

This fixes an issue (reported via chat) where worker tags were sometimes
not retained across file saves.
2024-03-04 13:08:53 +01:00
Sybren A. Stüvel
a4e5eef83e Manager: fix database migration 0004
Fix the database migration that adds `NOT NULL` clauses. It used
`INSERT INTO temp_x SELECT * from x;`, and the `*` returns the fields in
the order they are defined on the table. Since this might be different from
the order that the `INSERT INTO temp_x` expects, strange problems can
happen where columns get swapped (or constraints can fail on columns that
they should not fail for, because they got fed data from a different
column).
2024-03-04 13:06:09 +01:00
Sybren A. Stüvel
f9bb7afcc6 Add-on: fix mypy warnings
No functional changes.
2024-03-04 12:46:38 +01:00
Sybren A. Stüvel
7b72d0ca43 Refactor: move jobs-related queries to queries_jobs.sql
This makes it easier to later also create `query_workesr.sql`,
`query_meta.sql` etc. so that the sqlc-generated code can follow the
same subdivision as the persistence service code itself.

No functional changes.
2024-03-03 23:27:55 +01:00
Sybren A. Stüvel
b102b73a1f Refactor: convert more job functions to sqlc
No functional changes.
2024-03-03 23:23:51 +01:00
Sybren A. Stüvel
1ac796d0d8 Refactor: Manager: remove unused query from queries.sql
No functional changes.
2024-03-03 22:42:37 +01:00
Sybren A. Stüvel
3fbb3cde34 Manager: SQLC rename Uuid to UUID
No functional changes.
2024-03-03 20:54:43 +01:00
Sybren A. Stüvel
c046094880 Manager: start replacing GORM with SQLC
GORM has certain downsides:

- Code-first approach, where queries have to be translated to the Go code
  required to execute them.
- GORM comes with its own SQLite implementation, which doesn't provide an
  on-connect callback. This means that new connections cannot correctly
  enable foreign key constraints, causing database consistency issues.

[SQLC](https://sqlc.dev/) solves these issues for us.

This commit doesn't fully replace GORM with SQLC, but introduces it for
a few queries. Once all queries have been converted, GORM can be removed
completely.
2024-03-03 20:15:39 +01:00
Sybren A. Stüvel
7b31eba8d7 Webapp: improve positioning of the farm status indicator
Split the header into two or three parts, depending on the number of
columns shown. The farm status indicator will be above the middle column
(in 3 col mode) or at the right edge of the left column (in 2 col mode).

Also I reverted the hiding of the farm status when SocketIO has
disconnected, as that disconnect happens when navigation between tabs.
That created a too 'blinky' interface, so now it just shows the last-known
farm status.
2024-03-02 23:11:33 +01:00
Sybren A. Stüvel
7bf121e93e Webapp: show explanation in farm status tooltip 2024-03-02 22:32:02 +01:00
Sybren A. Stüvel
63e3c8de37 Webapp: make SocketIO reconnect faster
The exponential backoff was getting a bit too long, making the webapp
sometimes very slow to reconnect. This is now limited to max 3 seconds.
2024-03-02 22:20:42 +01:00
Sybren A. Stüvel
c0c70758c6 Webapp: hide farm status when SOcketIO is disconnected
Better to not show the farm status if the connection is lost.
2024-03-02 22:20:01 +01:00
Sybren A. Stüvel
1e7c059d12 Manager: check the farm status quickly after startup
The database is polled every 30 seconds to determine the farm status; at
startup the first poll is done after 1 second to get a faster status.

Note that when jobs and workers change their status, the farm status is
always updated.
2024-03-02 22:09:53 +01:00
Sybren A. Stüvel
7eb5eb68a3 Manager: ensure foreign keys are enabled in periodic integrity check
There are still issues with foreign keys getting disabled, so enable them
in the periodic database consistency check.

A more permanent solution is likely to drop GORM and switch to something
else that gives us an on-connect-callback, which can then be used to
turn on foreign key constraints for every connection made.
2024-03-01 23:42:04 +01:00
Sybren A. Stüvel
f763d12cd8 Update CHANGELOG 2024-03-01 22:40:21 +01:00
Sybren A. Stüvel
59bf389018 Webapp: show farm status in header bar
Show the farm status in the webapp header bar, and respond to farm status
events to update it when necessary.
2024-03-01 22:36:38 +01:00
Sybren A. Stüvel
c1a9b1e877 Manager: force a poll of the farm status when a job/worker changes state
This introduces the concept of 'event listener', which is now used by
the farm status service to respond to events on the event bus.

This makes it possible to reduce the regular poll period from 5 to 30
seconds. That's now only necessary as backup, just in case events are
missed or otherwise things change without the event bus logic noticing.
2024-03-01 22:36:38 +01:00
Sybren A. Stüvel
9bfb53a7f6 Manager: log error when an event doesn't have a SocketIO event type
SocketIO has 'rooms' and 'event types'. The 'event type' is set via
reflection of the OpenAPI type of the event payload. This has to be set
up in a mapping, though, and if that mapping is incomplete, an error will
now be logged.
2024-03-01 22:36:26 +01:00
Sybren A. Stüvel
ee7af29748 Manager: fix unit test for farm status events 2024-03-01 22:36:26 +01:00
Sybren A. Stüvel
54f7878045 Manager: add farm status events to the event bus
Send an event to the event bus whenever the farm status changes. The event
contains a farm status report (like `{status: "active"}`), and is sent to
the `/status` topic.

Note that at this moment the status is only polled every X seconds, and
thus may lag behind other events.
2024-03-01 08:41:35 +01:00
Sybren A. Stüvel
8cf19876c0 OAPI: regenerate code 2024-03-01 08:36:40 +01:00
Sybren A. Stüvel
3b1421c227 OAPI: add farm status events to the event bus 2024-03-01 08:36:19 +01:00
Sybren A. Stüvel
61cc8ff04d Manager: implement API operation to get the farm status
Add a new API operation to get the overall farm status. This is based on
the jobs and workers, and their status.

The statuses are:

- `active`: Actively working on jobs.
- `idle`: Farm could be active, but has no work to do.
- `waiting`: Work has been queued, but all workers are asleep.
- `asleep`: Farm is idle, and all workers are asleep.
- `inoperative`: Cannot work: no workers, or all are offline/error.
- `starting`: Farm is starting up.
- `unknown`: Unexpected configuration of worker and job statuses.
2024-02-29 20:42:28 +01:00
Sybren A. Stüvel
d9ffe8a1b6 OAPI: regenerate code 2024-02-29 20:38:38 +01:00
Sybren A. Stüvel
0c7bf3bf3b OAPI: add farm status service
Add an OpenAPI operation to fetch the overall farm status from the Manager.
2024-02-29 20:27:44 +01:00
Sybren A. Stüvel
94bf65a9e3 Bumped version to 3.5-alpha1 2024-02-26 18:17:19 +01:00
Sybren A. Stüvel
6162d280f1 Website: Bump available experimental version to 3.5-alpha0 2024-02-26 18:14:40 +01:00
Sybren A. Stüvel
81968610ed Worker: blender-render command, make the blendfile parameter optional
Only include the `blendfile` parameter if it is not empty. This makes it
possible to pass a Python script that loads/constructs the blend file,
instead of loading one directly.
2024-02-25 23:09:11 +01:00
Sybren A. Stüvel
72d5cfa07c Job compiler: test simplification of frame range for video task 2024-02-24 11:57:52 +01:00
Emmanuel Durand
1ffe0a10bd Job compiler: simplify output video name on rendering list of frames
When a more complex list of frames is to be rendered (like `1, 4, 5, 10,
15`), simplify the video filename to `{first}-{last}`.

Before: `somename-1, 4, 5, 10, 15.mp4`
Now:    `somename-1-15.mp4`
2024-02-24 11:57:46 +01:00
Sybren A. Stüvel
5b17fb24fd Website: clarify the worker configuration files
Add a little intro that explains that there are multiple config files. And
add a section that explains that the worker-specific files are not to be
edited, just deleted.
2024-02-22 13:05:22 +01:00
Sybren A. Stüvel
99062d42ac Website: add draft documentation for failure handling
The documentation isn't complete yet, I want to have a nice flow diagram
in there as well. But it's a start.
2024-02-22 13:00:24 +01:00
Sybren A. Stüvel
dfdb8e82a1 Worker: Refer to website instead of non-existent example file
The worker-written config files would all refer to
`flamenco-worker-example.yaml`, even though this file doesn't even
exist. Instead, the configuration file will refer to the appropriate
documentation on the website, and the credentials file will explain what
happens when you delete it.

The credentials are otherwise intentionally left undocumented, as their
contents are not to be manually edited. The only thing to do with that
file is delete it so that the Worker re-registers itself at startup.
2024-02-22 12:46:13 +01:00
Sybren A. Stüvel
7033028a0b Worker: use explicit type when writing config file
Instead of passing an arbitrary string ("Configuration" or "Credentials"),
use an explicit type for this. This will make it possible to have the
config-writing functions behave slightly differently depending on which
configuration type is being written.

No functional changes.
2024-02-22 12:46:13 +01:00
Sybren A. Stüvel
12bfa82854 Manager: add lifecycle events to the event bus
Send events on Manager startup & shutdown. To make this possible, events
sent to MQTT are now queued up until an MQTT server can be reached.
Otherwise the startup event would be sent before the MQTT connection was
established.
2024-02-21 22:20:56 +01:00
Sybren A. Stüvel
fd9605583f OAPI: regenerate code 2024-02-21 22:16:23 +01:00
Sybren A. Stüvel
a137ecd3cd OAPI: add lifecycle events
Add events for manager-startup and manager-shutdown.
2024-02-21 22:12:43 +01:00
Sybren A. Stüvel
e7bd8dff8a Bump Go version to 1.22 2024-02-21 21:23:08 +01:00
Sybren A. Stüvel
17c92e18c7 Website: adjust documentation for the new event bus
Needs more work though. At least now it doesn't point to non-existing
files any more.
2024-02-05 09:27:06 +01:00
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
1ed893fa84 OAPI: regenerate code 2024-02-05 09:14:31 +01:00
Sybren A. Stüvel
441079aa06 OAPI: rename SocketIOxxx types to Eventxxx types
Events were previously only sent via SocketIO, but now they can also be
sent via MQTT. These are now renamed from `SocketIO…` to `Event…`.

There is still the SocketIO subscription mechanism, for which the types are
still prefixed with `SocketIO`. MQTT manages subscription on the broker,
not on Flamenco Manager itself, for now this will remain SocketIO-only
functionality.
2024-02-05 09:11:13 +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