From 28a56f3d911ce93402e3aab2c033d00c1c54ce9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 28 Jan 2022 15:31:39 +0100 Subject: [PATCH] Store workers in database when registering --- Makefile | 10 ++- internal/manager/api_impl/api_impl.go | 10 ++- internal/manager/api_impl/workers.go | 29 +++++-- internal/manager/persistence/db_migration.go | 2 +- internal/manager/persistence/jobs_test.go | 2 + internal/manager/persistence/workers.go | 59 +++++++++++++ internal/manager/persistence/workers_test.go | 68 +++++++++++++++ pkg/api/flamenco-manager.yaml | 14 ++-- pkg/api/openapi_spec.gen.go | 88 ++++++++++---------- pkg/api/openapi_types.gen.go | 36 ++++++-- 10 files changed, 247 insertions(+), 71 deletions(-) create mode 100644 internal/manager/persistence/workers.go create mode 100644 internal/manager/persistence/workers_test.go diff --git a/Makefile b/Makefile index 2cf398a1..f2a77f8a 100644 --- a/Makefile +++ b/Makefile @@ -28,11 +28,13 @@ with-deps: go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen make -s application -application: ${RESOURCES} - go generate ${PKG}/... +application: ${RESOURCES} generate go build -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-manager-poc go build -v ${BUILD_FLAGS} ${PKG}/cmd/flamenco-worker-poc +generate: + go generate ${PKG}/... + # resource.syso: resource/thermogui.ico resource/versioninfo.json # goversioninfo -icon=resource/thermogui.ico -64 resource/versioninfo.json @@ -53,7 +55,7 @@ swagger-ui: @echo @echo 'Now update pkg/api/static/swagger-ui/index.html to have url: "/api/openapi3.json",' -test: +test: generate go test -short ${PKG_LIST} vet: @@ -70,7 +72,7 @@ clean: go generate ./... # static: vet lint resource.syso -static: vet lint +static: vet lint generate CGO_ENABLED=0 go build -v -o flamenco-manager-poc-static -tags netgo -ldflags="-extldflags \"-static\" -w -s ${LDFLAGS}" ${PKG}/cmd/flamenco-manager-poc CGO_ENABLED=0 go build -v -o flamenco-worker-poc-static -tags netgo -ldflags="-extldflags \"-static\" -w -s ${LDFLAGS}" ${PKG}/cmd/flamenco-worker-poc diff --git a/internal/manager/api_impl/api_impl.go b/internal/manager/api_impl/api_impl.go index f6019f99..20a197f5 100644 --- a/internal/manager/api_impl/api_impl.go +++ b/internal/manager/api_impl/api_impl.go @@ -26,18 +26,22 @@ import ( "github.com/labstack/echo/v4" "gitlab.com/blender/flamenco-ng-poc/internal/manager/job_compilers" + "gitlab.com/blender/flamenco-ng-poc/internal/manager/persistence" "gitlab.com/blender/flamenco-ng-poc/pkg/api" ) type Flamenco struct { jobCompiler JobCompiler - persist JobPersistenceService + persist PersistenceService } -type JobPersistenceService interface { +type PersistenceService interface { // StoreJob stores a job in the persistence layer. StoreJob(ctx context.Context, authoredJob job_compilers.AuthoredJob) error FetchJob(ctx context.Context, jobID string) (*api.Job, error) + + CreateWorker(ctx context.Context, w *persistence.Worker) error + FetchWorker(ctx context.Context, uuid string) (*persistence.Worker, error) } type JobCompiler interface { @@ -48,7 +52,7 @@ type JobCompiler interface { var _ api.ServerInterface = (*Flamenco)(nil) // NewFlamenco creates a new Flamenco service, using the given JobCompiler. -func NewFlamenco(jc JobCompiler, jps JobPersistenceService) *Flamenco { +func NewFlamenco(jc JobCompiler, jps PersistenceService) *Flamenco { return &Flamenco{ jobCompiler: jc, persist: jps, diff --git a/internal/manager/api_impl/workers.go b/internal/manager/api_impl/workers.go index 0d0949fb..a8603576 100644 --- a/internal/manager/api_impl/workers.go +++ b/internal/manager/api_impl/workers.go @@ -22,14 +22,17 @@ package api_impl import ( "net/http" + "strings" "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/rs/zerolog/log" + "gitlab.com/blender/flamenco-ng-poc/internal/manager/persistence" "gitlab.com/blender/flamenco-ng-poc/pkg/api" ) +// RegisterWorker registers a new worker and stores it in the database. func (f *Flamenco) RegisterWorker(e echo.Context) error { remoteIP := e.RealIP() @@ -46,17 +49,33 @@ func (f *Flamenco) RegisterWorker(e echo.Context) error { logger.Info().Str("nickname", req.Nickname).Msg("registering new worker") + dbWorker := persistence.Worker{ + UUID: uuid.New().String(), + Name: req.Nickname, + Platform: req.Platform, + Address: remoteIP, + SupportedTaskTypes: strings.Join(req.SupportedTaskTypes, ","), + } + if err := f.persist.CreateWorker(e.Request().Context(), &dbWorker); err != nil { + logger.Warn().Err(err).Msg("error creating new worker in DB") + return sendAPIError(e, http.StatusBadRequest, "error registering worker") + } + return e.JSON(http.StatusOK, &api.RegisteredWorker{ - Id: uuid.New().String(), - Nickname: req.Nickname, - Platform: req.Platform, - Address: remoteIP, + Uuid: dbWorker.UUID, + Nickname: dbWorker.Name, + Address: dbWorker.Address, + LastActivity: dbWorker.LastActivity, + Platform: dbWorker.Platform, + Software: dbWorker.Software, + Status: dbWorker.Status, + SupportedTaskTypes: strings.Split(dbWorker.SupportedTaskTypes, ","), }) } func (f *Flamenco) ScheduleTask(e echo.Context) error { return e.JSON(http.StatusOK, &api.AssignedTask{ - Id: uuid.New().String(), + Uuid: uuid.New().String(), Commands: []api.Command{ {Name: "echo", Settings: echo.Map{"payload": "Simon says \"Shaders!\""}}, {Name: "blender", Settings: echo.Map{"blender_cmd": "/shared/bin/blender"}}, diff --git a/internal/manager/persistence/db_migration.go b/internal/manager/persistence/db_migration.go index 68abc8a0..5793baad 100644 --- a/internal/manager/persistence/db_migration.go +++ b/internal/manager/persistence/db_migration.go @@ -25,7 +25,7 @@ import ( ) func (db *DB) migrate() error { - err := db.gormDB.AutoMigrate(&Job{}, &Task{}) + err := db.gormDB.AutoMigrate(&Job{}, &Task{}, &Worker{}) if err != nil { return fmt.Errorf("failed to automigrate database: %v", err) } diff --git a/internal/manager/persistence/jobs_test.go b/internal/manager/persistence/jobs_test.go index 2f6114b9..c54e17ed 100644 --- a/internal/manager/persistence/jobs_test.go +++ b/internal/manager/persistence/jobs_test.go @@ -112,4 +112,6 @@ func TestStoreAuthoredJob(t *testing.T) { assert.NoError(t, tx.Error) assert.Len(t, tasks, 3) + + // TODO: test task contents. } diff --git a/internal/manager/persistence/workers.go b/internal/manager/persistence/workers.go new file mode 100644 index 00000000..81029dd1 --- /dev/null +++ b/internal/manager/persistence/workers.go @@ -0,0 +1,59 @@ +package persistence + +/* ***** BEGIN GPL LICENSE BLOCK ***** + * + * Original Code Copyright (C) 2022 Blender Foundation. + * + * This file is part of Flamenco. + * + * Flamenco is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * Flamenco is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Flamenco. If not, see . + * + * ***** END GPL LICENSE BLOCK ***** */ + +import ( + "context" + "fmt" + + "gitlab.com/blender/flamenco-ng-poc/pkg/api" + "gorm.io/gorm" +) + +type Worker struct { + gorm.Model + UUID string `gorm:"type:char(36);not null;unique;index"` + Name string `gorm:"type:varchar(64);not null"` + + Address string `gorm:"type:varchar(39);not null;index"` // 39 = max length of IPv6 address. + LastActivity string `gorm:"type:varchar(255);not null"` + Platform string `gorm:"type:varchar(16);not null"` + Software string `gorm:"type:varchar(32);not null"` + Status api.WorkerStatus `gorm:"type:varchar(16);not null"` + + SupportedTaskTypes string `gorm:"type:varchar(255);not null"` // comma-separated list of task types. +} + +func (db *DB) CreateWorker(ctx context.Context, w *Worker) error { + if err := db.gormDB.Create(w).Error; err != nil { + return fmt.Errorf("error creating new worker: %v", err) + } + return nil +} + +func (db *DB) FetchWorker(ctx context.Context, uuid string) (*Worker, error) { + w := Worker{} + findResult := db.gormDB.First(&w, "uuid = ?", uuid) + if findResult.Error != nil { + return nil, findResult.Error + } + return &w, nil +} diff --git a/internal/manager/persistence/workers_test.go b/internal/manager/persistence/workers_test.go new file mode 100644 index 00000000..82c3268c --- /dev/null +++ b/internal/manager/persistence/workers_test.go @@ -0,0 +1,68 @@ +// Package persistence provides the database interface for Flamenco Manager. +package persistence + +/* ***** BEGIN GPL LICENSE BLOCK ***** + * + * Original Code Copyright (C) 2022 Blender Foundation. + * + * This file is part of Flamenco. + * + * Flamenco is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * Flamenco is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Flamenco. If not, see . + * + * ***** END GPL LICENSE BLOCK ***** */ + +import ( + "testing" + "time" + + "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "gitlab.com/blender/flamenco-ng-poc/pkg/api" + "golang.org/x/net/context" +) + +func TestCreateFetchWorker(t *testing.T) { + db := createTestDB(t) + + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) + defer cancel() + + w := Worker{ + UUID: uuid.New().String(), + Name: "дрон", + Address: "fe80::5054:ff:fede:2ad7", + LastActivity: "", + Platform: "linux", + Software: "3.0", + Status: api.WorkerStatusAwake, + SupportedTaskTypes: "blender,ffmpeg,file-management", + } + + err := db.CreateWorker(ctx, &w) + assert.NoError(t, err) + + fetchedWorker, err := db.FetchWorker(ctx, w.UUID) + assert.NoError(t, err) + assert.NotNil(t, fetchedWorker) + + // Test contents of fetched job + assert.Equal(t, w.UUID, fetchedWorker.UUID) + assert.Equal(t, w.Name, fetchedWorker.Name) + assert.Equal(t, w.Address, fetchedWorker.Address) + assert.Equal(t, w.LastActivity, fetchedWorker.LastActivity) + assert.Equal(t, w.Platform, fetchedWorker.Platform) + assert.Equal(t, w.Software, fetchedWorker.Software) + assert.Equal(t, w.Status, fetchedWorker.Status) + + assert.EqualValues(t, w.SupportedTaskTypes, fetchedWorker.SupportedTaskTypes) +} diff --git a/pkg/api/flamenco-manager.yaml b/pkg/api/flamenco-manager.yaml index de6ec446..4819357b 100644 --- a/pkg/api/flamenco-manager.yaml +++ b/pkg/api/flamenco-manager.yaml @@ -138,23 +138,27 @@ components: RegisteredWorker: type: object properties: - id: {type: string, format: uuid} + uuid: {type: string, format: uuid} nickname: {type: string} address: {type: string} - status: {type: string} + status: {$ref: "#/components/schemas/WorkerStatus"} platform: {type: string} last_activity: {type: string} software: {type: string} supported_task_types: type: array items: {type: string} - required: [id, nickname, address, status, platform, current_task, last_activity, software, supported_task_types] + required: [uuid, nickname, address, status, platform, current_task, last_activity, software, supported_task_types] + + WorkerStatus: + type: string + enum: [starting, awake, asleep, error, shutting-down, testing] AssignedTask: type: object description: AssignedTask is a task as it is received by the Worker. properties: - id: {type: string, format: uuid} + uuid: {type: string, format: uuid} job: {type: string} user: {type: string} name: {type: string} @@ -166,7 +170,7 @@ components: commands: type: array items: {$ref: "#/components/schemas/Command"} - required: [id, job, user, name, status, priority, job_priority, job_type, task_type, commands] + required: [uuid, job, user, name, status, priority, job_priority, job_type, task_type, commands] JobStatus: type: string diff --git a/pkg/api/openapi_spec.gen.go b/pkg/api/openapi_spec.gen.go index 7d4de50d..d4045b30 100644 --- a/pkg/api/openapi_spec.gen.go +++ b/pkg/api/openapi_spec.gen.go @@ -18,50 +18,50 @@ import ( // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/7xa224bN/p/FYL9A/8WO5KcuHujq02bJnXQg1G56EViyJzhJw1tDjkhOZK1gYA+xL7J", - "boG92F7tC7hvtPhIzkkztpzdHBAYoyH58Tv+voP0jma6KLUC5Sydv6M2y6Fg/vGZtWKtgF8we4OfOdjM", - "iNIJrei8t0qEJYw4fGKWCIefDWQgNsBJuiMuB/KLNjdgpjShpdElGCfA35LpomCK+2fhoPAP/2dgRef0", - "s1nL3CxyNvs6HKD7hLpdCXROmTFsh58Fx8MrbQrm6JxWleC02WWdEWqN2651ivvG3i9LI7QRbtfZIJSD", - "NZh6R3g7clyxYnzhYZrWMVcdlRrVvAg7UXBmb+5npLJgRhb2CTXwthIGO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+ "96+7n3/96e7fd7/c/bM/bln+9WiY+OMt67zkyTJ5Gz/ekgWLWl2trfg7JstjkskZyN0aai50AzkUlL6m", + "XyYL408u7GZxqTNyYFT47Pnx3JPsp5LTr17Tx8omy+cfp8mGylibLJNns2dHVE6XsEW71mZ9LThqqhH8", + "myRNdO2q2oVWAm8cKhvsMq885AQO1mHXkKVwSctULy6sIFPNouCzcCRM4Ybe1dnxkVzb5rWnzvjaXpiM", + "MzHw65nrsTTfbO316g8HQwzmOGVruZqKjd5I8R3ySZs5Wqin2O8yy1PyRJt0KqNztJSuJzNBAMuQDwyE", + "oB3DxG9Ac8wNuuml34jKI6PEmwaAOnlFD5CnLDZIHj2bWQfGhTQNO7jyaG4lIlV86NE1TWxRe1+acb3z", + "gw70w7gJvQfVeGhekSsG0Xf+7jXUhA4Hpa5FQ1wzYX2JFTazk5cpq8DanTa8WQq6CANXBq7ZanpGJsj1", + "QeAnMWBF3qWzwrkquSUehdro0JEoB7nrWqOkgW52hkCqro2MJ+1ysdg0wC704rAC/SbMmV6BKVkZWk32", + "4vSEUp7IUVns3fP69Ivr4wP6u91uvlU14fwinrGLbSVnx/OjOap54cpQGgonB9zG65I0uUYTkfDZ/Gh+", + "RLt1hQoqQUnBv6IgcoW3zAIq4THaB4e2XhUUIl6ZJzzMmkrhQhMSA/ETzfeN+lD5M1BVUuT+1OLShmAL", + "YPQYVA07rtsDrfo5iI4JNukHB+UdHy220qQpuun50dEfytkOLLN1nqPd1FLuWZhCI2dCOc2E4uJa8Bpk", + "GFzPR1P734XNUANN8OcXWFPi+NisyxLMvrUqA6Zw52cm1OG07hQHJb3Jgh9zAyUeP8qg1q1P7k0zebXk", + "fAwVr7RQzsvb+tiixcItTjjaa3TteOc9WvVwljShunZTN08aKfA1OiYPZk5+HFOgMKOR3AOq665q1X/Z", + "fRU10N/bS52tBb+9V4Wv0OVFCNXufj/zECRVnMhGCArEDiIq7enxsb7g/D3a6YGg8/A9NIeX3C8wyMJX", + "It52T/DbcEjxCKIlcd6oPWSYhYlt5WzXdZWTYNn0n7H7fD+IOVHaTCgq7KIQbrj/Q8HzoBOfYFGRe0nW", + "8PCHgmOt8KbCnDo2jHv6jtGwHxFy19iz8aX44nziUDAJ4UJ30o49ysVfPNyTc/MCeS3xLHTM7w8L+7+/", + "mFCS/+VFPwncpsnzo48Pi7ivdPxmdvhtk5+6N8Po2zT5+Oj498vOgxHABPOnaJp89BKVQD4oTz0qDgrT", + "788Jzzprfp05ECo6gBtq4jFP8Iqz0Yqmnw89C+a6weVQ/y0SujpSHOv2E9In/fcq9d83EidbdD5RtNPO", + "DGQmYYDv1o+wR6nt9GSY7IN9PM1cl2WtyB7xpwnjimDekY9y357f/i8AAP//twRIw+EjAAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/pkg/api/openapi_types.gen.go b/pkg/api/openapi_types.gen.go index 53c8eb02..87e22e5e 100644 --- a/pkg/api/openapi_types.gen.go +++ b/pkg/api/openapi_types.gen.go @@ -89,10 +89,24 @@ const ( TaskStatusSoftFailed TaskStatus = "soft-failed" ) +// Defines values for WorkerStatus. +const ( + WorkerStatusAsleep WorkerStatus = "asleep" + + WorkerStatusAwake WorkerStatus = "awake" + + WorkerStatusError WorkerStatus = "error" + + WorkerStatusShuttingDown WorkerStatus = "shutting-down" + + WorkerStatusStarting WorkerStatus = "starting" + + WorkerStatusTesting WorkerStatus = "testing" +) + // AssignedTask is a task as it is received by the Worker. type AssignedTask struct { Commands []Command `json:"commands"` - Id string `json:"id"` Job string `json:"job"` JobPriority int `json:"job_priority"` JobType string `json:"job_type"` @@ -101,6 +115,7 @@ type AssignedTask struct { Status TaskStatus `json:"status"` TaskType string `json:"task_type"` User string `json:"user"` + Uuid string `json:"uuid"` } // Single setting of a Job types. @@ -191,14 +206,14 @@ type JobStatus string // RegisteredWorker defines model for RegisteredWorker. type RegisteredWorker struct { - Address string `json:"address"` - Id string `json:"id"` - LastActivity string `json:"last_activity"` - Nickname string `json:"nickname"` - Platform string `json:"platform"` - Software string `json:"software"` - Status string `json:"status"` - SupportedTaskTypes []string `json:"supported_task_types"` + Address string `json:"address"` + LastActivity string `json:"last_activity"` + Nickname string `json:"nickname"` + Platform string `json:"platform"` + Software string `json:"software"` + Status WorkerStatus `json:"status"` + SupportedTaskTypes []string `json:"supported_task_types"` + Uuid string `json:"uuid"` } // SecurityError defines model for SecurityError. @@ -227,6 +242,9 @@ type WorkerRegistration struct { SupportedTaskTypes []string `json:"supported_task_types"` } +// WorkerStatus defines model for WorkerStatus. +type WorkerStatus string + // SubmitJobJSONBody defines parameters for SubmitJob. type SubmitJobJSONBody SubmittedJob