Commit graph

135 commits

Author SHA1 Message Date
Sanne Raymaekers
edadbb3470 upload/azure: set hyperv generation
This is a required parameter in the new armcompute sdk.
2024-01-16 14:25:58 +01:00
Sanne Raymaekers
adc07299a8 upload/azure: set storage account minimum TLS version to 1.2 2024-01-16 14:25:58 +01:00
Sanne Raymaekers
828d82e871 upload/azure: user newer resourcemanager packages
The older azure sdk and autorest packages are deprecated.

Signed-off-by: Sanne Raymaekers <sanne.raymaekers@gmail.com>
2024-01-16 14:25:58 +01:00
Achilleas Koutsou
15dbb90eda upload/pulp: wait for tasks in UploadAndDistributeCommit
When uploading and distributing a commit, wait for any async tasks to
finish before returning.  There are two tasks that can block this
function:
- Creating a distribution: this only happens when a new repository is
  created.
- Import commit: this will always happen in this function.
2023-10-18 21:14:46 +02:00
Achilleas Koutsou
cfddd448c3 osbuild-worker: add pulp configuration
Add support for pulp client configuration in the worker config.
Add test values to worker config test.
2023-10-18 21:14:46 +02:00
Achilleas Koutsou
ab659c013c upload/pulp: helper function to upload and distribute
Helper function that performs the whole upload and distribute procedure.
Two more helper functions are added for retrieving the href for a
repository based on its name, and for retrieving the base URL for a
repository's distribution.
2023-10-18 21:14:46 +02:00
Achilleas Koutsou
22e4169649 upload/pulp: task state functions
Define the task state enum based on the available values defined in the
API.

