Commit graph

84 commits

Author SHA1 Message Date
Tom Gundersen
b6d9268810 dnf-json: support excluding packages
In our base distro definitions we exclude packages in addition to
including them. Extend dnf-json to support this, so we can depsolve
the base package set as well as the packages added in blueprints.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-14 14:43:27 +01:00
Ondřej Budai
55d3854033 targets/local: drop Location field
When support for osbuild result was added into osbuild-composer it was in
a bit hacky way - localtarget's location was reused as a path for the
result. This didn't make much sense because we want to store the result
even when image build has no localtarget.

Several past commits made store less dependant on the localtarget. The
responsibility for "holding the paths" to build artifacts was gradually
switched from the localtarget to the store while still maintaining
backwards compatibility - localtarget.Location still pointed at the
correct location.

This commit finishes the switch: local target now has no Location field.
The store is now fully responsible for managing the artifacts and paths
to them. LocalTarget is now just a simple "switch" - if image build has it,
then worker uploads an image into the store and it's then available for
download using the weldr API.
2020-02-14 11:53:38 +01:00
Ondřej Budai
08c5eaf6a6 store disk artifacts per image build instead of per compose
In #221 Compose was refactored: Now it can have multiple image builds. More
image builds result in more jobs. Each job has its own result (logs from
osbuild). Additionally, also targets are now a part of image build. With
local target this effectively means we can have multiple images per compose.

However, these artifacts (images & results) were stored only per compose
prior this commit, thus rendering the behaviour of composes with multiple
image builds undefined and racy.

This commit fixes it by storing all the artifacts per image build instead of
per compose. To achieve this feature, getComposeDirectory and
getImageBuildDirectory methods were created to centralize the path assembly.

