Commit graph

3299 commits

Author SHA1 Message Date
Tom Gundersen
0272fb8815 blueprint/output: add unit tests
These all follow the same scheme as was introduced for the qcow2
output type.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-21 13:35:05 +02:00
Tom Gundersen
5a82c95c9a blueprint/qcow2: move wanted pipeline into sepratate file
This will allow us to run tests on the generated images from the
same files in the future.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-21 13:35:05 +02:00
Tom Gundersen
d302ac6d09 blueprint/output/qcow2: add unit tests
Use the autogenerated test framework from VSCode (with minor fixes to
make them compile).

As we do not yet support customizations in blueprint, all the tests are
trivial.

I was not entirely sure about the best way to encode the wanted pipeline
output. I currently represent it as a JSON string and unmarshal it into
the object to compare with.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-18 15:57:31 +02:00
Ondřej Budai
8644213bb7 Remove process termination in case of error from runDNF function
log.Fatalf not only writes into a log, but also exits the process.
Instead, we want the caller to handle the error.

Also, the logged message is imho wrong.
2019-10-14 23:43:04 +02:00
Ondřej Budai
44088d9a6b Redirect dnf-json stderr to osbuild-composer stderr
When something wrong happens, we want to know about it.
2019-10-14 23:43:04 +02:00
Jacob Kozol
d5830a4794 tests: delete blueprints after tests
At the end of each set of tests the blueprint created is deleted.
This tests the delete route as well as removing blueprints
created while testing external apis such as lorax.
2019-10-11 14:16:19 +02:00
Ondřej Budai
6e790bc62d osbuild-composer: Fix imports broken by new module name
We've merged some stuff with old module name used in imports. This
commit fixes it.
2019-10-09 08:06:07 +02:00
Ondřej Budai
15b82a15d2 osbuild-composer: Rename module to github.com/osbuild/osbuild-composer
This should be the best practice according to other popular go projects:
- https://github.com/prometheus/prometheus
- https://github.com/syncthing/syncthing
- https://github.com/drone/drone
- https://github.com/hashicorp/terraform

Also, this change fixes go get command (it currently fails due to bad package
name).
2019-10-08 21:44:57 +02:00
Tom Gundersen
22254637f8 blueprint: generate real f30 images for all the output types
This is still just a placeholder, and in particular the live CD support
is not right.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-08 21:03:45 +02:00
Tom Gundersen
4845826048 blueprint: add proper error handling for querying invalid output types
Otherwise an invalid output type would crash composer.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-08 21:03:45 +02:00
Tom Gundersen
976d59cfda pipeline: add rawfs assembler support
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-08 21:03:45 +02:00
Tom Gundersen
35055b3176 pipeline/assembler: complete the qcow2/qemu rename
This was an oversight.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-08 21:03:45 +02:00
Tom Gundersen
6a40d77ed3 pipeline/stages/dnf: repositories are no longer named
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-08 21:03:45 +02:00
Tom Gundersen
7e78b4051d jobqueue: add back tests for the API
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
94e1e6f42b store: add error types and rudimentary error handling
This will allow us to better distinguish between different error
conditions in the API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
2e4063c78b job: drop the job package
This was only used internally in the store package, so moved the
one type that was still used and remove the rest.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
68ade23fcc store: make state (de)serialization internal
This hides the state hanlding in the store package. As before, it
can be disabled by passing `nil` instead of the path to the state
file.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
9cb140795e store: add {Push,Pop}Compose methods and hide channel
Wrap the channel in Pop and Push methods, so it is not exposed to
the callers. PushCompose replaces the old AddCompose for consistency,
and PopCompose simply reads from the other end of the channel.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
3ff4f59fc7 store: pass the store to the jobqueue API
Drop the jobUpdates channel, and instead add an UpdateCompose method
to the store, which updates the status of a compose directly.

This allows us to report back errors directly, rather than having to
mirror the staet in the jobqueue API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
89fd2e6037 store: move creation to main.go
Let the weldr API take the store as an argument, rather than create it
itself. This will allow us to share the store with the jobqueue API in
follow-up patches.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
4fcb5d66fa store: make the Store a package of its own
This encapsulates all the state of osbuild, no longer just the state specific
to the weldr API. Make it a first class type, preparing for direct access from
both the weldr and jobqueue APIs.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
2e979c8b82 weldr/store: add getImage
This allows images to be downloaded for completed composes.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
0880014edf jobqueue: cleanup API a bit and unify the two job stores
Let the store in weldr be the only one that keeps state, and push
updates directly there. This fixes a bug where there was an ID mismatch.

Change the API to not let the caller pick the UUID, but provide it
in the response. Use the same UUID as is used to identify composes,
this makes it simpler to trace what is going on.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
7f82ef4043 weldr/store: correctly update compose status
The entries in the map are stored by value, we must write them back
after modifying them.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
02ec086e51 weldr/compose: add support for listing the contents of the queue
This either returns all elements in the queue, or only those matching
a list of UUIDs.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
b1688cda76 blueprint: add infrastructure for translating to blueprints
Each output type will have its own translator from a blueprint to
a pipeline.

In the future, we may also want to distinguish between different
base distributions and architectures, but for now we keep it
simple and hardcode to a given one.

