Commit graph

4399 commits

Author SHA1 Message Date
Alexander Todorov
0d3ef8817a Update repositories in repo-*.json files 2022-06-21 10:40:58 +02:00
Alexander Todorov
b82895b52a Define 8.7 & 9.1 nightly repos in Schutzfile 2022-06-21 10:40:58 +02:00
Alexander Todorov
8c03162867 COMPOSER-1576: Switch to latest RHEL versions for testing 2022-06-21 10:40:58 +02:00
Achilleas Koutsou
e8d6dee9ac CI: run the new test script on gitlab
We only need one runner and it should use the internal network for
access to all repositories.

Set a rule so it doesn't run on 'main' (makes no sense).

Set git depth to 500:
We need a long history in order to find the merge-base between the PR
and 'main'.  It's unclear whether there's a straightforward way to find
the depth of the PR to limit the clone depth accurately.  500 should be
enough for any PR (I'd hate to see a PR that makes this statement
false).
2022-06-21 09:50:45 +02:00
Achilleas Koutsou
7076f9b8dc test: new script that detects changes in manifests in a PR
The script runs the gen-manifests command first on the PR head and then
on the merge-base with the PR's base branch (typically 'main') and
checks for any differences.  It creates a review comment on the PR on
GitHub if any changes are detected.

The message is posted as a simple COMMENT type review to inform the
author and reviewers that changes exist.

The script doesn't fail if there's a diff.  CI shouldn't fail if changes
are detected since they can be intentional.  The job fails if something
goes wrong with the script execution (manifest generation, comment
posting, etc).

The script exits immediately if not run from a PR.

The gen-manifests run is silenced with `> /dev/null`.  In the future,
this should be handled by flags to the command itself to control the
output format noisiness.

The gen-manifests command is run 50 workers.  Testing with 100 seemed to
make the execution stall, likely because of the resources on the worker.
We can experiment with this value more in the future.
2022-06-21 09:50:45 +02:00
Christian Kellner
c38fcb128c distro/rhel7: add support for azure images
Add support for building Azure images, including RHUI based ones for
the private market place.
2022-06-21 00:06:26 +02:00
Christian Kellner
06e05df620 distro: add support for building a rhel 7 (qcow2)
Based on the RHEL 8.6 pipelines, needs a special buildroot with two
extra packages: python3-iniparse and python3-PyYAML.
Only x86_64 support for now.
2022-06-21 00:06:26 +02:00
Christian Kellner
13ce6140b9 distro: add YumConfig to ImageConfig
Not adding the actual option to any existing pipelines, since this is
only going to be relevant for rhel7.
2022-06-21 00:06:26 +02:00
Christian Kellner
42038ad47b osbuild2: support for the new vpc options in the qemu stage
Recently osbuild exposed the low level qemu options for the VPC
format. Add support for the `force_size` option.
2022-06-21 00:06:26 +02:00
Christian Kellner
5082c36ca5 osbuild2: add new Grub2LegacyStage for org.osbuild.grub2.legacy
Expose osbuild's `org.osbuild.grub2.legacy` stage.
2022-06-21 00:06:26 +02:00
Christian Kellner
75d7bbaaa3 osbuild2: optionally use sgdisk for partitioning
Add a new option to `GenImagePrepareStages`, which is used by all
modern pipelines for partitioning, to optionally use the `sgdisk`
partitioning tool via `org.osbuild.sgdisk`.
2022-06-21 00:06:26 +02:00
Christian Kellner
4b4e8ca810 osbuild2: add new SgdiskStage for org.osbuild.sgdisk
New partitioning stage that uses `sgdisk(8)` via `org.osbuild.sgdisk`.
2022-06-21 00:06:26 +02:00
Christian Kellner
074973e03d osbuild2: rename Partition to SfdiskPartition
Properly namespace the partition stage options for the Sfdisk stage.
2022-06-21 00:06:26 +02:00
Christian Kellner
4d9215ffb0 osbuild-pipeline: add support package sets in repo definitions
THe `rpmmd.RepoConfig` configuration supports setting "package sets"
for each repository, which allows the associate the individual repos
to specific package sets. Add a new `package_set` option to the
repo configuration of the compose request so that this feature can
be used.
2022-06-21 00:06:26 +02:00
zwtop
5c79d4e98c docker-compose: fix osbuild-worker unable load libcrypt.so.1
Signed-off-by: zwtop <wang.zhan@smartx.com>
2022-06-18 11:39:10 +01:00
Tomas Hozza
bdf009f800 UploadJobArtifact(): return 400 if not accepting artifacts
The worker server API handler `UploadJobArtifact()` was previously
silently discarding artifacts uploaded by the worker, if the server was
configured to not accept artifacts.

