Commit graph

3643 commits

Author SHA1 Message Date
Ondřej Budai
e45578d3b0 packer: remove the ami_id variable
We want to build multiple images at once so they have to be defined elsewhere.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-11 09:06:43 +01:00
Ondřej Budai
5ecbfbad9e packer: rename composer.pkr.hcl to worker.pkr.hcl
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-11 09:06:43 +01:00
Achilleas Koutsou
e5675efc4a github: fix job names and IDs for the tests workflow
Flip the incorrect flip that happened in
e4baddfad1
2022-03-10 10:54:20 +01:00
Achilleas Koutsou
93c6336e24 reporegistry: remove unused ReposByArch() function
Since all calls to `ReposByArch()` have been replaced by
`ReposByArchName()`, remove the function and updates tests.
2022-03-09 23:22:06 +00:00
Achilleas Koutsou
baa2339de4 weldr: remove the (host) architecture member from the API struct
The `API.arch` member was (mostly) used to read the name of the
architecture.
The only non-name use was for the purposes of reading RPM repositories
from the configuration, in `reporegistry.ReposByArch()`, a thin wrapper
around `reporegistry.ReposByArchName()`.
Removing the `arch` member from the API and using the new `archName`
that is set up in the API constructor lets us control the arch name that
is set without relying on a valid `distro.Arch` object being available
(which would depend on having a valid `distro.Distro` object).

Replaced all calls to `ReposByArch()` with `ReposByArchName()` which
depends on the arch and distro name strings instead of a full
`distro.Arch`.
2022-03-09 23:22:06 +00:00
Achilleas Koutsou
f9eb98b14d weldr: allow running on unsupported distros
When the host distribution is not known or supported, instead of failing
with an error, print a warning to the log and initialise the API with
the architecture name and distro name.
This enables running the weldr API on unsupported distros for
cross-distro building.

Guards against a nil arch member when initialising the store.
2022-03-09 23:22:06 +00:00
Diaa Sami
3ab2725042 koji: Reduce excessive logging by retryablehttp
Use LeveledLogger
Fixes COMPOSER-1394
2022-03-09 23:18:25 +00:00
Juan Abia
4c5de045ff test: add test purpose
Most test scripts don't have any documentation regarding it's purpose,
although it can be guessed by the code. There's value in adding this
small comment.