Some placeholder output formats are added, these have not been
tested or reserached, but are included to show how the it will
all fit together.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-05 20:44:32 +02:00
Tom Gundersen
949d3464b5 weldr: split blueprint into its own package
This will contain all the translation logic from blueprints to pipelines,
which will constitute the main part of composer, so let's separate that
out from the API.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-05 20:44:32 +02:00
Jacob Kozol
cefea2d387 test: run api tests against lorax
osbuild-composer's tests can be run against lorax-composer's api in
order to ensure parity with lorax. This can be accomplished by passing
the environment variable LORAX=true into the tests. Otherwise, the
tests run as usual against osbuild-composer's api.
2019-10-04 22:17:44 +02:00
Tom Gundersen
859bc0ad2e pipeline: clean up and document
This finishes the initial version of the pipline package, adding
documentation, but still missing unittests.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-03 12:49:21 +02:00
Martin Sehnoutka
ed185b41ce Integration of osbuild composer with systemd
osbuild-composer now uses socket activation instead of hardcoded paths
in the code. osbuild-worker is an http client therefore it uses only
service unit. osbuild-worker must be started after the socket is
created. osbuild-composer service requires osbuild-worker to run, because without
it no jobs can be started.

osbuild-composer is executed as a regular user (newly created
_osbuild-composer user) as opposed to the worker which must run as root
in order to execute osbuild itself
2019-10-02 17:56:59 +02:00
Jacob Kozol
d23d57bc31 Update api and store for parity with lorax
Add parameters to the api responses that while not displayed by
cockpit-composer are used in props validation or blueprint updates.
2019-10-02 15:25:02 +02:00
Tom Gundersen
96f3cbf655 weldr/store/compose: store information exposed in the API
Use the exact same status strings as is used in the API,
making it clearer that they are the same (and avoiding any
translation). Remember the creation/start/finish timestamps.
And store the output type.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-29 14:51:22 +02:00
Tom Gundersen
6c49acbd51 pipeline: add locale stage
This was left out from 7625d26ff5.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-29 14:51:22 +02:00
Tom Gundersen
7625d26ff5 pipeline/target: implement as variant types
Go doesn't really do variants, so we must somehow emulate it. The
json objects we use are essentially tagged unions, with a `name`
field in reverse domain name notation identifying the type and a
type specific 'options' object.

In Go we represent this by having an BarOptions interface, which
implements a private method `isBarOptions()`, making sure that only
types in the same package are able to implement it. Each type FooBar
that should belong to the variant implements the interface, and a
constructor `NewFooBar(options *FooBarOptions) *Bar` that makes sure
the `name` field is set correctly.

This would be enough to represent our types and marshal them into
JSON, but unmarshalling would not work (json does not know about
our tags, so would not know what concrete types to demarshal to).
We therefore must also implement the Unmarshall interface for Bar,
to select the right types for the Options field.

We implement his logic for Target, Stage and Assembler. A handful
of concrete types are also implemented, matching what osbuild
supports.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-28 17:49:07 +02:00
Tom Gundersen
5df6874b94 target: add constructor
We only support local target for now, but this avoids having to
open code it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-27 15:54:13 +02:00
Tom Gundersen
f880581a14 weldr/store: keep the compose status up-to-date
This way it can be correctly exposed in the API. We listen on a channel
from the job-queue, where status updates are pushed when the worker is
running/finished (or, in the future, failed).

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-27 14:34:51 +02:00
Tom Gundersen
cad89c6650 weldr: keep composes in the store
This means they are serialised and restarted in case composer is
crashed/restarted. We also need this in the future to track their
state, and allow them to be listed in the UI.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-27 01:38:41 +02:00
Tom Gundersen
0dc30d7f1b weldr/compose: return the build-id when starting a compose
The return argument was ommitted. Also move to using the uuid package
wherever that makes sense.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-27 00:51:15 +02:00
Lars Karlitski
cfe89eaed5 Add simple osbuild-worker
It doesn't actually build anything yet, but talks to the queue API.
2019-09-26 23:58:03 +02:00
Tom Gundersen
0bdd3a5c89 job-queue: pass a well-formed job object to the worker
For now we will hardcode the org.osbuild.local target, so we might
as well fix this up front.

We do not yet support any target types, but for testing purposes we
claim to support 'tar', and we pass a noop tar pipeline to the worker.

This makes introspecting the job-queu api using curl a bit more
pleasant.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-26 23:48:19 +02:00
Tom Gundersen
3221112d35 composer/job-queue: add scaffolding for the job queue API
This is by no means done, and needs more tests, docs and bugfixes,
but push it early so we have a common base to work on.

Based on work by Martin Sehnoutka.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-26 19:53:06 +02:00
Lars Karlitski
fa7068b59b weldr: act as if we can produce a tar output
We can't yet, but this is useful for testing.
2019-09-26 19:53:06 +02:00
Lars Karlitski
6576fe45dc main: move http serving to weldr
Also make sure that /run/weldr exists.
2019-09-26 19:53:06 +02:00
Jacob Kozol
e24bfcf7d0 Add blueprint workspace diff
The list of changes between the committed blueprint and its workspace
are returned when a user requests the diff. Each change includes the
new(added) or the old(removed) package.
2019-09-26 19:52:28 +02:00
Jacob Kozol
e14c48ff61 Fix package name-version for wildcard version
If a package had version "*" and its name-version would be "name-*".
This would match all packages containing "name" in their name. Instead
the name-version is "name-*-*" so it matches any version of the package.
2019-09-26 13:13:03 +02:00
Martin Sehnoutka
0861b80c99 create jobs queue for scheduling new builds 2019-09-25 14:31:15 +02:00
Tom Gundersen
3533597dde weldr: add missing arguments to constructor calls
In the test we don't need to serialize the state, so pass nil to
the costructor.
2019-09-24 01:09:58 +02:00
Tom Gundersen
da887a43fb tree-wide: format the code
$ go fmt ./...

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-24 01:03:27 +02:00
Tom Gundersen
b60f580d92 tree-wide: use a standard project layout
Keep main.go files under cmd/ and internal libraries under internal/.
This will allow us to add more exutables under cmd/ (whereas only one
was possible when main.go was kept in the root).

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-09-24 00:03:53 +02:00