Change the behavior to return HTTP error "Bad Request" (`400`) to the
worker, in case it tries to upload artifact to the server, but the
server is configured to not accept any artifacts.

Add a new unit test testing the new behavior and adjust existing unit
tests, which were relying on the artifact being previously silently
discarded.
2022-06-17 17:37:15 +02:00
Tomas Hozza
fd82174469 worker/osbuild: consolidate Koji target options values meaning
When the Koji target support was added to the osbuild job, based on the
osbuild-koji job, the meaning of target option values got messed up.

The side effect of the issue is that when Koji composes are
submitted via Cloud API the resulting image is currently always uploaded
back to the worker server.

`OsBuildKoji` job
-----------------
- `OSBuildKojiJob.ImageName` is set to the filename of the image as
  exported by osbuild.
- `OSBuildKojiJob.KojiFilename` is set to the desired filename which
  should be used when uploading the image to Koji.

`OsBuild` job + `KojiTargetOptions` before
------------------------------------------
- `OSBuildJob.ImageName` is set to the filename of the image as exported
  by osbuild. This is done only by the Cloud API code for Koji composes.
  Cloud API does not set this for regular composes and any other target.
  The variable is set in common case only by Weldr API code with the
  same meaning and it is used by the `OsBuild` job implementation as an
  indication that the image should be uploaded back to the worker server.
- `Target.ImageName` is not set at all. Other targets use it for the
  desired filename which should be used when uploading the image to the
  target environment.
- `KojiTargetOptions.Filename` is set to the desired filename which
  should be used when uploading the image to Koji. All other target
  types use `Filename` variable in their options for the filename of the
  image as exported by osbuild.

`OsBuild` job + `KojiTargetOptions` after
-----------------------------------------
- `OSBuildJob.ImageName` is still set to the filename of the image as
  exported by osbuild. This is kept for a backward compatibility of new
  composer with older workers.
- `Target.ImageName` is set to the desired filename which should be used
  when uploading the image to Koji.
- `KojiTargetOptions.Filename` is set to the filename of the image as
  exported by osbuild.

This change is backward incompatible, meaning that old worker won't be
able to handle Koji compose requests submitted via Cloud API using a new
composer and also a new worker won't be able to handle Koji compose
requests submitted by a new composer. This is intentional, because after
discussion with Ondrej Budai, the Cloud API Koji integration is
currently not used anywhere in production.
2022-06-17 17:37:15 +02:00
Achilleas Koutsou
1ae0a5f469 CI: run the new regression test (insecure-repo)
Run on 9.0 GA only.  Running it on more than one distro is unnecessary.
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
aace1c9224 test: add new regression test for insecure downlods
Creates a dummy package and a web server with TLS and a self-signed
certificate and builds an image from the repository with `check_ssl`
disabled.
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
d2808d4830 Schutzfile: pin osbuild version for insecure curl option 2022-06-15 20:13:47 +02:00
Achilleas Koutsou
45ba071724 osbuild2: set the Insecure option for curl sources
When creating the curl source item for a package, set the Insecure
option on the source to the value of the IgnoreSSL field for the
package.
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
2555910f77 distro: use GenSources in Manifest() creation methods
Use the new helper function to generate the "sources" section of the
manifest in all distros that use the v2 manifest format.
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
5fe3d1f6d1 osbuild2: add GenSources helper function
This collects all the sources for a pipeline creates the "sources"
section for an osbuild manifest.
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
c74bfe2aaf ostree: add new CommitSource type
Will be used by pipeline generators to specify the source URL for a
given commit in the manifest sources.
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
e340687ab5 rpmmd: add IgnoreSSL field to PackageSpec
After a depsolve, each package inherits the `IgnoreSSL` value from its
repository configuration.

This information is not yet used.  It will be used to expose this
information to osbuild's org.osbuild.curl stage.

The test data is updated to match the new behaviour:
The test repository config specifies `IgnoreSSL=true` and the packages
in the response inherit the value.
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
2f247847d6 rpmmd: add ignore_ssl to serialisable repo config
The internal repository configuration (RepoConfig) supports IgnoreSSL
which, when set to `true`, will run a depsolve job with the dnf repo
parameter `sslverify` set to `false`.

The serialisable repo object (repository) did not support reading this,
so it was impossible to set in global repo configs (from
/usr/share/osbuild-composer/repositories and
/etc/osbuild-composer/repositories).
It was, however, possible to set it through the weldr API when adding a
new source.
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
000344937c osbuild: add Inscure field to CurlSourceOptions
Makes curl skip the verification step for secure connections and proceed
without checking.
The default (empty) value is 'false'.

osbuild counterpart: c8073b5836
2022-06-15 20:13:47 +02:00
Achilleas Koutsou
cd2c8e4c45 osbuild: rename URLWithSecrets to CurlSourceOptions
New options were added to the object in osbuild.  CurlSourceOptions is a
more appropriate name since the object isn't only used for adding
secrets.
2022-06-15 20:13:47 +02:00
Sanne Raymaekers
fe918fd8a0 dnfjson: Move subscriptions to Solver with config
The BaseSolver is an object which gets constructed when the worker
starts, and the subscriptions attached to it expire after about 3
days. By refreshing the subscriptions each time a new Solver is created,
valid subscriptions are used.
2022-06-15 15:15:23 +02:00
schutzbot
53a231174b Post release version bump
[skip ci]
2022-06-15 08:29:51 +00:00
Tomas Hozza
15891e1e7f worker/osbuild: fix forgotten return when koji upload fails
The return statement was forgotten when the Koji target support was
added. As a result, a Job with a failed Koji upload would be reported
as successful, while at the same time having a `JobError` set.
2022-06-14 15:46:38 +02:00
Achilleas Koutsou
af94d28b52 dnfjson: test for repo name and URL in error message 2022-06-14 11:39:07 +02:00
Achilleas Koutsou
0c13277940 dnfjson: append name and URL a repository to error message
If dnf-json returns an error that is related to a repository, it uses
the ID to identify the repository that caused the error.  Since IDs
can't easily be mapped back to a configuration, appending the URL and
name (if any) to the error message makes it easier to identify which
repository failed.
Keeping the ID in the message is also useful for finding the cache
directory of the repository if needed.
2022-06-14 11:39:07 +02:00
Simon Steinbeiss
f7c735231d Adjust release schedule timer
Adjust the timer for our automated releases to trigger the workflow at
8 UTC. This corresponds to 10am in most of our team's timezone and to
  the reminder event in our team calendar.
2022-06-14 11:21:52 +02:00
Juan Abia
135d28bc9f remove cloud-cleaner in favour of scheduled cloud cleaner
from now on, we will run schedules cloud cleaner every ~1h, so there's
no need to run cloud cleaner.
2022-06-14 10:41:18 +02:00
Juan Abia
bdd7122f10 separate scheduled cloud cleaner to a separate repo
checkout this repo on our CI so changes can be made easier.
2022-06-14 10:41:18 +02:00
Achilleas Koutsou
460a85f245 osbuild1: remove UnmarshalJSON for Stage and StageOptions
OSBuild used to return the stage options as part of the result object
for v1 manifests.  We didn't use this information anywhere.  Currently
we convert v1 results to the v2 format while parsing the results of jobs
from old manifests (old distro definitions), but the StageOptions are
ignored and we only care about the StageMetadata.
2022-06-13 21:00:40 +01:00
Achilleas Koutsou
2a5aecb9f2 osbuild2: remove UnmarshalJSON for Stage and StageOptions
Initially added as a copy of the osbuild v1 parser.
OSBuild used to return the stage options as part of the result object,
but this is no longer the case in v2.
More importantly, it doesn't seem like we used this information
anywhere, so it's useless.
2022-06-13 21:00:40 +01:00
Ondřej Budai
caadee87ec azure: add an option to tag page blobs
We want to start tagging page blobs so this commit adds a small tagging method
to our azure library and exposes it in the osbuild-upload-azure helper.

Example:

go run ./cmd/osbuild-upload-azure/ \
  -container azure-container \
  -image ./sample.vhd \
  -storage-access-key KEY \
  -storage-account account \
  -tag key:value \
  -tag hello:world \
  -tag bird:toucan

