store: move queue out of the store
The store is responsible for two things: user state and the compose queue. This is problematic, because the rcm API has slightly different semantics from weldr and only used the queue part of the store. Also, the store is simply too complex. This commit splits the queue part out, using the new jobqueue package in both the weldr and the rcm package. The queue is saved to a new directory `queue/`. The weldr package now also has access to a worker server to enqueue and list jobs. Its store continues to track composes, but the `QueueStatus` for each compose (and image build) is deprecated. The field in `ImageBuild` is kept for backwards compatibility for composes which finished before this change, but a lot of code dealing with it in package compose is dropped. store.PushCompose() is degraded to storing a new compose. It should probably be renamed in the future. store.PopJob() is removed. Job ids are now independent of compose ids. Because of that, the local target gains ComposeId and ImageBuildId fields, because a worker cannot infer those from a job anymore. This also necessitates a change in the worker API: the job routes are changed to expect that instead of a (compose id, image build id) pair. The route that accepts built images keeps that pair, because it reports the image back to weldr. worker.Server() now interacts with a job queue instead of the store. It gains public functions that allow enqueuing an osbuild job and getting its status, because only it knows about the specific argument and result types in the job queue (OSBuildJob and OSBuildJobResult). One oddity remains: it needs to report an uploaded image to weldr. Do this with a function that's passed in for now, so that the dependency to the store can be dropped completely. The rcm API drops its dependencies to package blueprint and store, because it too interacts only with the worker server now. Fixes #342
This commit is contained in:
parent
64011e3cba
commit
b5769add2c
18 changed files with 415 additions and 443 deletions
|
|
@ -7,6 +7,8 @@ import (
|
|||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"github.com/osbuild/osbuild-composer/internal/compose"
|
||||
"github.com/osbuild/osbuild-composer/internal/jobqueue/testjobqueue"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
|
|
@ -150,6 +152,10 @@ func createBaseStoreFixture() *store.Store {
|
|||
return s
|
||||
}
|
||||
|
||||
func createBaseWorkersFixture() *worker.Server {
|
||||
return worker.NewServer(nil, testjobqueue.New(), nil)
|
||||
}
|
||||
|
||||
func createBaseDepsolveFixture() []rpmmd.PackageSpec {
|
||||
return []rpmmd.PackageSpec{
|
||||
{
|
||||
|
|
@ -207,6 +213,7 @@ func BaseFixture() Fixture {
|
|||
nil,
|
||||
},
|
||||
createBaseStoreFixture(),
|
||||
createBaseWorkersFixture(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -223,6 +230,7 @@ func NoComposesFixture() Fixture {
|
|||
nil,
|
||||
},
|
||||
createStoreWithoutComposesFixture(),
|
||||
createBaseWorkersFixture(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -242,6 +250,7 @@ func NonExistingPackage() Fixture {
|
|||
},
|
||||
},
|
||||
createBaseStoreFixture(),
|
||||
createBaseWorkersFixture(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -261,6 +270,7 @@ func BadDepsolve() Fixture {
|
|||
},
|
||||
},
|
||||
createBaseStoreFixture(),
|
||||
createBaseWorkersFixture(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -283,5 +293,6 @@ func BadFetch() Fixture {
|
|||
},
|
||||
},
|
||||
createBaseStoreFixture(),
|
||||
createBaseWorkersFixture(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package rpmmd_mock
|
|||
import (
|
||||
"github.com/osbuild/osbuild-composer/internal/rpmmd"
|
||||
"github.com/osbuild/osbuild-composer/internal/store"
|
||||
"github.com/osbuild/osbuild-composer/internal/worker"
|
||||
)
|
||||
|
||||
type fetchPackageList struct {
|
||||
|
|
@ -20,6 +21,7 @@ type Fixture struct {
|
|||
fetchPackageList
|
||||
depsolve
|
||||
*store.Store
|
||||
Workers *worker.Server
|
||||
}
|
||||
|
||||
type rpmmdMock struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue