Commit graph

31 commits

Author SHA1 Message Date
Tom Gundersen
50d469fe45 distro: replace BasePackages() with Packages()
Rather than getting a set of base packages from the ImageType, and then
appending the requested packages from the blueprint, pass the blueprint
into the new Packages() function, and return the full set of packages to
be depsolved.

This allows us to also append packages based on other customizations
too, and use that to append chrony when the timezone is set. This
matches the behavior anaconda had, and there was a TODO item to do this,
which had been overlooked.

Fixes #787.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-29 16:04:38 +02:00
Tom Gundersen
48079b3a4d rpmmd/RepoConf: rename Id to Name
This is how it is used in the rest of the code, as a name to represent
the repository in the weldr API. Rename to match its use, and avoid
confusion with the ID passed to dnf-json, which is not the same.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-28 00:23:54 +02:00
Tom Gundersen
0b3702cb19 distro/Manifest: generalize the size argument
When generating an osbuild manifest for an image type, we take a
customizations struct, which specifies the image-type-independent
customizations to apply. We also take the size argument, which is
specific to the image build and not part of the blueprint.

Introduce a new argument ImageOptions, which for now just wraps the size
argument. These options are specific to the image build/type, and
therefore does not belong with the other customizations.

For now this is a non-functional change, but follow-up commits will
introduce more types of image options.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-25 22:37:29 +02:00
Ondřej Budai
070929b622 api/rcm: use JobStatus() instead of JobResult()
This is the only place where JobResult() method is used. Let's replace it
with JobStatus() which provides the same data.
2020-05-19 22:20:20 +02:00
Lars Karlitski
b5769add2c 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
2020-05-08 14:53:00 +02:00
Lars Karlitski
37b42d452b store: make PushCompose() take a manifest
Code that's calling PushCompose() had to depsolve packages and fetch the
right ImageType from a distro, but not create the osbuild manifest. That
was left for PushCompose to do. Move it out of there to the callers, so
that the store is mainly concerned with storing things.

This also simplifies the argument list of PushCompose().
2020-05-08 14:53:00 +02:00
Lars Karlitski
cef7267a2d store: create compose id from PushCompose
Every caller had to make their own uuid and pass that into
PushCompose(). Make PushCompose() create the id and return it.
2020-04-01 00:29:13 +02:00
Lars Karlitski
a6338410bc rcm: remove outdated comment
PushCompose() does not inject a local target anymore.
2020-04-01 00:29:13 +02:00
Lars Karlitski
eb10cf3124 store: remove unused arguments from PushCompose 2020-04-01 00:29:13 +02:00
Tom Gundersen
fa015a70f6 rcm: rework the API for submitting composes
The API allowed composes to have multiple architectures, image
types and repositories. Turns out that's not exactly what we want
it is not clear how to combine the lits of each. Each architecture
might not combine with each image type, and it is not clear which
repositories are need for each image build. Lastly, while allowing
different image builds to have different distros in the same
compose does not appear immediately useful, there is no particular
reason to disallow that. This patch reworks the way composes are
specified.

The intention remains the same, to be able to submit several image
builds as one compose. But rather than taking arrays of image types
and architectures, take one array of image builds instead, each of
which consists of one distro, one architecture, one image build and
an array of repositories.

In a follow-up patch they will also each contain an array of upload
targets.

This means that each image build will have the same sort of structure
as a compose request in the weldr API. The reason we want to submit
an array of them rather than have them as individual composes, is that
in a follow-up patch we will introduce the concept of a "finalizer",
or "call-back" or something to that effect, which will be triggered
when all the images have been built successfully. The use-case is,
as always, koji, which requires this.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:04 +02:00
Tom Gundersen
1c0d951f54 rcm: make repository struct private
This is only used internally to the `submit()` function.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-29 16:08:04 +02:00
Martin Sehnoutka
9d2dacbcab internal: pass architecture from the APIs to dnf-json
The following commit will introduce support for forced architecture in
dnf-json. The APIs already have this kind of information, so we can
simply pass it to the Depsolve and FetchMetadata functions.
2020-03-24 20:45:30 +01:00
Tom Gundersen
d7aad58897 store/PushCompose: take ImageType and Arch as argumnet rather than strings
Resolve eagerly into real objects, and avoid having to resolve and
error-check again.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
7d4ad6b649 rcm/depsolve: take ImageType as argumnet rather than strings
Use the already resolved real object, and avoid having to resolve
and error-check again.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
1597ae2ed6 rcm/submit: resolve into real Arch and ImageType objects
Rather than using the `common` package, parse the JSON as strings,
then resolve into real Arch and ImageType objects.