This commit also has to downgrade the azblob library version to 0.13 so the
API for blob tags is the same as the one currently shipped to Fedora.
This is suboptimal but it should unblock us for now.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-06-13 21:06:01 +02:00
Ondřej Budai
f71ca8f0ca azure: move the .vhd extension logic to the callers
It always felt wrong that the method uploaded the blob under a different name
than the one specified in the blob metadata.

This commit moves the responsibility of specifying the right extension to
the callers. azure.EnsureVHDExtension helper was added to simplify this.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2022-06-13 21:06:01 +02:00
Chloe Kaubisch
9e6ade2eff cloudapi: standardize format of url strings
Small fix, add format: uri to base_url for the sake of consistency
across url strings.
2022-06-13 13:06:30 +02:00
Tomas Hozza
09f57b6c2f api.sh: fix requesting of JWT token
`osbuild-mock-openid-provider`'s `/token` endpoint expects URL-encoded
values in the POST request body. Use the same values as those that would
be used by the worker when refreshing a token.
2022-06-10 14:48:18 +01:00
Tomas Hozza
c035e78182 CI: keep testing Koji integration with kojiapi
The internal composer instance still uses kojiapi for Brew builds,
instead of the cloudapi. Keep testing Koji builds via both APIs for now
to ensure that everything works.
2022-06-10 14:48:18 +01:00
Tomas Hozza
4a94b46f33 cloudapi: handle multi-tenancy in all compose/<id> endpoints
Use the `EnsureJobChannel()` middleware in all `compose/<id>` endpoints.
Specifically in the:
 - status
 - metadata
 - manifests
 - logs

As a result, these endpoints now return `404` in case the server has JWT
enabled and the channel associated with the request does not match the
channel associated with the requested compose (job).

Extend the multi-tenancy unit test to ensure that these endpoints behave
as expected in case of match and mismatch between the request and
compose channels.
2022-06-10 14:48:18 +01:00
Tomas Hozza
fc7d090498 cloudapi: add EnsureJobChannel() middleware to verify job channel
Add `EnsureJobChannel()` middleware method, intended for `compose/<id>`
endpoints. Its purpose is to ensure that the tenant channel set in
the request `echo.Context` matches the tenant channel associated with
the compose. In case of mismatch, `404` is returned.

Add `JobChannel()` method to the worker server implementation for
requesting channel associated with the job.
2022-06-10 14:48:18 +01:00
Tomas Hozza
c5e1c15cca cloudapi: move ValidateRequest() to middleware.go
Consolidate middleware functions to a single file.
2022-06-10 14:48:18 +01:00
Tomas Hozza
6fa2aa7b4a cloudapi: add helper method to extract tenant channel from echo.Context
Extract the determination of tenant channel into a helper function.
This will simplify handler and middleware  methods, which won't have
to implement the same logic by themselves.

Fix the multi-tenancy unit test to pass the appropriate context when
querying compose statuses, because the server that is being use has JWT
enabled and expects the tenant to be set in it.
2022-06-10 14:48:18 +01:00
Tomas Hozza
947a083aae cloudapi: use OperationID constant instead of string literal 2022-06-10 14:48:18 +01:00
Tomas Hozza
db2ad7bc5f cloudapi: switch osbuild-koji -> osbuild for Koji build jobs
Switch to using `osbuild` job type with `koji` upload target for Koji
build jobs, instead of using `osbuild-koji` job type.

Modify unit tests accordingly.
2022-06-10 14:48:18 +01:00
Tomas Hozza
09534091a9 cloudapi: run all Koji compose unit tests
Previously, only a subset from all Koji Compose unit test cases were
run. Remove this limitation and run all defined unit tests, which were
copied from `kojiapi`.

In addition, fix unit tests and relevant cloudapi methods to make unit
tests pass.

Add `TestRouteWithReply()` to `test/helpers.go` to allow getting the
compose ID when submitting a new compose. This is needed to make some
unit tests deterministic.

Do not delete values from `fields` slice in `dropFields()` in
`test/helpers.go`. The behavior was previously not consistent.
If the top-level map contained the value, it was deleted from it, but
the nested maps also contained the value, it was not deleted. On the
other hand, if the top level map didn't contain the value, but nested
maps did contain it, the value was deleted from all nested maps.
2022-06-10 14:48:18 +01:00