Commit graph

1037 commits

Author SHA1 Message Date
Major Hayden
b452a31eed Remove CacheDirectory for remote worker
Setting the cache directory to `/var/cache` causes problems on the
remote worker startup and it needs to be removed.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-26 15:46:29 -05:00
Major Hayden
0921643fa3 Add health check at /status
There are times where it would be good to monitor that osbuild-composer
is up and running. Add a very simple status check that always returns
200/OK. This can be expanded later to verify that other parts of
osbuild-composer are working properly.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-26 15:34:16 -05:00
Lars Karlitski
e503b0a4d4 worker: pass a temporary store to osbuild
When fdd753615 added `--output-directory` to the invocation of osbuild,
it also removed `--store`.

This was a mistake: osbuild's default store is `.osbuild`, which is not
what we want. Restore the old behavior of passing a temporary directory.
2020-05-26 22:16:52 +02:00
Lars Karlitski
b065d8c304 worker: handle error in defer
There's not much to do when removing the temporary directory fails.
Print a message so that people have the chance to notice.
2020-05-26 22:16:52 +02:00
Lars Karlitski
a1cf3984dc worker: introduce job artifact directory
The `jobs/:job_id/builds/:build_id/image` route was awkward: the
`:jobid` was actually weldr's compose id and `:build_id` was always `0`.

Change it to `jobs/:job_id/artifacts/:name`, where `:job_id` is now a
job id, and `:name` is the name of the artifact to upload. In the
future, it could support uploading more than one artifact.

This allows removing outputs from `store`, which is now back to being a
pure JSON-store. Take care that `weldr` returns (and deletes) images
from the new (or for backwards compatibility, the old) location.

The `org.osbuild.local` target continues to exist as a marker for the
worker to know whether it should upload artifacts.
2020-05-26 10:42:20 +02:00
Tom Gundersen
8f7a9b3439 weldr/compose: add support for ostree-specific options
Similarly to how some image types accept a size-argument, some image
types require  ostree-specific options. For now this is only used by
Fedora IoT on Fedora 32.

composer-cli nor cockpit-composer currently has the ability to pass in
these options, but the change is backwards compatible and existing image
types are unaffected. If the options are omitted for image types that
require them, sensible defaults are chosen.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-25 22:37:29 +02:00
Tom Gundersen
b0cfec767a distro/f32: add iot-commit image type
This produces a Fedora IoT commit tarball, based on
https://github.com/gicmo/ostree-osbuild-demo and the fedora 32 specific
configuration found at
https://pagure.io/fedora-iot/ostree/c/465c8a2c1d1c0cf4b762477af87fb1d82c8ee002?branch=master

The usbguard package is excluded due to some SELinux failure that
remains to be resolved.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-25 22:37:29 +02:00
Tom Gundersen
77ea9d67bf distro/f32: pass ImageOptions to assemblers
Prepare for assemblers needing more image-type specific options.

This is not a functional change.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-25 22:37:29 +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
Tom Gundersen
a544fa7eb6 osbuild: add rpm-ostree stage
This adds the wrapper object and a simple test for the rpm-ostree stage.

See the osbuild documentation for details.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-25 22:37:29 +02:00
Tom Gundersen
1c9cb20b77 osbuild: add ostree.commit assembler
This adds the wrapper object and a simple test for the ostree.commit
assembler.

See the osbuild documentation for details.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-25 22:37:29 +02:00
Tom Gundersen
fd7320aaa1 osbuild/fstab: add filesystem label support
Exactly one of the UUID or the label must be set. The helpers are kept
the same and only supports the UUID for now, but these should likely be
dropped in favor of open-coding the structs anyway.

We do not enforce that the UUID or label is set, but osbuild will.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-25 22:37:29 +02:00
Lars Karlitski
8e0dd790b7 weldr: messages → msgs in status route
composer-cli expects `msgs`, not `messages`, and throws an exception if
it doesn't exist:

    https://github.com/weldr/lorax/blob/master/src/composer/cli/status.py#L52

It is not used anywhere else, so this is a safe change.
2020-05-25 16:20:47 +02:00
Alexander Todorov
7c0d384fde tests: split compose sanity tests and add more. Refs #356, #615
`quiet` parameter for runComposerCLIPlainText is not actually used
anywhere so I've removed it
2020-05-25 12:13:26 +03:00
Alexander Todorov
8ab1712796 tests: update name of test func, Refs #356
composer-cli sources list is already covered in the existing test
2020-05-25 12:13:26 +03:00
Alexander Todorov
d8de74a7d1 tests: add runComposerCLIPlainText(). Refs #356
see this comment from @teg:
https://github.com/osbuild/osbuild-composer/issues/356#issuecomment-630766947

