-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cloud API: Support selecting multiple upload targets and add Pulp OSTree uploads #3744
Cloud API: Support selecting multiple upload targets and add Pulp OSTree uploads #3744
Conversation
9abd73d
to
b21e73e
Compare
c8ad6ab
to
f85e067
Compare
#3636 has been merged. Rebased and marked as ready. |
Converted to draft to block this while I work on supporting multiple targets. |
f85e067
to
2d2c763
Compare
Sorry this took so long. Multiple upload targets added. This now supports what @croissanne suggested and also adds the default upload options with the default target for the image type if specified, so all the following examples are valid: Single explicit upload target: {
"architecture": "x86_64",
"image_type": "edge-commit",
"upload_targets": [
{
"type": "org.osbuild.aws.s3",
"upload_options": { ... }
}
]
}
{
"architecture": "x86_64",
"image_type": "edge-commit",
"upload_targets": [
{
"type": "org.osbuild.pulp.ostree",
"upload_options": { ... }
}
]
}
{
"architecture": "x86_64",
"image_type": "guest-image",
"upload_targets": [
{
"type": "org.osbuild.aws.s3",
"upload_options": { ... }
}
]
} Default only (will select the default for the image type): {
"architecture": "x86_64",
"image_type": "edge-commit",
"upload_options": { ... },
"upload_targets": []
}
{
"architecture": "x86_64",
"image_type": "guest-image",
"upload_options": { ... },
"upload_targets": []
} One explicit upload target + a default: {
"architecture": "x86_64",
"image_type": "edge-commit",
"upload_options": { ... },
"upload_targets": [
{
"type": "org.osbuild.pulp.ostree",
"upload_options": { ... }
}
]
}
{
"architecture": "x86_64",
"image_type": "guest-image",
"upload_options": { ... },
"upload_targets": [
{
"type": "org.osbuild.aws.s3",
"upload_options": { ... }
}
]
} Multiples of the same upload target are supported. |
We should add some tests for this. I'm thinking we can change some of the compose requests in the API tests to use the new |
2d2c763
to
4229856
Compare
Edge test failures are failures to fetch from the rpm repos for the osbuild-composer build. A glitch, I guess? |
4229856
to
19da7a6
Compare
The response for the compose status is ComposeStatus:
allOf:
- $ref: '#/components/schemas/ObjectReference'
- type: object
required:
- status
- image_status
properties:
status:
$ref: '#/components/schemas/ComposeStatusValue'
image_status:
$ref: '#/components/schemas/ImageStatus'
image_statuses:
type: array
items:
$ref: '#/components/schemas/ImageStatus'
koji_status:
$ref: '#/components/schemas/KojiStatus' which means we can use the ImageStatus:
required:
- status
properties:
status:
$ref: '#/components/schemas/ImageStatusValue'
upload_status:
$ref: '#/components/schemas/UploadStatus'
error:
$ref: '#/components/schemas/ComposeStatusError' but what should we do with the EDIT: Spoke with @croissanne and we decided instead to add |
4aa3d9b
to
19da7a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, the PR looks good! I have just one small nitpick...
19da7a6
to
859277e
Compare
Added support for multiple upload targets and the response now includes an array of The structure was discussed and agreed with @croissanne. |
e227c45
to
2694567
Compare
2694567
to
31667e5
Compare
Rebased to prevent OCI private key leaking. Apologies :( |
31667e5
to
101e05c
Compare
I think the RHEL 8.8 RPM builds are getting hungry and killed again:
From RHEL 8.8 aarch64 rpm build journal log: https://gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/-/jobs/5490961946 This time it's happening on all 8.8 builds, regardless of architecture. The last time we had this issue it was on all EL8 builds for aarch64. Weird. |
0d55230
to
ca76d14
Compare
Add an upload_targets field to the image request. This lets the API caller specify multiple upload targets and upload options to be used. If the upload target type does not match the upload options, the request is invalid. For backwards compatibility, the upload targets field is optional. If it is not specified, the default upload target and upload options for the image type are assumed, which is the same as the old behaviour. Adding an explicit selection to the request makes it possible to support multiple upload targets for the same image type. We plan to support ostree commits being uploaded to both aws.s3 and pulp. To report on the multiple upload requests, we add an upload_statuses field to the ImageStatus response.
To report on the multiple upload requests, we add an upload_statuses property to the ImageStatus response.
Separate the handling of each individual target type into its own function called by GetTarget()'s case switch. This makes the function more readable and the target object creation reusable. Added an empty line after each creation of irTarget to make it easier to visually distinguish the cases that fall through.
Separate the target selection in GetTarget() into two steps. First determine the default target name for the image type and then use the name to initialise the target object. This is a bit more work (and double switching) but will be needed to support selecting targets externally.
Add an array of targets in the imageRequest and return an array from ImageRequest.GetTargets() (renamed from GetTarget()). Currently, the function still only returns one target, the default for the image type with the top level upload options.
Read the upload target types and options in the UploadTargets array of the ImageRequest and initialise the Target array. If the top-level (old) UploadOptions are also specified, prepend them to the array using the image type's default target type. Each upload target type is checked against a support map for compatibility.
It is now valid for UploadOptions to be nil but only if there is at least one UploadTarget defined.
Test some valid and invalid combinations for the GetTargets() upload target selection. Includes tests with and without the upload options for the default target.
Add the new upload_statuses under the image_status in the result of the ComposeStatus object. The first status is also included in the old top-level 'upload_status' property for backwards compatibility. Tests are updated to match the new results.
Add the pulp.ostree upload target to the cloud API and enable it for edge/iot commits. Co-Authored-By: Achilleas Koutsou <[email protected]>
When making the upload request for edge commit image types, use the new upload_targets array to define the aws.s3 upload options. Leave other upload target definitions as is for now to test the old options.
Check that the first element of the upload_statuses array matches the top-level upload_status. We only test one upload target for now.
ca76d14
to
70bb02c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! this was a big effort ._.
This PR is a follow-up to #3636 and replaces #3672. It requires #3636 but isn't based on it (it wont compile until it is).
The purpose of this PR is to add the ability to upload edge and iot commits built through the cloud API to a Pulp server that supports ostree repos. However, at the same time, we need to be able to support the old behaviour of uploading ostree commits to AWS S3. This is a required part of HMS-1798.
I also think it's a good idea in general to be able to specify alternative upload targets for certain artifacts. We could support uploading any artifact to S3 for example.
The main change in this PR is that an image request now includes an (optional)
upload_target
option which is an enum of the names of all the upload targets we support in the cloud API (in the formorg.osbuild.<target>
, e.g.,org.osbuild.aws.s3
). Omitting theupload_target
maintains the current behaviour, which means each image type has a default target. Also, we define a mapping between upload targets and image types that they support and any invalid combination is a bad request.The commit that adds the pulp ostree upload target to the cloud API was cherry picked from #3672 (thanks @kingsleyzissou).
This pull request includes: