
As it was decided that the name "tags" would be better for the clarity of the feature, all files and code named "cluster" or "worker cluster" have been removed and replaced with "tag" and "worker tag". This is only a name change, no other features were touched. This addresses part of #104204. Reviewed-on: https://projects.blender.org/studio/flamenco/pulls/104223 As a note to anyone who already ran a pre-release version of Flamenco and configured some worker clusters, with the help of an SQLite client you can migrate the clusters to tags. First build Flamenco Manager and start it, to create the new database schema. Then run these SQL queries via an sqlite commandline client: ```sql insert into worker_tags (id, created_at, updated_at, uuid, name, description) select id, created_at, updated_at, uuid, name, description from worker_clusters; insert into worker_tag_membership (worker_tag_id, worker_id) select worker_cluster_id, worker_id from worker_cluster_membership; ```
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
package webupdates
|
|
|
|
import (
|
|
"github.com/rs/zerolog/log"
|
|
|
|
"git.blender.org/flamenco/internal/manager/persistence"
|
|
"git.blender.org/flamenco/pkg/api"
|
|
)
|
|
|
|
// NewWorkerUpdate returns a partial SocketIOWorkerUpdate struct for the given worker.
|
|
// It only fills in the fields that represent the current state of the worker. For
|
|
// example, it omits `PreviousStatus`. The ommitted fields can be filled in by
|
|
// the caller.
|
|
func NewWorkerUpdate(worker *persistence.Worker) api.SocketIOWorkerUpdate {
|
|
workerUpdate := api.SocketIOWorkerUpdate{
|
|
Id: worker.UUID,
|
|
Name: worker.Name,
|
|
Status: worker.Status,
|
|
Version: worker.Software,
|
|
Updated: worker.UpdatedAt,
|
|
}
|
|
|
|
if worker.StatusRequested != "" {
|
|
workerUpdate.StatusChange = &api.WorkerStatusChangeRequest{
|
|
Status: worker.StatusRequested,
|
|
IsLazy: worker.LazyStatusRequest,
|
|
}
|
|
}
|
|
|
|
if !worker.LastSeenAt.IsZero() {
|
|
workerUpdate.LastSeen = &worker.LastSeenAt
|
|
}
|
|
|
|
// TODO: add tag IDs.
|
|
|
|
return workerUpdate
|
|
}
|
|
|
|
// BroadcastWorkerUpdate sends the worker update to clients.
|
|
func (b *BiDirComms) BroadcastWorkerUpdate(workerUpdate api.SocketIOWorkerUpdate) {
|
|
log.Debug().Interface("workerUpdate", workerUpdate).Msg("socketIO: broadcasting worker update")
|
|
b.BroadcastTo(SocketIORoomWorkers, SIOEventWorkerUpdate, workerUpdate)
|
|
}
|
|
|
|
// BroadcastNewWorker sends a "new worker" notification to clients.
|
|
func (b *BiDirComms) BroadcastNewWorker(workerUpdate api.SocketIOWorkerUpdate) {
|
|
if workerUpdate.PreviousStatus != nil {
|
|
log.Warn().Interface("workerUpdate", workerUpdate).Msg("socketIO: new workers should not have a previous state")
|
|
workerUpdate.PreviousStatus = nil
|
|
}
|
|
|
|
log.Debug().Interface("workerUpdate", workerUpdate).Msg("socketIO: broadcasting new worker")
|
|
b.BroadcastTo(SocketIORoomWorkers, SIOEventWorkerUpdate, workerUpdate)
|
|
}
|