Add a helper function that returns true if a task is running or waiting
and ignores errors.
2023-10-18 21:14:46 +02:00
Achilleas Koutsou
50367e6f14 upload/pulp: distribute ostree repo
Function for distributing an ostree repository, making it available for
consumption.
2023-10-18 21:14:46 +02:00
Achilleas Koutsou
57f1bb8bf4 upload/pulp: import commit into repository
Function for importing a commit artifact (that's already been uploaded)
into a given repository.  Note that the "repo" argument to the
NewOstreeImportAll() function refers to the name of the repository
directory inside the archive, which for the commits we produce in
osbuild is always "repo".
2023-10-18 21:14:46 +02:00
Achilleas Koutsou
4c002f3d54 upload/pulp: file upload method 2023-10-18 21:14:46 +02:00
Achilleas Koutsou
1365347382 upload/pulp: list and create repositories 2023-10-18 21:14:46 +02:00
Achilleas Koutsou
bc6c2fb6af upload: define new pulp uploader
Define a basic client struct to pull in the pulp-client library.
2023-10-18 21:14:46 +02:00
Tomáš Hozza
f6e0e99391 Worker/koji-finalize: include osbuild version in image metadata
Include the osbuild version used to build the image, in the image extra
metadata attached to the Koji build and image output.

Extend `koji.sh` to verify that the version is set and of the expected
value.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-09-27 12:39:28 +02:00
Tomáš Hozza
95169111de Worker/koji-finalize: include manifest metadata in the build metadata
Expose the extra metadata attached to each manifest output, also to the
build extra metadata under `osbuild_manifest` property. The value is a
map of all manifest metadata with keys being the filename of each
manifest.

This will expose the information about osbuild-composer and
osbuild/images versions used to produce the manifest in the Koji
buildinfo, including the Web UI.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-09-27 12:39:28 +02:00
Tomáš Hozza
c27cf0253d Worker/koji-finalize: include composer and deps version in manifest MD
Include the osbuild-composer and its dependencies versions in the extra
metadata associated with the Manifest output when importing it to Koji.

This will make it possible to pin-point the exact version combination
which was used to generate the osbuild manifest used to built the image
imported to Koji.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-09-27 12:39:28 +02:00
Tomáš Hozza
e63472ef44 Koji: expose osbuild artifact information in image metadata
Expose the osbuild information used to produce the image, in the image
extra metadata under the `osbuild_artifact` property.

This information will get included in the image / build extra metadata
and make it explicit how to reproduce the image build using osbuild and
the attached manifest.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-09-27 12:39:28 +02:00
Tomáš Hozza
4f51d44762 Worker/koji-finalize: add cloud target results to image/build metadata
Add any non-Koji upload target results attached to an OSBuild result, to
the image extra metadata. This will make it easy to locate any image
from Koji uploaded to cloud, in the target cloud environment.

The rationale behind including only non-Koji target results is that one
can find it only in Koji, so there is no added value in including the
Koji target results at all.

Extend the `koji.sh` to check the target results in image metadata when
testing Koji scenario with cloud upload.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-09-27 12:39:28 +02:00
Tomáš Hozza
e0ec3a2a1c Worker/koji-finalize: import osbuild manifest and log to Koji build
Import osbuild manifest and build log to the Koji build as outputs. Also
note the respective filenames in the image output extra metadata.

Note that the osbuild manifest is imported as a log file for now. Koji
has very limited set of output types defined and I still need to
determine the best way to use a custom output type in Koji instances (as
other content generators do).

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-09-27 12:39:28 +02:00
Tomáš Hozza
27f98ec313 Target/koji: mark optional fields in BuildOutput as omitempty
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-09-27 12:39:28 +02:00
Sanne Raymaekers
a632848c59 cmd/osbuild-worker: add default OCI configuration
Useful for hosted deployments, where target options are often empty or
incomplete.
2023-09-19 22:57:06 +02:00
Sanne Raymaekers
067366ed6a internal/target: add OCI object storage target
Uploads an OCI image to OCI object storage, and generates a
pre-authenticated request for the object, which can be used to import it
into custom images.
2023-09-19 22:57:06 +02:00
Ondřej Budai
23718dc707 upload/oci: fix a crash when the uploader returns an empty response
resp.IsResumable crashes if resp.MultipartUploadResponse == nil. This happens
for instance when authentication fails. Fix this by also checking the
MultipartUploadResponse field.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-09-01 13:23:25 +02:00
Sanne Raymaekers
b26458f1f1 oci/upload: create image capability schema
After creating the custom image, make sure the capabilities default to
paravirtualized.
2023-08-28 10:29:14 +02:00
Tomáš Hozza
4ac6a7a11d Koji: expose boot mode in image extra metadata
Also extend the Koji test case to verify that the boot mode information
is in the build extra metadata and that it contains valid value.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-08-08 15:53:07 +02:00
Tomáš Hozza
af1c373407 Koji: expose image output metadata in build extra metadata
Expose the extra metadata information for each image output stored in
`ImageExtraInfo` also in the build extra metadata. The extra metadata
for each image is nested under key corresponding to the image filename.

Extend the Koji test case to check information in the buildinfo output
and specifically check for all expected metadata in the build Extra
metadata field.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-08-08 15:53:07 +02:00
Tomáš Hozza
350762497f Koji: refactor and consolidate structures
The original Koji implementation expected that the output of a content
generator is only an image. While in reality, we will eventually upload
other types of files as outputs to Koji, such as logs and osbuild
manifest.

Rename Koji structures and their members to better map to the upstream
Koji documentation and their JSON representation. Add comments to
structures. Define type aliases and constants for string values which
are more like enums, than a free-form values.

These changes have no effect on the actual JSON representation of any of
the structures

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-08-08 15:53:07 +02:00
Ondřej Budai
cac9327b44 update to go 1.19
UBI and the oldest support Fedora (37) now all have go 1.19, so we are
cleared to switch.

gofmt now reformats comments in certain cases, so that explains the formatting
changes in this commit.
See https://go.dev/doc/go1.19#go-doc

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-07-21 19:18:00 +02:00
Achilleas Koutsou
0e4a9e586f split: replace internal packages with images library
Remove all the internal package that are now in the
github.com/osbuild/images package and vendor it.

A new function in internal/blueprint/ converts from an osbuild-composer
blueprint to an images blueprint.  This is necessary for keeping the
blueprint implementation in both packages.  In the future, the images
package will change the blueprint (and most likely rename it) and it
will only be part of the osbuild-composer internals and interface.  The
Convert() function will be responsible for converting the blueprint into
the new configuration object.
2023-07-10 21:11:19 +02:00
Sanne Raymaekers
8a8607cdf6 internal/vmware: add support for the GOVC_FOLDER option
When importing the ova it also creates a VM, and users don't always have
permission to register in the default folder.
2023-05-25 10:14:32 +02:00
Sanne Raymaekers
967306bc47 internal/upload: add import.ova support to vmware 2023-05-25 10:14:32 +02:00
Ondřej Budai
bd7f0741b2 upload/koji: always upload in the overwriting mode
We sometimes see the following error in the logs:
Fault(1000): upload path exists: /mnt/koji/work/osbuild-cg/osbuild-composer-koji-082e1c88/Fedora-IoT-38.raw.xz.

I think this happens when we retry the upload call of the first chunk due to
random network issues. The solution is to always upload in the overwriting
mode, which ignores the already existing file.
See https://pagure.io/koji/blob/175ecb5e8f3d45a1d244b227eb889321e5dd0a29/f/kojihub/kojihub.py#_15522

This is safe because:
1) We use UUIDs in the filename, which means that there should never be a real
   conflict.
2) The overwriting mode is actually the default mode in koji, see
   https://pagure.io/koji/blob/175ecb5e8f3d45a1d244b227eb889321e5dd0a29/f/koji/__init__.py#_3342

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-05-18 09:25:22 +02:00
Ondřej Budai
fdc4f54be8 upload/koji: add a retrying mechanism for CGImport
CGImport quite often fails with the following error:
Fault(1000): File size 735051776 for Fedora-IoT-38.raw.xz (expected 738785372)
doesn't match. Corrupted upload?

When I inspect the file manually, everything seems fine, though.
I believe that this because of NFS inconsistency when multiple DNS-balanced
kojihubs are used in the setup (which is what Fedora uses). The addded
loop implements a retrying mechanism for the CGImport call to try again
whenever we see this issue.