Most of the calls within these tests should be converted to
use the plain text version. However some functions need the
JSON b/c they parse it and return a response, e.g. startCompose(),
getComposeStatus().
2020-05-25 12:13:26 +03:00
Major Hayden
eca999be4a
Add sudo to dnf list command
Bringing over the fix from ansible-osbuild
2020-05-22 14:03:46 -05:00
Major Hayden
ac11ea00f0 Remove RPM builds in GitHub Workflows
We are now building RPMs via mock in Jenkins, so we don't need these RPM
build jobs in GitHub Workflows.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-22 07:44:44 -05:00
Tom Gundersen
cc231e0ed1 distro/rhel-8: merge all the RHEL-8 minor releases into one
As it turns out, the default expectation is not to distinguish between
these. We will now produce whatever is the most recent minor release by
default, and image tests will still be pinned at a given snapshot to be
reproducible.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-21 17:57:28 +02:00
Major Hayden
1e29ab291e CI: Add mock builds for RHEL 8.3
Now that mock building seems to be stable, let's start building RPMs for
RHEL 8.3 so we can onboard it for base/image testing soon.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-21 08:56:53 -05:00
Major Hayden
d92a742f28 Build in a mock chroot first
Build the RPMs in a mock using a simple script so that ansible-osbuild
can focus fully on deployment rather than compiling RPMs.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-20 23:11:16 +02:00
Brian C. Lane
3c312b9bbd github: Fix go test coverage report
The go test coverage report does not cover other packages unless you
list them with the -coverpkg= argument. This results in an incomplete
coverage report with oddly missing lines.

This commit lists all of the packages so that they will all be included
when running the tests and gathering the results.
2020-05-20 22:58:29 +02:00
Major Hayden
62f61d34c2 CI: Skip AWS test if bucket missing
The osbuild CI uses the osbuild-composer CI testing playbooks but
there's no need to run the EC2 import for osbuild's CI. Add a check in
the Ansible playbook to look for the AWS_BUCKET environment variable and
skip the EC2 import if the bucker variable is missing.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-20 14:01:00 -05:00
Major Hayden
63c59b2ca1 CI: Run EC2 tests for all instances
Now that EC2 image testing is working well for Fedora 32, enable it for
all of the distros. Also, make it less special and allow it to run with
the other image tests.

Remove the `ami-boot` test from the list of regular image test cases
since it will be thoroughly tested via an import into AWS.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-20 12:01:38 -05:00
Lars Karlitski
e4df938152 schutzbot: remove all timeouts except the global one
When we ran into these timeouts, they were always false negatives. It is
hard to find right values for them.

If someone does introduce a bug that hangs one of the tests, we still
have the global timeout.

Fixes #648
2020-05-20 07:21:13 -05:00
Lars Karlitski
b0daa82fad distribution: set permissions on api sockets
This fixes permission for the weldr sockets: allow users in group
`weldr` to access them, but nobody else. Also add this group to the
sysusers file.

Fixes #646
2020-05-20 01:55:26 +02:00
Major Hayden
1d16dc4d73 Remove AWS snapshot import timeout
Importing an image into an EBS snapshot can sometimes take a long time.
The customer experience for a timeout is not great.

Allow the import to continue running for as long as needed without
timing out. This allows a customer to monitor the process of their
import until it has a success or failure status.

Fixes osbuild/osbuild-composer#632.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-19 22:34:04 +02:00
Ondřej Budai
eadd9be306 store: remove the last traces of result.json
GetImageBuildResult() method is not called anywhere, so we can drop it. As
it was the only reader of result.json file, we can also drop all the code
which wrote to that file.
2020-05-19 22:20:20 +02:00
Ondřej Budai
8a25d045d9 tests: add a smoke test that logs exist
Our current tests cannot currently check if the logs can reach all the way
from the worker to the weldr API. This commit adds a simple check that
the /compose/log route returns at least something.

Also the logs are printed when the compose fails.
2020-05-19 22:20:20 +02:00
Ondřej Budai
d4c083ee9a api/weldr: fix the missing logs
The store-jobqueue split broke the retrieval of logs in weldr API. Weldr API
still retrieved the logs from store but they are now stored in the jobqueue.
This commit fixes that by taking advantage of the fact that getComposeStatus()
now returns the compose result from which the logs can be generated.
2020-05-19 22:20:20 +02:00
Ondřej Budai
e4d32f9e2f worker/server: drop the JobResult method
Let's speak why I merged JobResult and JobStatus together:

