Commit graph

56 commits

Author SHA1 Message Date
Ondřej Budai
3480fe3093 koji: use typeinfo in CGImport metadata instead of the legacy format
From Koji Content Generator Metadata[1]:

"maven, win, or image: Legacy build type names which appear at this level
instead of inside typeinfo."

=> see, it's legacy

"typeinfo: A map whose entries are the names of the build types used for
this build, which are free form maps containing type-specific information
for this build."

=> struct{} is used for typeinfo.image because the docs says it should contain
"a free form map", null apparently isn't an option.

[1]: https://docs.pagure.org/koji/content_generator_metadata/

As suggested by the Brew maintainers Tomáš Kopeček and Lubomír Sedlář.
2020-10-27 19:01:30 +00:00
Ondřej Budai
a2e84bc0ac koji: fix a typo in json tag
According to the content generator metadata documentation[1], the field should
be named components.

[1]: https://docs.pagure.org/koji/content_generator_metadata/
2020-10-21 11:40:01 +02:00
Ondřej Budai
a67baf5a4d upload/koji: use the new API of kolo/xmlrpc by default
Fedora 33 ships the new API so let's do the switch now.

But... this would break older Fedoras because they only have the old API,
right?

We have the following options:

1) Ship xmlrpc compat package to Fedora 33+. This would mean that we delay the API switch till F32 EOL. This would be the most elegant solution, yet it has two issues: a) We will surely not be able to deliver the compat package before F33 Final Freeze. b) It's an extra and annoying work.

2) Downstream patch. No.

3) Use build constraints and have two versions of our code for both different
   API.

I chose solution #3. It has an issue though:

%gobuild macro already passes -tags argument to go build. Therefore the
following line fails because it's not possible to use -tags more than once:

%gobuild -tags kolo_xmlrpc_oldapi ...

Therefore I had to come up with manual tinkering with the build constraints
in the spec file. This is pretty ugly but I like that:

1) Go code is actually clean, no weird magic is happening there.
2) We can still ship our software to Fedora/RHEL as we used to
   (no downstream patches)
3) All downstreams can use the upstream spec file directly.

Note that this doesn't affect RHEL in any way as it uses vendored libraries.
2020-10-14 16:44:26 +02:00
Ondřej Budai
d32345104c upload/koji: extract processXMLRPCResponse method
Fedora 33 ships kolo/xmlrpc with a different API. This commit extracts the
affected code so we can use build flags in the future allowing us to use
both API versions.
2020-10-14 16:44:26 +02:00
Tom Gundersen
555934e303 koji: move run-koji-containers.sh to tools
Also install it is part of he tests subpackage. This a helper-tool, not
golang code, so should not live in `internal`. We need access to this
from the integration tests, so install it onto the tests system.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-10-06 13:08:26 +02:00
Martin Sehnoutka
b06e6dd916 *.sh: apply automatically all suggestions from shellcheck
This commit was automatically generated using:
```
$ fd --exclude vendor sh | xargs shellcheck -f diff | git apply
```
2020-09-19 15:10:39 +02:00
Tom Gundersen
4f39a33d34 osbuild-composer-koji.socket: use standard https port
Rather than using the arbitrary port 8701, use the standard 443. The
worker API will remain on a separate port, and as long as the two APIs
are exposed by the same binary that will have to remain separate at
8700.

Move the test instance of koji on localhost from 443 to 4343, to avoid a
conflict.

In a follow-up we should also give this API a prefix, so the cloud API
can share the same port with it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-17 17:34:57 +02:00
Tom Gundersen
9666be2891 schutzbot: add koji integration tests
This sets up containers running koji and supporting infrastructure, and
calls the osbuild-composer-koji API to build and image and push it into
our testing instance.

koji-compose.py and various fixes by Christian Kellner.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
e52830f530 upload/koji: don't pass task_id to cg_init_build
Contrary to our assumption, we cannot initialize the build with the
link to the task. We can only update the link once the build has
completed.

This seems like a bug in koji, but we keep it like this for now.
2020-09-16 00:15:02 +01:00
Tom Gundersen
b6f06da1a7 upload/koji/uploadChunk: fix compilation errors
The API of kolo/xmlrpc changed after the commit that is shipped in
Fedora. Pin the vendored version to that and adjust the API usage.

This should make the RPM compile in both RHEL and Fedora.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
3457038688 upload/koji: support refunding reserved build ids
Add support for both cancelling and failing a build. This is tested, but
not hooked up, as we need some more architecture work before that makes
sense.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Tom Gundersen
f446613d4a upload/koji: use CGInitBuild and clarify metadata structs
Move to requiring CGInitBuild to be called before CGImport. In the
future we could make the former optional again, but for now we want to
allow the caller to have done CGInitBuild and for composer only to do
the CGImport using the passed in build_id and token.