This should not be a behavioural change, but will simplify the code
in subsequent commits.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Tom Gundersen
96b4850554 rcm/submit: fix error handling
We were not correctly catching the case where more than one arch
or more than one image type was specified.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-23 15:43:55 +01:00
Lars Karlitski
069ccba894 store: pass repos to PushCompose
Repositories were not passed down into `Distro.Manifest()`. This makes
all builds fail, because these repositories are use to access gpgkeys.
2020-03-21 11:08:16 +01:00
Lars Karlitski
baa055d6ee rcm: use same function as weldr for pushing composes
Now that `Store.PushCompose()` takes a `Distro` as argument, the rcm API
can use that function as well. This moves them both through the same
code path, reducing duplication.

Remove `PushComposeRequest()` and the corresponding struct. It was
supposed to allow composes with multiple output types and architectures,
but that was not yet implemented. Merging the two now simplifies moving
the compose queue out of the store in a future commit, which will then
tackle multi-image-type composes as well.
2020-03-18 08:33:42 +01:00
Lars Karlitski
15033faa81 rcm: pass packages when pushing a compose
In the post-dnf-stage world, `Distro.Manifest` expects the full list of
depsolved packages.  This is similar to what weldr does, but much
simpler, because the rcm API only cares about base packages.
2020-03-18 08:33:42 +01:00
Lars Karlitski
c2c8fae093 store: give ComposeRequest a real distro
`ComposeRequest` included a `common.Distribution`, which had to be
resolved in PushComposeRequest. Use a real `distro.Distro` object here,
and push resolving it to the rcm package.

Change the `Distribution` on the (lower-case) `composeRequest` to a
string. This struct represents the incoming request. Since we're now
resolving the real distro object from the registry in the same function,
it seems redundant to validate the incoming distro twice.
2020-03-18 08:33:42 +01:00
Tom Gundersen
5d179428be rpmmd: drop the Name attribute from RepoConfig
This was never actually used anywhere, as passing it to dnf-json
was a noop.

We may want to reconsider the concept of a source/repo name and
how it differs from an ID, but for now drop the name.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-03-15 23:48:42 +01:00
Lars Karlitski
72f8b07e8b store: move ComposeRequest to the store package
A ComposeRequest is data used to submit a compose to the store, so it
should live in that package.

Remove the json marshalling test, because ComposeRequest is never
marshalled to JSON.

This will allow to use types from `distro` in the ComposeRequest struct.
2020-03-12 20:01:24 +01:00
Martin Sehnoutka
923a0b0b97 rcm: introduce rpmmd member of the api structure
This is needed for unit tests, because it wasn't possible to mock the
rpmmd module before. This also requires that the checksum is moved to
the compose request and evaluated in the endpoint handler instead of
push compose. I think it makes sense to have the checksum in the compose
request directly.

Also a "module platform ID" is required now, but we don't have the
"global" distribution any more, so this patch introduces mapping from a
distribution to the module platform ID.
2020-02-20 13:04:28 +01:00
Martin Sehnoutka
e791f51e2e rcm: use pushcomposerequest instead of pushcompose
the new version is better suited for the need of this API
2020-02-20 13:04:28 +01:00
Martin Sehnoutka
d758a7ba1b rcm: use custom types in the RCM compose request
The change also requires customizations in the error handling, as some
errors are now handled automatically by the custom unmarshaler.

Include a note about HTTP return types.
2020-02-20 13:04:28 +01:00
Lars Karlitski
4f2ac6a687 tree-wide: format code with gofmt 2020-02-17 16:09:17 +01:00
Tom Gundersen
fefe5db4ce distro/pipeline: take depsolved packages as argument
This is unused for now, but will allow us to generate pipelines with
the pre-depsolved NEVRAs, so osbuild does not need to depsolve again.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-14 14:43:27 +01:00
Martin Sehnoutka
7f66147888 RCM API: return bad request instead of internal server error
push compose returns nil in case of any error, until we can
differentiate between internal server error and bad request, just return
bad request
2020-02-12 11:17:26 +01:00
Martin Sehnoutka
76947da8d5 RCM API: drop the checksum requirement for submit
The repositories used by RCM never change, there is no need for them to
include checksum of the repository.

Also rework the tests as the store will change in following commits
(store now needs to include a registry of all distros because we can do
cross-distro builds)
2020-02-12 11:17:26 +01:00
Jacob Kozol
e3d64ea1eb store: custom image size
When pushing a compose to the store an image size can be included in the
parameters.
2020-01-23 00:57:31 +01:00
Martin Sehnoutka
4f63b54a16 Introduce RCM API
It contains two basic endpoints:
 * POST /v1/compose
 * GET /v1/compose/<uuid>
It passes all the tests, but cannot be used for the intended use case
because the store API does not (yet) support distributions and
architectures as a parameters.
2020-01-15 15:46:52 +01:00