Note that this isn't caught by other HTTP retrying mechanism because a failed
XMLRPC call returns code 200.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-05-18 09:25:22 +02:00
Ondřej Budai
943ead790e upload/azure: skip uploading empty pages
The size of the page blob is defined on creation and the blob is
zero-initialized. Therefore, we can just skip all the pages that contain
only zeros. This should save a lot of bandwidth if used on sparse files as
e.g. operating system images. (:
2023-04-04 09:09:43 +02:00
Ondřej Budai
abe6ccfb50 upload/azure: migrate from azure-storage-blob-go to azure-sdk-for-go
https://github.com/Azure/azure-storage-blob-go/ is deprecated, the main SDK
should be now used instead. Let's migrate the code. There should be no
functional changes.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-04-04 09:09:43 +02:00
Ondřej Budai
9beddf626f upload/azure: remove the MD5 sum check
It doesn't actually make any sense. For Page Blobs, Azure doesn't compute any
hashes. The MD5 sum is basically just a property, which we set by one call and
get by the other call.

See
https://stackoverflow.com/questions/42229153/how-to-check-azure-storage-blob-file-uploaded-correctly/69319211#69319211

for more info.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-04-04 09:09:43 +02:00
Brian C. Lane
7a4bb863dd Update deprecated io/ioutil functions
ioutil has been deprecated since go 1.16, this fixes all of the
deprecated functions we are using:

ioutil.ReadFile -> os.ReadFile
ioutil.ReadAll -> io.ReadAll
ioutil.WriteFile -> os.WriteFile
ioutil.TempFile -> os.CreateTemp
ioutil.TempDir -> os.MkdirTemp

All of the above are a simple name change, the function arguments and
results are exactly the same as before.

ioutil.ReadDir -> os.ReadDir

now returns a os.DirEntry but the IsDir and Name functions work the
same. The difference is that the FileInfo must be retrieved with the
Info() function which can also return an error.

These were identified by running:
golangci-lint run --build-tags=integration ./...
2023-03-07 09:22:23 -08:00
Diaa Sami
19f9ab7f58 koji: log unsuccessful requests only once 2023-03-02 15:48:12 +01:00
Diaa Sami
20c6fad7c2 osbuild-worker/koji: Add logging for koji requests/responses 2023-02-08 11:40:34 +01:00
Tomáš Hozza
4df3b0ca03 internal/upload/azure: make location optional in various methods
Make the `location` argument optional (can be now empty "") in
`RegisterImage()` and `CreateStorageAccount()` methods.

If the provided `location` argument is an empty string, then the location
is determined from the provided Resource Group instead.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2022-10-27 19:33:43 +02:00
Tomáš Hozza
641f7a7d29 internal/upload/azure: add method for getting resource group location
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2022-10-27 19:33:43 +02:00
Brian C. Lane
561bbbbdf3 azure: storageErr is already azblob.StorageError type 2022-09-15 03:57:40 -07:00
Tomas Hozza
95e2e75851 worker/osbuild: stop handling VMDK stream-optimized conversion
A backward compatibility code handling the conversion of VMDK image to
stream-optimized sub-format has been kept in the implementation since
PR#2529 [1] merged on May 4th 2022. Since this change, no API
implementation is submitting jobs, which would hit this conversion code,
because VMDK images are already being produced in the desired
sub-format.

On-premise deployments are expected to use the same composer and worker
versions. There are no composer / worker instances in production, which
are not running the modified code.

Delete the backward compatibility code.

[1] https://github.com/osbuild/osbuild-composer/pull/2529
2022-07-01 18:55:01 +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
Diaa Sami
e773d4896b koji: fix excessive logging & monitoring
update koji init & finalize to use custom leveled logging
This is mainly affects logging, but it also changes functionality slightly
since init & finalize are now using the customCheckRetry, they are able
to retry the "TLS timeout" error.
2022-04-05 23:48:30 +02:00
Diaa Sami
7c4d74481a koji: fix excessive logging & monitoring
update koji upload to use custom leveled logging, this only affects
logging
since uploading uses a different connection to send the chunks, it is
done separately in this commit
2022-04-05 23:48:30 +02:00
Diaa Sami
ed5cd56c5a koji: promote relevant logs to Info for monitoring
Add support for promoting certain `Debug` log messages to `Info` so we
can monitor them while the logging level set to `Info`, having it set
to Debug is far too noisy.
2022-04-05 23:48:30 +02:00
Diaa Sami
e6475d0e0e koji: make function non-member
follow-up to PR-2397
2022-04-05 23:48:30 +02:00
Diaa Sami
68639b4bf9 koji: increment retry counter only when retrying 2022-03-26 09:33:36 +01:00
Diaa Sami
6b08b8ed63 koji: don't decrement retry counter on the first call
After examining the logic of retryablehttp library, the callback does not happen for the first HTTP call, so no need to decrement when counting.
2022-03-26 09:33:36 +01:00