Also rename and document some struct fields in the metadata struct to
make them more specific to our use-case and hopefully easier to read.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-09-16 00:15:02 +01:00
Ondřej Budai
05fd221bd4 upload/koji: add support for GSSAPI/Kerberos auth
Prior this commit we only had support for username/password authentication
in the koji integration. This wasn't particularly useful because this
auth type isn't used in any production instance.

This commit adds the support for GSSAPI/Kerberos authentication.
The implementation uses kerby library which is very lightweight wrapper
around C gssapi library.

Also, the koji unit test and the run-koji-container script were modified
so the GSSAPI auth is fully tested.
2020-08-27 17:29:57 +01:00
Ondřej Budai
ecc7340570 upload/koji: allow passing a custom transport to koji.Login
In the near future, we will need to communicate with Koji using HTTPS.
This will surely bring the need for ignoring bad certificates/providing
our own self-signed ones. Thus, this commit prepares the Koji integration
by adding a way to accept a custom http transport which can be used to
customize the TLS settings.
2020-08-27 17:29:57 +01:00
Ondřej Budai
bc02da786d upload/koji: ensure that Koji type instance is always logged-in
Previously, Koji instance could be both logged-in and not logged-in.
This change disallows it: Now, the Koji instance is created by calling
koji.Login, so it must be always logged-in. This change should lead to more
robust code.
2020-08-27 17:29:57 +01:00
Ondřej Budai
f77f570202 upload/koji: extract RoundTripper from Koji type
The RoundTripper bits are not dependant on the Koji type, this commit extracts
them, so the responsibilities are clearly separated.
2020-08-27 17:29:57 +01:00
Ondřej Budai
1a13f6936c upload/koji: reuse the transport used by xmlrpc when uploading a chunk
This way, the handling of session and callnum is done at one place instead of
two places.
2020-08-27 17:29:57 +01:00
Ondřej Budai
c9d7892ec0 upload/koji: reorganize run-koji-container script
run-koji-container has now two actions: start and stop:
- ./run-koji-container.sh start
- ./run-koji-container.sh stop

The start action starts all containers. When it exits, all containers are
started and running in the background. To stop and removethem, use the stop
action.

This change is needed so we're able to easily use this script also in the CI
environment.
2020-08-27 17:29:57 +01:00
Ondřej Budai
355f4da115 upload/koji: use v1 koji container
rc1 doesn't seem to exist anymore.
2020-08-27 17:29:57 +01:00
Ondřej Budai
a32ff633ba upload/koji: make koji runner work with docker
The setup should be container engine agnostic. This changes allows this script
to be run on systems which prefer docker over podman (e.g. Github Actions).
2020-08-27 17:29:57 +01:00
Alexander Todorov
963e46f50d Always use .vmdk suffix after streamOptimized conversion
b/c vCenter gets confused by the .stream suffix
2020-08-26 14:45:31 +02:00
Alexander Todorov
3292b5eb68 Do not unlink file while it is still open
- inside RunJob() there is a deferred function which will remove
  the entire temporary directory in which images are created, including
  the streamOptimized file

- inside testBootUsingVMware(), which wants to use this function,
  there is already a deferred function which removes the converted
  image
2020-08-26 14:45:31 +02:00
Alexander Todorov
e7aa9c10c2 Move openAsStreamOptimizedVmdk() into importable package
so it can be used later within tests
2020-08-26 14:45:31 +02:00
Ondřej Budai
8d1c187f3c upload/azure: delete the unused test
This test is not run anywhere because it was surpassed by image tests with
azure boot type which perform more than just uploading a randomly generated
file to Azure. Let's delete dead code.
2020-08-25 10:41:10 +02:00
Ondřej Budai
c711b9149e remove travis mentions in codebase
Travis is no longer used, let's ditch these.
2020-08-25 10:41:10 +02:00
Major Hayden
70c32ef7c5 awsupload: Add comments for Register()
Please the golang linter by adding a small comment for the Register
function.

Signed-off-by: Major Hayden <major@redhat.com>
2020-08-24 12:57:37 -05:00
Major Hayden
02306c978e awsupload: Better emoji for snapshot wait
The clock emoji isn't as well supported as the 🚚.

