Commit graph

381 commits

Author SHA1 Message Date
Tomáš Hozza
a90101bde9 builder: fix missing default value for details in ComposeStatusError
The builder plugin could produce a traceback when image build failed,
but it didn't contain any details.

```
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/koji/daemon.py", line 1468, in runTask
    response = (handler.run(),)
  File "/usr/lib/python3.6/site-packages/koji/tasks.py", line 335, in run
    return koji.util.call_with_argcheck(self.handler, self.params, self.opts)
  File "/usr/lib/python3.6/site-packages/koji/util.py", line 271, in call_with_argcheck
    return func(*args, **kwargs)
  File "/usr/lib/koji-builder-plugins/osbuild.py", line 719, in handler
    status = client.wait_for_compose(cid, callback=self.on_status_update)
  File "/usr/lib/koji-builder-plugins/osbuild.py", line 483, in wait_for_compose
    status = self.compose_status(compose_id)
  File "/usr/lib/koji-builder-plugins/osbuild.py", line 454, in compose_status
    return ComposeStatus.from_dict(res.json())
  File "/usr/lib/koji-builder-plugins/osbuild.py", line 251, in from_dict
    ImageStatus.from_dict(s) for s in data["image_statuses"]
  File "/usr/lib/koji-builder-plugins/osbuild.py", line 251, in <listcomp>
    ImageStatus.from_dict(s) for s in data["image_statuses"]
  File "/usr/lib/koji-builder-plugins/osbuild.py", line 228, in from_dict
    error = ComposeStatusError(error_id=error_id, **error)
TypeError: __init__() missing 1 required positional argument: 'details'
```

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2022-11-21 12:06:35 +01:00
Simon Steinbeiss
292e8c9026 builder: Fix typo 2022-11-16 18:39:41 +01:00
Simon Steinbeiss
c4de854fc3 ci: Pin Fedora container for pylint
This is so that new pylint errors with the version in Fedora 37 can be
fixed in a separate, subsequent PR.
2022-11-16 18:39:41 +01:00
Simon Steinbeiss
9975f38990 hub: Log adding tasks to Koji's db
Log both the entrypoint and the return value from adding a task to
Koji's database. We can measure both to ensure a task has been
successfully added to the database as a service level indicator.
2022-11-16 18:39:41 +01:00
Simon Steinbeiss
fd42f9eaf2 builder: Explicitly log task id to track SLI
Each 'Task id' corresponds to a 'Compose id' in case everything works as
expected. In order to be able to track both in Splunk to measure our
first service level indicator (SLI) we need to explicitly log the 'Task
id' when it is received by the plugin.
2022-11-16 18:39:41 +01:00
Thomas Lavocat
741be470bb ci: add tags to AWS instances
The new terraform runners support an extended lists of tags to get a
greater precision on the stats we can extract from AWS cost center.
2022-11-10 18:39:30 +01:00
schutzbot
cc3e621754 Post release version bump
[skip ci]
2022-09-02 14:28:16 +00:00
Tomas Hozza
f21a2de39b Hub: support image_type being an array for backwards compatibility
The support for specifying multiple `image_types` for a single compose
has been removed by [1]. This turned out to be problematic, because e.g.
Pungi uses the array type when triggering image builds via osbuild.

Bring back the support for specifying the `image_type` as an array, but
restrict it to a single item. This will cover the Pungi use-case, since
it is always passing a single `image_type` in the array. The array is
then converted to a string in the Hub plugin and passed as such to the
Builder plugin.

Extend unit tests covering the introduced compatibility layer.

[1] c725265081
2022-09-02 15:15:21 +02:00
Tomas Hozza
6065ce8b72 packit: Enable Bodhi updates workflow 2022-09-01 18:47:45 +02:00
Tomas Hozza
afd0db50c2 containers: fix globing of RPMs with two-digit version
`?` matches only a single character, which does not work with the
version on `main` being "10".
2022-09-01 18:47:45 +02:00
schutzbot
bb421f845b Post release version bump
[skip ci]
2022-08-31 14:33:09 +00:00
Tomas Hozza
d1e064aec3 koji_test.py: test upload to cloud with AWS
Extend the integration test with a new case, testing that direct upload
to the cloud works for Koji composes. Test this using a single cloud
provider, specifically AWS.

The test case submits a new osbuild-image build using Koji CLI,
determines the image information once the build finishes and then checks
that such image exists in AWS. The image is then deleted as part of the
test case tear-down.

The AWS credentials are now configured in the worker's configuration, if
the appropriate environment variables are set.

Update the SPEC file with a new test dependency and update the required
osbuild-composer version.
2022-08-31 13:13:24 +02:00
Tomas Hozza
c76e97ddc9 Support specifying upload options for image builds
The upload options are expected to be provided as a JSON file. The same
options will be used for all image type and architecture combinations,
similarly as it is done for ostree options.