Both methods actually called jobqueue.JobStatus(), so performance-wise
there's no real difference and it feels to me that it makes the code simpler:
You don't have to decide which method to call, you just get all the data
about a job in one call. We could split those again when we see some perf
issues with retrieving logs on each status check but I don't think we should
optimize prematurely. Let's leave some work for the future us.
2020-05-19 22:20:20 +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
Ondřej Budai
3b6bc69c37 api/weldr: propagate the ComposeResult to ComposeStatus
When a job doesn't exist for a compose, just return an empty result.
In the future this will cause logs disappear from jobs created before the
store-jobqueue split but we decided we can live with that, they are still
in /var for those who really want them.
2020-05-19 22:20:20 +02:00
Ondřej Budai
78d5109c81 worker/server: add Result to ComposeStatus
Return also the OsbuildJobResult in ComposeStatus struct. This change will
allow us to remove the JobResult function, see the following commits.
2020-05-19 22:20:20 +02:00
Ondřej Budai
65c7b78d4e api/weldr: make composeToComposeEntry() take composeStatus
This makes all the calls to composeToComposeEntry() method slightly easier
to read.

Not a functional change.
2020-05-19 22:20:20 +02:00
Ondřej Budai
5806e3ea08 api/weldr: make getComposeStatus() return composeStatus struct
The reasoning is the same as in one of the previous commits. I think that
returning multiple values from one method can be confusing and potentially
error-prone. Also, this method will return ComposeResult soon too.

Also, I chose to create a new composeStatus struct instead of reusing
worker.JobStatus. I think that's a good thing in terms of consistency and
reducing the dependencies between packages.

Not a functional change.
2020-05-19 22:20:20 +02:00
Ondřej Budai
fffec5fc38 api/weldr: getComposeState() -> getComposeStatus()
State is just one of the returned values, this will make more sense when
composeStatus struct is introduced.

Not a functional change.
2020-05-19 22:20:20 +02:00
Ondřej Budai
fa5b775718 worker/server: make JobStatus() return JobStatus struct
Personally, I don't like methods returning too much values. I think it's
easy to assign the values in an incorrect order and thus interpreting them
in a wrong way. Also, the following commits will make JobStatus() return
also the JobResult, which would make the number of returned values even
higher.

Not a functional change.
2020-05-19 22:20:20 +02:00
Ondřej Budai
8b58d2c91a test: document the Azure setup process
The image tests are now able to upload images to Azure and boot them there.
However, the documentation on how to set up the required resources in Azure
was missing. This commit adds it.
2020-05-19 10:00:48 -05:00
Ondřej Budai
4ebf6ee85b upload/koji: add a simple test
This commit adds a test which uploads a random file to Koji and runs CGImport.
The result is checked using the koji cli client.
2020-05-19 13:54:53 +02:00
Ondřej Budai
a1c578c8d1 cmd/koji: add error handling to logout
otherwise, the linter complains
2020-05-19 13:54:53 +02:00
Ondřej Budai
87a7e90c98 upload/koji: return the CGImport result
Currently, only build id is returned, more will come when needed.
2020-05-19 13:54:53 +02:00
Ondřej Budai
e43eb4da7b upload/koji: make the hexdigest field consistent
We usually try to match the field name with its json/toml/xmlrpc tag. This
commit does exactly that.
2020-05-19 13:54:53 +02:00
Ondřej Budai
184cd24426 upload/koji: handle the unmarshalling error 2020-05-19 13:54:53 +02:00
Ondřej Budai
0c87a7f524 upload/koji: handle the xmlrpc error
This is the way to handle situations when the remote method errors.
2020-05-19 13:54:53 +02:00
Tom Gundersen
76515066a8 upload/koji: add helpers to upload to koji
This does not yet actually upload the image, and it only supports empty
images. You need to place a an empty file named <filename>, with a valid
extension (e.g., .qcow2) in /mnt/koji/work/<directory>/.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-19 13:54:53 +02:00
Ondřej Budai
c508582a63 ci/travis: remove ami test
Schutzbot now tests it, no need to do it twice.
2020-05-19 11:11:04 +02:00
Major Hayden
d4b7c1d0c7 CI: Test EC2 import and boot
Build an AWS AMI image, upload it to S3, import it into EC2, and boot
it.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-18 10:27:24 -05:00
Major Hayden
d1a0d04b92 Add three hour timeout to test pipelines
If a pipeline runs for three hours, stop the pipeline. This can happen
if a network connection breaks down or if jenkins loses control of one
of its agents due to infrastructure issues.

Signed-off-by: Major Hayden <major@redhat.com>
2020-05-18 08:51:44 -05:00
Tom Gundersen
a22cd78eb3 store/json: log on dropping composes on unmarshal
If an invalid compose is encountered, then we drop it. Make sure to log
if a logger object is provided.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-05-18 11:50:15 +02:00