Signed-off-by: Major Hayden <major@redhat.com>
2020-08-24 12:57:37 -05:00
Major Hayden
6659ab58ad awsupload: Apply tags to imported snapshot
Applying a `Name` tag to the snapshot makes the name of the image appear
in the snapshot listing in EC2's console. It also makes it easier to
remove a snapshot after deregistering the AMI.

Signed-off-by: Major Hayden <major@redhat.com>
2020-08-24 12:57:37 -05:00
Major Hayden
fc7f6349eb awsupload: Add description to snapshots
Make it easier to tell which snapshot goes with each AMI by labeling
them with a description.

Signed-off-by: Major Hayden <major@redhat.com>
2020-08-24 12:57:37 -05:00
Major Hayden
38e4fe8781 Add more emojis to AWS upload logs
Now that we know emojis work properly with osbuild-composer and systemd,
let's add some more.

Signed-off-by: Major Hayden <major@redhat.com>
2020-06-05 19:56:57 +02:00
Tom Gundersen
27e2d17911 awsupload: fix printing of IDs
The AWS API always uses pointers to strings everywhere, rather than
plain strings. The log messages got this wrong and printed the pointers
rather than dereferencing them.

Don't require users to do a memory dump to get at the AMIs, but instead
print the actual strings. Also change to %s from %v to let the linter
warn us in the future. %s accepts only strings, whereas %v prints
whatever you throw at it.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-06-04 10:05:12 +02:00
Ondřej Budai
761be27f32 upload/aws: fail ImportSnapshot when the snapshot is deleted
When ImportSnapshot fails, it goes into the deleted state. However, the code
didn't consider this state as a failure. This commit fixes that.

Fixes #706
2020-06-03 21:55:46 +02:00
Major Hayden
1c9ded8e53 Add basic logging to AWS upload process
The AWS upload process takes time and has multiple steps that can fail
or take an extended time to run.

Add some basic logging to various parts of the AWS upload process to
assist with troubleshooting in CI and production.

Signed-off-by: Major Hayden <major@redhat.com>
2020-06-03 21:02:58 +02:00
Major Hayden
fb35868ea3 Let AWS figure out the image format during import
Specifying the image format in the `DiskContainers` part of the snapshot
import process sometimes causes AWS to fail the import due to formatting
issues. However, AWS seems to do a decent job at determining the image
format on its own without specifying the format explicitly.

Signed-off-by: Major Hayden <major@redhat.com>
2020-06-02 22:00:05 +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
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
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
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
Ondřej Budai
6513263a14 upload/azure: force .vhd extension
Azure cannot create an image from a storage blob without .vhd extension.
This commit ensures that image always has the right extension.
2020-04-29 18:15:13 +02:00
Ondřej Budai
1d52dfcc2b upload/azure: fix typos 2020-04-29 18:15:13 +02:00
Ondřej Budai
5415be465f upload/azure: remove an unneeded custom error type
The errorString was not exported and used anywhere else, this commit replaces
it with a standard method of creating simple errors.
2020-04-29 18:15:13 +02:00
Ondřej Budai
e52a35d84e upload/azure: add a context to errors
Debugging azure upload fails is currently pretty hard, this commit adds
a context to all errors Azure upload can emit.
2020-04-29 18:15:13 +02:00
Ondřej Budai
83a3a8d821 change the format of the ami image type to vhdx
Prior this commit the ami image type produced raw.xz images. This was bad for
two reasons:

- The upload was broken because AWS doesn't support tar.xz format
- XZ compression is terribly slow

This commit changes the format to vhdx, which is supported by AWS and also
quite quick. See https://github.com/osbuild/osbuild-composer/issues/257
why vhdx was chosen.

Fixes #257
2020-04-24 15:27:39 +02:00
Ondřej Budai
5e49b026ca tests: remove the old aws unit test
The old aws unit test is not very useful now, because there's the new
integration test which covers a lot more. Therefore, this commit
removes it.

Fixes #512
2020-04-19 21:54:43 +02:00
Ondřej Budai
b2048b9796 upload/aws: double the timeout for snapshot import
us-east-1 seems to very slow these days, some imports can take up to
15 minutes. This commit raises the number of attempts before we give up.
Previously, we did 40 attempts, each delayed by 15 seconds, making the total
timeout equal to 10 minutes. Now we do 80 attempts with the same delay,
making the total timeout 20 minutes.
2020-04-15 01:16:33 +02:00
Ondřej Budai
9a96908c1e upload/aws: delete the s3 object after the snapshot is imported
After the snapshot is imported to EC2, there's no point in having the s3
object anymore. If the s3 object is not deleted, the user will be charged
for it periodically, while the object doesn't provide any value.
2020-04-04 02:49:00 +02:00