Commit graph

101 commits

Author SHA1 Message Date
Ondřej Budai
ead3ae6cab Add spec file for building RPM package
The version is set to 0 as we haven't release the first version yet.
2019-10-25 14:21:04 +02:00
Tom Gundersen
18934d4249 tools/image-info: add support for naked partitions
In case there is no partition table, we assume the whole image is
one big partition and treat is as such.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 11:46:25 +02:00
Tom Gundersen
fd33ea1cc7 weldr/tests: add first version of a compose/queue test
This can serve as a starting point, but it shows there are a few
problems to solve: we need to verify json that depends on the setup,
in particular, the json the queue contains will contain UUID's that
are generated out of our control.

Moreover, the setup for this test only makes sense for internal test,
so I think we may want to change the logic for whether or not a test
sholud be supported to be run externally to be per test-function,
rather than per call to sendHTTP().

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 10:18:47 +02:00
Tom Gundersen
26995d7a1d weldr/tests: refactor tests
This does not change the behavior, but refactors according to these principles:
1) No two routes are tested in the same function (but it would be ok to split
   tests for one route over several funcions)
2) At most one testRoute() call is made per API object, and the state is
   completely set up and tore down between tets.

On top of this we should add more test cases to each of the tables, but
I'm leaving this to future PRs.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 10:18:47 +02:00
Tom Gundersen
8c3cd245d8 weldr/test: split out sendHTTP helper method
This simplifies the code a bit, and will be used in follow-up patches
to distinguish between setup calls and explicit tests.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 10:18:47 +02:00
Tom Gundersen
f055ba2e07 store: change semantics of queue states
A job is now in "WAITING" state exactly when it is in the channel,
once it is popped it enters "RUNNING" state. It is only possible
to update the state of a job that is in the running state.

This mean that updating to "RUNNING" is entirely optional, but in
the future we may want to use this as a watchdog logic, and require
the worker to update at regular intervals to avoid being restarted.

The job queue API is updated to require a POST followed by one
or several PATCH messages to the returned ID. If a patch is sent
to an ID before the POST it is as if the object does not exist
(regarldess of it being in the queue in WAITING state or not).

Once a job has been POSTed it can be PATCHed to update it zero or
more times with (still) RUNNING before exactly oncee with either
FINISHED or FAILED.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-25 10:18:47 +02:00
Ondřej Budai
967b0e8ce0 blueprint: add initial support for customizations
List of currently unsupported ones:
- [[repos.git]]
- [customizations.kernel]
- [[groups]]
- [[packages]] and [[modules]]

Some of customizations have unimplemented behaviour, see TODOs
2019-10-24 15:13:47 +02:00
Ondřej Budai
86c47bc1d6 pipeline/stages: Add support for various stages defined in osbuild 2019-10-24 15:13:47 +02:00
Martin Sehnoutka
ed2dd9829c Adjust Openstack output to the Lorax one 2019-10-24 15:12:21 +02:00
Jacob Kozol
72a54b9c0e tests: specify if each test runs against external API
Not all tests will be compatible with external APIs such as Lorax. When
calling testRoute each test now declares if it can run against an
external API or not. This change allows us to test against Lorax but
skip the cases that will be invalid when not run against
osbuild-composer's API.
2019-10-23 20:53:50 +02:00
Martin Sehnoutka
bf73ee019e Adjust VHD output to the Lorax one 2019-10-23 20:52:22 +02:00
Jacob Kozol
81d9fef76a api: update api error responses to equal lorax's
In order to maintain parity with lorax the api needs to reply with an
error message equivalent to that used by lorax. Error messages are now
returned inside an error object that contains an id, message, and
optional status code.

For some routes, there are errors when no url parameters are passed. The
httprouter was using named parameters of the form /:param which does not
match for empty parameters. Now, it has been updated to use the
catch-all parameters of the form /*param. This change allows the case of
no parameters. However, parameters will now include a "/" as
their first character. This needs to be removed from the string in the
route handler.

In order to provide the proper error message for
/modules/list/<modules>, searching for the modules needed to be updated.
The requested modules and known packages are iterated over and if there
is a match the module is added to the response. Also, the found module
is dropped from the list of requested modules. If this list is not empty
after searching all of the modules then an error is returned containing
the name of the non-existant module.
2019-10-23 01:08:03 +02:00
Martin Sehnoutka
4ef4112a12 Adjust AMI output to the Lorax one 2019-10-23 01:05:14 +02:00
Martin Sehnoutka
96d401b212 QCOW2 image generation and output test 2019-10-22 13:52:36 +02:00
Tom Gundersen
09ac84926e blueprint: add unit tests for ex4 output type
Also fix a bug where the RawFs assembler was not correctly unmarshaled.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-21 23:17:49 +02:00
Tom Gundersen
32be0d05cb blueprint: add unit tests to public methods
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-21 23:17:49 +02:00
Tom Gundersen
b63cda530e blueprint: document error type
Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-21 23:17:49 +02:00
Tom Gundersen
c51f1833f9 blueprint/output: add missing test files
These files were left out of 0272fb8815.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-21 23:17:49 +02:00
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
deb763c13b dnf-json: Remove custom dnf cache directory
When osbuild-composer is run as systemd service, we don't want to write
anything into working directory. Currently, we write dnf cache into it.
Instead, let's just use the default dnf cache directory.
2019-10-14 23:45:53 +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
Lars Karlitski
abd958f463 Add README and LICENSE files 2019-10-14 10:31:04 +02:00
Tom Gundersen
029dd0a81b build-sys: rework makefiles
Unify into one make file, with two targets:

build:
  This unconditionally builds the binaries that wolud be shipped in the package,
  this is marked as a phony target, and relies on the go compiler to know what
  is up-to-date and what needs to be rebuilt.

install:
  This installs binaries and config files into the file system and runs any
  scripts to set things up correctly, as if the rpm had been installed.

This drops the old `run` target, which could still be done from the commandline,
but we want to be able to rely on systemd features, so it is not something we
want to test or support.

To run osbuild-composer from a checkout one should now do:
```
$ make build
$ sudo make install
```

This has the same effect as installing the RPM would have, starting and stopping
the sokcets/services is still left to the user.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-11 17:40:31 +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
b0d9423b73 osbuild-pipeline: add tool to print pipelines to stdout
This tool outputs the pipeline associated with each output type. In
the future this should grow to take a blueprint as an input, and
also allow the arch/os/version/variant to be configured.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-08 21:03:45 +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
ad637b46f8 osbuild-composer: rename the state file state.json
It is no longer specific to the weldr API, so drop the weldr prefix.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2019-10-07 10:37:43 +02:00
Tom Gundersen
b6c63b6d59 store: don't initialize the store with an example
We probably want to ship in a pristine state, so let's leave this out
for now.

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