Paths to artifacts prior this commit:
${COMPOSER_STATE_DIR}/outputs/${COMPOSE_ID}/*

Paths to artifacts after this commit:
${COMPOSER_STATE_DIR}/outputs/${COMPOSE_ID}/${IMAGE_BUILD_ID}/*
2020-02-14 11:53:38 +01:00
Ondřej Budai
cc00e0cdc9 drop the Compose.Image field
Everything that this field contained can be computed in another way:

- path: just lookup the local target and read the path from there
- mime: can be derived from distribution and compose output type
- size: can be derived from the path

Therefore it imho doesn't make much sense to store these information multiple
times.
2020-02-14 11:53:38 +01:00
Ondřej Budai
a9633d29e9 weldr: clean up the image size code
There's no connection between user-specified image size and actual image
size (which might differ du to a compression). Therefore, it's not needed
to check if the actual image exists if we want to return just the
user-specified size.
2020-02-14 11:53:38 +01:00
Jacob Kozol
238d2b562e weldr: add filtering to compose route
When requesting the compose status, a user may want to filter the list
of composes by blueprint name, compose status, and/or compose type. These
filters can now be set in the /compose/status route's url as the queries
blueprint, status, and type.
2020-02-12 19:23:40 +01:00
Martin Sehnoutka
ab6b6da76c Weldr API: use the new compose/store API
The compose now contains multiple image builds, but Weldr API does not
support this feature. Use the first image build every time.

Also start using the new types instead of plain strings.
2020-02-12 11:17:26 +01:00
Jacob Kozol
abb5469b30 distro: get proper image size from distro
When a user does not define the image size for a compose the default
image size of that image type is used. In order to properly store the
compose's image size even if the default is used the store calls the
distro function GetSizeForOutputType. This function accepts an output
format and image size. If the image size is 0 then the default
value for the output format will be returned. Also, for vhd images the
size must be rounded. This is now handled in the distro function instead
of the api.
2020-02-07 14:49:15 +01:00
Jacob Kozol
e30f40873d store: add image size to compose
When a use defines the image size for a compose this size is stored in
the compose struct so that the virtual image size can be returned by the
api instead of the file size of the image.
2020-02-07 14:49:15 +01:00
Brian C. Lane
8c19364b65 api: Add TOML support for workspace POST
composer-cli pushes blueprints to the workspace using TOML not JSON.
This also adds a test.
2020-02-07 00:16:16 +01:00
Ondřej Budai
a43dd00459 move ComposeResult type into common package to allow its reusing 2020-02-05 01:35:50 +01:00
Jacob Kozol
b81dc53442 api: add custom image size for composes
When creating a compose the desired image size can be set. If the image
type is a VHD the image size is rounded up to the nearest MB since all
VHDs on Azure must have a virtual size aligned to 1 MB.
2020-01-23 00:57:31 +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
Ondřej Budai
8c6f5016b0 api: implement /compose/log 2019-12-20 11:43:39 +01:00
Ondřej Budai
665a7d81a8 api: return actual logs in /compose/logs
Commit b1c5ef2a introduced support for retrieving logs from osbuild.
This commit finishes the second part - actually returning the logs
from /compose/logs route.
2019-12-20 11:43:39 +01:00
Lars Karlitski
839a109c78 weldr: ensure a fresh dnf cache when making a new compose
dnf-json relies on dnf's ability to cache repository metadata. This is
important, because the API calls it quite often to serve requests for
package lists and depsolves.

However, osbuild's dnf stage always fetches new metadata, because it
doesn't have access to the host's cache. Since metadata is valid for
some time, even after a repository changed, the checksum we put in
the pipeline might be old.

Force a new metadata download when producing the pipeline. This is still
not perfect, but greatly reduces the probability of putting stale
metadata into the pipeline.
2019-12-19 21:46:02 +01:00
Tom Gundersen
506b012f08 distro: take architecture as an argument
Allow bootloader specific packages to be defined per architecture,
and allow repositories to depend on the architecture.

This does not altert he pipelines we produce, part from the ami
image now contains the grub2-pc package, rather than the grub2
package. This should make no difference.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-12-14 17:23:31 +01:00
Lars Karlitski
57aea4160d weldr: return version as string from api/status
This is what lorax-composer does and composer-cli expects.
2019-12-13 00:14:40 +01:00
Lars Karlitski
d9ad5d7062 weldr: add toml output to projects/source/info 2019-12-11 18:53:10 +00:00
Lars Karlitski
72e1da47ab weldr: make projects/source/new accept text/x-toml
composer-cli sends sources as toml if the original format is toml.
2019-12-11 18:53:10 +00:00
Tom Gundersen
d33fc5f010 composer: add provisional multi-arch support
The pipeline generation now takes the architecture as an argument.
Currently only x86_64 is supported. The architecture is detected
at start-up, and passed down to each pipeline translation.

For osbuild-pipeline we now requrie the architecture to be passed
in.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-12-11 15:23:24 +01:00
Lars Karlitski
0718766fbc weldr: fix reply on compose/info route
composer-cli requires `dependencies.packages` to exist. We can still
leave it empty for now, because it doesn't look at the contents.
2019-12-10 20:21:47 +00:00
Lars Karlitski
d3a0b788a2 distro: set the repository checksum dynamically
Instead of having a static repository checksum, set it dynamically from
the metadata that osbuild-composer last saw. This is implemented in
dnf-json, which returns the checksums for each repository on every call.

This enables the use of repositories that change over time, such as
fedora-updates. Note that the osbuild pipeline will break when such a
repository changes. This is intentional: pipelines have to be
reproducible.
2019-12-10 20:38:22 +01:00
Ondřej Budai
6bbc89d5f3 api: implement /compose/delete route 2019-12-10 01:14:36 +01:00
Ondřej Budai
4e62f181fa api: implement /compose/logs route
The implementation is just a stub returning always the same tar archive.
The ability to return actual logs will be implemented in the future - osbuild
isn't currently returning any logs.
2019-12-08 00:21:30 +01:00
Ondřej Budai
d7f81b36e6 api: implement /compose/info route
Not everything is implemented in this route but enough to pass the tests.
2019-12-06 10:42:19 +01:00
Ondřej Budai
ad7650384e api: use committed blueprint in POST /compose
lorax-composer apparently doesn't use blueprint from workspace to create a new
compose. This commit implements the same behaviour.
2019-12-05 13:08:50 +01:00
Ondřej Budai
24faab8c18 store: clean up blueprint API
Prior to this commit blueprint getters looked like C-style API with output
parameters. This commit refactors them to more conventional multiple return
values API.
2019-12-05 13:08:50 +01:00
Ondřej Budai
f89a9671be store: add image struct into compose struct
As a part of f4991cb1 ComposeEntry struct was removed from store package.
This change made sense because this struct is connected more with API than
with store - store uses its own Compose struct. In addition, converters
between Compose and ComposeEntry were added. Unfortunately, ComposeEntry
contains ImageSize which was not stored in Compose but retrieved from store
using GetImage method. This made those converters dependent on the store,
which was messy.

To solve this issue this commit adds image struct into Compose struct.
The content of image struct is generated on the worker side - when the worker
sets the compose status to FINISHED, it also sends Image struct with detailed
information about the result.
2019-12-05 09:48:21 +01:00
Lars Karlitski
b2880cacc6 weldr: don't indent toml output
Be consistent with lorax-composer.

The integration tests do a string compare on received toml files.
2019-12-04 19:15:33 +01:00
Ondřej Budai
b6307cafd5 api: fix compose routes returning null instead of empty array
Cockpit-composer really doesn't like that
2019-12-03 11:49:35 +01:00
Ondřej Budai
dca7ab2847 api: handle blueprint depsolve error 2019-12-03 11:49:27 +01:00
Lars Karlitski
20bb60f3fd weldr: add support for toml blueprints 2019-12-03 01:27:00 +01:00
Ondřej Budai
f4991cb1ca api: Add support for upload API
This commit introduces basic support for upload API. Currently, all the routes
required by cockpit-composer are supported (except for /compose/log).

Also, ComposeEntry struct is moved outside of the store package. I decided
to do it because it isn't connected in any way to store, it's more connected
to API. Due to this move there's currently a known bug that image size is
not returned. This should be solved by moving Image struct inside Compose
struct by follow-up PR.
2019-12-01 00:05:17 +01:00
Ondřej Budai
7fbe8453ef api: support wildcard /compose/status 2019-12-01 00:05:17 +01:00
Lars Karlitski
85e6182bdc distro: don't fall back to fedora-30
Make osbuild-composer use FromHost() directly. Everywhere else needs to
specify the distro explicitly.

Also don't panic when a distro doesn't exist. Instead, return nil. Make
sure all callers check for that.
2019-11-29 00:46:05 +01:00
Lars Karlitski
14ebed46da distro: register distros explicitly
Automatically registering on `init()` is clever, but a bit too magical
and easy to get wrong, because every binary must include all distros
somewhere.

Flip this inside out: distros now have a `New()`, which returns
something that implements the `Distro` interface. The distro package
explicitly creates all of them.

This means that distros cannot import distro itself anymore, because go
forbids import cycles. This only affected `InvalidOutputFormatError`.
Return a generic error for now.
2019-11-29 00:46:05 +01:00
Ondřej Budai
e73b43162d api: add basic support for v1 api
lorax-composer recently introduced API version 1. This commit introduces
very basic support for it. This implementation tries to deduplicate code
for routes with the same behaviour as much as possible. All the differences of
v1 API are marked as TODOs for now and will be implemented in follow-ups PRs.
2019-11-22 14:36:05 +01:00
Lars Karlitski
b911d0b928 weldr: get repositories from distro
Make distros export repository information and use those in the weldr
API. This means that repos are only specified once and that the API
returns the right packages when we allow different distros.
2019-11-18 12:22:10 +01:00
Lars Karlitski
1dac0a03d2 weldr/sourceInfo: move '*' out of the loop
The API returns all sources on the route `sources/info/*`, but shouldn't
when one of the sources in the comma-separated list is a `*`.
2019-11-18 12:22:10 +01:00
Lars Karlitski
d1a6e2efb7 weldr: clean up source/info route
Split the error case (no sources specified) into its own function, so
that we can use `source/info/:sources` (note the colon) to get the list
of sources without the leading `/`. This gets rid of two special cases
which made the previous implementation hard to parse.
2019-11-18 12:22:10 +01:00
Lars Karlitski
d06a39bd51 weldr: move RepoConfig → SourceConfig conversion to store
This puts it aside the already existing SourceConfig → RepoConfig
conversion and makes `sourceInfoHandler` a bit easier to parse.
2019-11-18 12:22:10 +01:00
Lars Karlitski
919d849123 weldr: use repo ids as source names
The naming is confusing: repositories have an `id` and a human readable
`name`. Weldr's sources also have a field called `name`, but
lorax-composer uses that as a way to identify repositories by their id.

Use `id` consistently here as well.
2019-11-18 12:22:10 +01:00
Lars Karlitski
740e4da733 rpmmd: move SourceToRepo to store
This removes the `store` dependency from `rpmmd`, which is the more
generic package.

It's also nicer to have this on a method of `SourceConfig`.
2019-11-18 12:22:10 +01:00
Jacob Kozol
c4088caee1 api: add blueprint freeze route
The blueprint freeze route returns the blueprint info but each
package will be the package selected by depsolving. So, instead of the
version being the version number with optional wildcards as
/blueprints/info would provide, the version is of the form
`Version-Release.Arch`.
2019-11-15 00:25:18 +01:00
Ondřej Budai
dd9a815c40 api: improve parity of /{modules,projects}/{list,info} routes
These endpoint are similar in many ways, therefore just one commit. Their
functionality is basically same as in lorax except for error messages and
weird edge cases when handling trailing slashes.

closes #64, closes #65
2019-11-15 00:23:24 +01:00
Ondřej Budai
2ed070b218 api: remove packages from api struct
This was probably forgotten in c882bebf
2019-11-15 00:23:24 +01:00
Jacob Kozol
5ffcb3fe6d api: add undo blueprint route
Add a route to set a blueprint back to its state at a particular change.
The route `blueprints/undo/:blueprint/:commit` requires the blueprint
name and the commit hash for the change that the blueprint should be
reverted too. Also, the commit message for the change created when a
blueprint is pushed is now passed from the api to the store's
PushBlueprint funtion.
2019-11-14 20:36:17 +01:00
Jacob Kozol
c882bebfb4 remove packages from weldr API initialization
The package list is generated on each request for a package so there is
no longer a need to generate the package list in main or to store these
packages in the API object.
2019-11-14 12:16:07 +01:00
Jacob Kozol
6f4a7bacd2 api: fetch packages from sources and base repo
The package list is now generated from the base repo and the
user-defined repos. This allows users to add packages not found in the
base repo to their blueprints.
2019-11-14 12:16:07 +01:00