[skip-ci]
2022-03-09 22:46:25 +01:00
Laura Barcziova
a51f52f041 Packit: build SRPMs in Copr
Add srpm_build_deps key to the Packit configuration to specify the needed dependencies for SRPM build
and indicate to build SRPM in Copr.
2022-03-09 22:25:54 +01:00
Jakub Rusz
67c5f91ea4 mockbuild: use public EPEL-9 2022-03-09 22:03:39 +01:00
Sanne Raymaekers
663f1dcbee cmd/osbuild-worker: Pass bucket config to job implementation 2022-03-09 13:28:48 +01:00
kingsleyzissou
0c762d4ca0 Post release version bump
[skip ci]
2022-03-09 10:10:24 +00:00
Gianluca Zuccarelli
761aab6cac cloudapi/v2: add error object to ImageStatus
Add an error object to the ComposeStatus.ImageStatus.
The error object contains a human-readable error reason
and optional details in the case of an error.
2022-03-09 08:49:37 +00:00
Sanne Raymaekers
63a0bbc1f2 cmd/osbuild-worker: Configure s3 bucket on the worker itself
Parameterize aws section of worker config. If credentials is empty,
the iam role will be used.
2022-03-08 21:58:11 +01:00
Tomas Hozza
3a2002f557 CI: temporarily disable Installer test on el9/c9s due to rhbz#2059565
Temporarily disable Installer test case in the CI on RHEL-9 and CentOS
Stream 9 until https://bugzilla.redhat.com/show_bug.cgi?id=2059565 is
resolved. This test case is now consistently failing due to the
mentioned bug and makes it impossible for the CI to pass cleanly.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
2022-03-08 13:53:16 +01:00
Jakub Rusz
05be7c4096 test/image-tests: temporarily skip azure_rhui image testing
This manifest is intended only for internal use and is currently failing
in nightly pipelines. This will be moved to a different test script in
the future, see COMPOSER-1397.
2022-03-08 13:19:34 +01:00
Ondřej Budai
2ea2e9be09 templates/composer: give access to Fedora org
We will be using both offline tokens (account_id) and service accounts
(rh-org-id) for now.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 13:06:35 +01:00
Achilleas Koutsou
f449cd45e8 github/workflows: check dnf-json with pylint
Use a fedora container for dnf dependency.
Add a pylintrc file to the project with 120 max line length and
docstrings ignored.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
e4baddfad1 github/workflows: fix job names for the tests workflow
lint and unit-tests were accidentally swapped.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
7267fec608 dnf-json: disable some pylint checks
invalid-name: script name is "unpythonic" since it contains a -, but
that's fine.
too-many-arguments: also fine.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
74d8a1a462 dnf-json: add __init__ for DnfJsonRequestHandler to define cache_dir
Add a small __init__ for our subclass to define our one custom
attribute.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
b34150be6e dnf-json: fix small type mismatch in null value assignment 2022-03-08 12:42:12 +01:00
Achilleas Koutsou
7346171bd2 dnf-json: staticify methods that don't need to be instance methods
These two methods don't rely on the object instance at all so they
should be static.
The _timestamp_to_rfc() method can be a one-liner.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
df935627c4 dnf-json: codestyle: whitespace and blank line fixes
Whitespace around operators and after commas.
No whitespace after opening and before closing brackets.
Two blank lines between top-level functions and classes.
One blank line between class methods.
Indentation fixes.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
447df031dd dnf-json: CacheState factory as classmethod
In this case it might be functionally equivalent, but it's generally
nicer to have factory methods as class methods.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
3268c1f28f dnf-json: shorten CacheState loading and saving method names
CacheState.load_cache_state_from_disk() is long and redundant.
CacheState.store_on_disk() is fine (and load_from_disk() would also be
fine) but in the absence of any other store/load sources, the
from_disk() part is also unnecessary.
CacheState.store() and CacheState.load() should be enough.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
43a90ed473 dnf-json: remove mutable default argument value
Mutable values should not be used as default function arguments.
2022-03-08 12:42:12 +01:00
Achilleas Koutsou
1b86423d67 dnf-json: import cleanup
Removed unused imports: pathlib, queue, and datetime
Reorganised imports into 3 sections:
1. stdlib modules
2. stdlib submodule
3. foreign modules

Each section is sorted alphabetically.
2022-03-08 12:42:12 +01:00
Ondřej Budai
37181eb995 templates/composer: add tenant_provider_fields
account_id is for https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token

rh-org-id is for https://identity.api.openshift.com/auth/realms/rhoas/protocol/openid-connect/token

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
d2d70c1e95 cloudapi: add multi-tenancy test
This commit adds a very in-depth test for multi-tenancy. It queues several
composes and then runs all jobs belonging to them while checking that
they are run by the correct tenant.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
ad5a135b56 internal/test: add small library for tests
Yeah, we have TestRoute. It has one issue though: It doesn't have support
for passing a custom context. One option is to extend the method with yet
argument but since it already has 9 (!!!), this seems like a huge mess.

Therefore, I decided to invent a new small library for writing API tests.
It uses structs heavily which means that adding features to it doesn't
mean changing 100 lines of code (like adding another arg to TestRoute does).

I hope that we can start using this library more in our tests as it was
designed to be very flexible and powerfule.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
ffbbd022e3 cloudapi/test: make newV2Server return also the queue
We will need this for the multi-tenancy test.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
bafb613a43 cloudapi/test: add option to enable JWT
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
4a9812be2e cloudapi/test: add option to specify depsolve channels to test server
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
2d16aeb467 tests: add an E2E test for multi-tenancy
See the comment. It's imho still very important to have this test
but its powers are limited.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
299264f178 test/koji: install podman-plugins everywhere
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
cfb756b9ba api/{cloud,worker}: used channel name based on JWT claims for new jobs
This commit implements multi-tenancy. A tenant is defined based on a value
from JWT claims. The key of this value must be specified in the configuration
file. This allows us to pick different values when using multiple SSOs.