Extend unit tests to cover the newly added functionality.
2022-08-31 13:13:24 +02:00
Tomas Hozza
4e32ae5439 CI: exclude LICENSE from spell check
Spell check started to freak out on `complies` in the `LICENSE`. Exclude
`LICENSE` from spell check until it learns English.
2022-08-22 09:58:06 +02:00
Tomas Hozza
c725265081 Drop support for specifying more than one image type
While it is technically possible to build more than one image type
as part of a Koji compose in osbuild-composer, this option is not used
in reality and it also makes very little sense. If the user wants to
build more than one image type, they should submit multiple Koji builds.

Adjust affected unit tests.
2022-08-22 09:58:06 +02:00
Tomas Hozza
dd8233e8b7 Don't reduce infomation uploaded in compose-status.json
Previously, the image status in the compose status uploaded to the koji
build was represented as a single string describing the overall status.
All information related to the image upload or error details were
thrown away.

Refactor `ImageStatus` to contain all the information about the image,
its upload targets and potential errors, as they are returned by
composer.

This will improve the experience when debugging compose failures. In
addition, including all the data will be important once images
will be uploaded directly to the cloud, because it will contain
information to locate the image in the cloud environment.
2022-08-22 09:58:06 +02:00
Tomas Hozza
21a947d64f GH action: use Fedora container for Pylint 2022-08-22 09:58:06 +02:00
Tomas Hozza
ed6b01bb97 test_koji.sh: refactor the test case and de-duplicate some code
Refactor the test case implementation to make it easier to reuse
existing code when adding a new testing scenario.

The common pieces were moved under a new `SutInfo` class, which provides
information and convenience methods related to the system on which the
test is running.

This change will make it easier to later add a new scenario testing
upload to the cloud.
2022-08-22 09:58:06 +02:00
Tomas Hozza
0a026a6573 deploy.sh: drop Fedora 34 specific workaround 2022-08-22 09:58:06 +02:00
Tomas Hozza
85d7120d9f CI: Use Fedora 36, RHEL-8.6 and the latest osbuild and composer
Use latest osbuild and osbuild-composer releases. This is important to
be later able to test direct uploading to the cloud for Koji composes.
Also the mock openid server had to be enhanced to be usable for testing
`koji-osbuild`.

Modify used osbuild-worker configuration to use JWT for authentication
with composer. Update configurations of both, composer and worker to
handle multi-tenancy.

Do not start any services in `schutzbot/deploy.sh`, because at that
point, none of the configuration files are in place.

Ensure that the correct units are started and masked by
`test/integration.sh` to simulate the Service scenario more closely.
This means that the local worker is masked and only remote worker is
started.

Co-authored-by: Jakub Rusz <jrusz@redhat.com>
2022-08-22 09:58:06 +02:00
Tomas Hozza
faa40f1060 Schutzbot: add thozza's SSH key to team keys 2022-08-22 09:58:06 +02:00
Ondřej Budai
d38e11ea8a builder: add retries to composer API calls
The status calls are sometimes failing on:
upstream connect error or disconnect/reset before headers. reset reason:
connection termination

Since all requests are going through the company proxy, I think that the
networking isn't working 100% reliably. This commit adds a retry mechanism
provided by the urllib3 library. It will retry on all networking issues and
also on some 5xx errors that makes sense to retry (like gateway failures).

A test is added that runs the compose waiting code against a mock server
that fails every second request. This is imho sufficient to mimick a flaky
networking.
2022-08-05 14:53:37 +02:00
schutzbot
99062e8399 Post release version bump
[skip ci]
2022-06-30 16:45:09 +00:00
Ondřej Budai
a55f11211c builder: always refresh OAuth token after getting 401
See the comment inline
2022-06-30 18:38:23 +02:00
schutzbot
7baefacf2d Post release version bump
[skip ci]
2022-06-29 14:03:29 +00:00
Ondřej Budai
3930f277fc test: make run-builder.sh work with podman 4
RHEL is now shipping podman 4 that encodes the networks differently, let's
implement a small dirty hack to fix it on RHEL before
https://github.com/osbuild/koji-osbuild/pull/100 can land and fix it properly.
2022-06-29 16:00:36 +02:00
Jakub Rusz
12773dbe25 pylint: fix new errors 2022-06-29 16:00:36 +02:00
Ondřej Budai
7a70cfd42e builder: set OAuth token creation time before we fetch it
See the comment.
2022-06-29 16:00:36 +02:00
Simon Steinbeiss
ab147208e9 packit: Enable Koji build integration
Also drop the create_pr option, which was dropped by Packit.
2022-05-16 12:01:54 +02:00
Ondřej Budai
e2010fed21 spec: set the default release to 1
The release number in the RPMland canonically starts at 1, not at 0. I think
it technically doesn't cause any harm but let's stick to what all other packages
do.
2022-05-04 18:17:59 +02:00
schutzbot
7e27934532 Post release version bump
[skip ci]
2022-05-03 12:31:04 +00:00
Christian Kellner
591a55aad5 plugins: add support for customizations
The Cloud API supports passing in a variety of image customizations,
like e.g. extra packages or pre-defining users.

Add a new command line option to the client `--customizations` which
takes a path to a JSON file which contains the customziations; they
will be passed via the existing `opts` argument to the hub.