Let me explain more in depth how this works:

Cloud API gets a new compose request. Firstly, it extracts a tenant name from
JWT claims. The considered claims are configured as an array in
cloud_api.jwt.tenant_provider_fields in composer's config file. The channel
name for all jobs belonging to this compose is created by `"org-" + tenant`.

Why is the channel prefixed by "org-"? To give us options in the future. I can
imagine the request having a channel override. This basically means that
multiple tenants can share a channel. A real use-case for this is multiple
Fedora projects sharing one pool of workers.

Why this commit adds a whole new cloud_api section to the config? Because the
current config is a mess and we should stop adding new stuff into the koji
section. As the Koji API is basically deprecated, we will need to remove it
soon nevertheless.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
33a310e4e1 osbuild-mock-openid-provider: use offline token as org id
This is quite a hack. Basically, the mock provider copies the offline token
into rh-org-id JWT claim. This allows us to test multi-tenancy.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
c1dc58eba4 worker: NewServer: move config parameters to a new Config struct
We will have more parameters soon so let's make this prettier sooner rather
than later.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
9feb7b59d6 clouadpi: NewServer: move awsBucket parameter to a new ServerConfig struct
We will have more parameters soon so let's make this prettier sooner rather
than later.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
2765d2d9a8 jobqueuetest: add a test for multiple channels
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
32080e6202 jobqueuetest: modify testArgs to test also channels
jobqueue.Job must return the channel specified in jobqueue.Enqueue during
the whole lifecycle of the given job.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
4c31b04a65 jobqueuetest: add channel arg to the pushTestJob helper
Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Ondřej Budai
7bfcee36f8 jobqueue: introduce the concept of channels
Channels are a concept similar to job types. Callers must specify a channel
name when queueing a new job. A list of channels is also specified when
dequeueing a job. The dequeued job's channel will always be from one of the
specified channel. Of course, the job types are also respected. The dequeued
job will also always be from one of the specified type.

Currently, all calls to jobqueue were changed so all queue operations use
an empty channel name and all dequeue operations use a list containing
an empty channel.

Thus, this is a non-functional change.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-03-08 12:07:00 +01:00
Jakub Rusz
ba4f49078a ci: skip CI for draft and WIP PRs
Let only the init stage run so that we have a link on PRs to the CI and
can trigger it manually if desired. PR template updated with this info.
Also use yaml anchors for rules to reduce duplication.
2022-03-08 11:53:09 +01:00
Jakub Rusz
ae07093404 tests/image-tests: filter out cases with ostree URL
These tests depend on external dependencies which are difficult to setup
during image-test like http ostree repository. See
https://github.com/osbuild/osbuild-composer/pull/2389#issuecomment-1060338127
for more details.
2022-03-08 09:23:05 +01:00
Xiaofeng Wang
e147e41879 test: Fix COMPOSE_URL issue and add set-env-variables.sh 2022-03-08 09:23:05 +01:00
Jakub Rusz
485fc68a98 tests/upgrade: add user choice for vdo devices check
This is a user choice that has to be picked before the upgrade or it
acts as an inhibitor.
2022-03-08 09:23:05 +01:00
Jakub Rusz
ec93130a30 schutzbot/prepare-rhel-internal: update repository gpgkey
SHA-1 key is no longer supported, update it with a new one from
redhat-release. Related rhbz#2058497
2022-03-08 09:23:05 +01:00
Sanne Raymaekers
55b78bbd36 templates/packer: Remove -u flag from creds mapping script
We test if specific variables are set, and -u interferes with that.
2022-03-07 17:11:54 +01:00