Add support for `customizations` to the `opts`/`options` arguments
to the hub plugin. No validation to the object is done. Instead we
rely in Composer for the validation of the content.

Add support for `customizations` the image `ComposeRequest` in the
builder plugin. All specified values are just passed through to
composer as-is.

Add tests for the respective plugins.
2022-05-03 12:28:05 +02:00
Ondřej Budai
d8c9332257 builder: add support for proxying requests to composer
We need koji-osbuild-builder to be able to connect to composer via a proxy
because koji builders in our internal deployment cannot reach
api.openshift.com directly. This commit adds a new option `proxy` to the
builder plugin config that controls whether a proxy is used to route all
requests to composer.
2022-05-02 12:55:22 +02:00
Ondřej Budai
dca6717568 test/builder: fix typo 2022-05-02 12:55:22 +02:00
Ondřej Budai
d50ce20bfe devcontainer: remove trailing comma from JSON
JSON doesn't support that.
2022-04-13 14:52:32 +02:00
Jakub Rusz
afe767a0ca workflows/trigger-gitlab: run Gitlab CI in new image-builder project
We have a new project in Gitlab
https://gitlab.com/redhat/services/products/image-builder/ci/koji-osbuild
and we want to run the CI there instead.
2022-04-13 10:27:45 +02:00
schutzbot
b6f9ad5f4d Post release version bump
[skip ci]
2022-03-28 17:23:53 +00:00
Ondřej Budai
069ecdc391 builder: rename gpg_key field to gpgkey for repos
We decided to do this late change to Cloud API in order to keep the field name
same for all the APIs:

https://github.com/osbuild/osbuild-composer/pull/2479

I strongly believe that gpgkeys are not used in any of the current koji-osbuild
deployments yet so this change should be safe.
2022-03-25 14:47:32 +01:00
Ondřej Budai
11b618b2c0 builder: fix type annotations
ireqs is a list of ImageRequest. Also use Optional where None is a valid value.
2022-03-25 11:11:32 +01:00
Simon Steinbeiss
4c791c3f19 Add GitHub Action to create upstream tag
This action can be triggered manually from the GitHub Actions tab.
2022-03-24 16:57:55 +01:00
Stephen Coady
ce0e79b115 docs: fix error in hacking.md
Signed-off-by: Stephen Coady <scoady@redhat.com>
2022-03-24 09:35:59 +01:00
dependabot[bot]
1389c20247 build(deps): bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-24 00:24:57 +01:00
Ondřej Budai
041e99cb53 spec: remove double dependency on podman-plugins
I introduced this in 0bcac397a3, we can just
podman-plugins anywhere so let's drop the unneeded conditional dependency.
2022-03-24 00:01:22 +01:00
Ondřej Budai
5575282ab3 spec: don't push tests into Fedora
koji-osbuild-tests is dependent on osbuild-composer-tests but this package
is not shipped into Fedora because it provides zero value to users.

Let's do the same for koji-osbuild. koji-osbuild-tests will be built only
in our upstream CI but not built in the official Koji.
2022-03-24 00:01:22 +01:00
Ondřej Budai
039fc6b618 test/builder: drop misleading quotes from config
configparser treats quotes literally:

client_id = "koji"

translates to the following python string:

'"koji"'

This doesn't matter in the test because the oauth mock from osbuild-composer
actually ignores the credentials and return the token in every case.

But if you want to take this config as an example, you will probably put the
credentials automatically inside the quotes which will not work because a real
oauth server will refuse the client ID surrounded by quotes.

Note that .conf works different than .toml:

TOML requires to have strings in quotes. Yeah, consistency. 🤷
2022-03-23 17:53:30 +01:00
Christian Kellner
9562deb983 builder: use correct secret when fetching token
Use the `self.secret` and not `self.id` for the secret. Doh. Mea culpa.
Fix the corresponding test as well, which also checked for the wrong
thing.

Reported-By: Ondřej Budai <ondrej@budai.cz>
2022-03-23 15:21:48 +01:00
Simon Steinbeiss
6f3c49139d packit: Push directly to dist-git 2022-02-16 12:39:25 +01:00
ochosi
b576875ac8 Post release version bump
[skip ci]
2022-02-15 23:38:15 +00:00
Simon Steinbeiss
560c7859d1 Pre-release version bump
This is necessary once so we can enable the upstream release bot workflow,
which consists of just pushing a tag and bumping the version number
directly after the release is done.
2022-02-15 23:29:56 +00:00
Christian Kellner
f559c18079 plugins: support for repo package sets
This adds support for specifing the package sets for repositories;
on the command line this can be done via `--repo-package-set` with
and argument of `;` separated package set names. This will result
in repo information being transported via dict instead of plain
strings. Thus the hub plugin's schema was modified accordingly.
Last but not least, the builder plugin now can decode these dicts
and setup the repos accordingly.
Test were added for plugins as well as the integration test changed
to use this new feature.
The first upstream commit that supports this feature is pinned.
2022-02-15 17:35:29 +01:00