-
Notifications
You must be signed in to change notification settings - Fork 108
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
Weldr/Cloud API: simplify GCP upload options #3023
Conversation
c767835
to
5991d11
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.
LGTM. One tiny question.
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.
I have concerns about generating the GCP object names on multiple levels, I think that we should make it more consistent and do it in the API.
Also, I would really love to make the worker more dumb and predictive.
Should we update Lines 1 to 21 in d9cfbea
|
Looking at it, probably yes. Everything should keep working even without this change as the option to pass the bucket via the API call is still present. Nevertheless changing the script will be needed anyway in order to stop passing the bucket over the API, so I may as well change it now. Thanks for pointing this out! |
fb37f5e
to
625fca2
Compare
I addressed all review comments and added a change for the packer template as suggested by Sanne. Please have a look. |
Oh no, it now needs to be rebased. :/ Otherwise, this is amazing! |
1363b72
to
0f4f3b4
Compare
Rebased on top of |
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.
Thanks a lot, a great cleanup!
0f4f3b4
to
cb1afe6
Compare
Rebase on |
Flip the logic when deciding if to use the Bucket from the job or worker configuration. Previously, the Bucket from the worker configuration was always preferred if it was set, even if it was provided in the job itself. This made it impossible to override the configuration. Change the logic to use the Bucket from the worker configuration only if it was not set in the job. Report an error if no bucket name was provided with the job and there is also none specified in the configuration.
There is a desire to make the worker as "dumb" as possible. Therefore it is not desired to generate the AWS object key names in the worker if it was not provided in the job. Modify the worker code to not generate the AWS object key in any case and instead set an error in case the object key was not provided. Modify Weldr API implementation to generate the object key, if it was not provided by the user. This is consistent with Cloud API implementation.
Previously, the internal `OSBuildJobImpl` structure defined only `GCPCreds` member. This is not practical, once there will be more than one GCP-related variable. Define a new `GCPConfiguration` structure, move the credentials variable into it and use it in `OSBuildJobImpl` instead.
Extend the worker's configuration to allow setting GCP Bucket to use when uploading images to GCP. The value from the configuration is used only if not provided in the TargetOptions of the job. In GCP, the region of the bucket does not limit importing of the image to a particular region. So it is completely possible to use a single Bucket to import images to any and all regions. Return an error in case no bucket name was set in the job nor in the worker configuration.
The Bucket can now be set also in the worker configuration.
GCP Bucket to use can be now configured in the worker configuration. Make the `Bucket` optional in the Cloud API when uploading image to GCP. Adjust the Cloud API test case to configure GCP Bucket on the worker and not provide it in the API request.
The object key is required in order to upload the image to GCP. Return an error if it is not set.
Previously, it was expected from the user to provide the Object name when uploading image to GCP. The object name does not matter much, because the object is deleted once image import finishes. Make the specification of the object name optional and generate it if not provided. Adjust the GCP Weldr test case to not provide the Object name when uploading the image. The user can still provide the Object name if needed.
Similar to AWS, set the GCP bucket in the worker configuration.
Add a comment explaining why it is important to set the AWS bucket in the worker configuration, even if the `AWS_ACCOUNT_IMAGE_BUILDER_ARN` is empty.
cb1afe6
to
a80273c
Compare
The GCP Bucket may be (and usually will be) set on the composer-worker. Related to osbuild/osbuild-composer#3023. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
The GCP Bucket may be (and usually will be) set on the composer-worker. Related to osbuild/osbuild-composer#3023. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
The GCP Bucket may be (and usually will be) set on the composer-worker. Related to osbuild/osbuild-composer#3023. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
The GCP Bucket may be (and usually will be) set on the composer-worker. Related to osbuild/osbuild-composer#3023. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
In both, the Weldr and Cloud APIs, users had to previously provide values, which could have been generated automatically by osbuild-composer, or were in reality static and could be configured on the worker.
Specifically:
Bucket
- bucket name usually does not change for Cloud API calls, since it is specific to the GCP credentials provisioned on the worker and as a result, to the respective GCP project. Therefore it makes more sense to allow setting the GCP bucket in the worker configuration when composer is running in a SaaS deployment.Object
- object name used for the image when uploading it to the GCP Storage had to be previously provided by the user of the Weldr API. For Cloud API, the value has been generated by the implementation. In reality, the object name is not very important, as long as it is unique. The reason is that the object gets deleted after the image importing finishes.Notable changes:
Bucket
optional for GCP upload options in the Cloud API. Adjust the Cloud API test case to set the Bucket in the worker configuration, instead of passing it in the compose request.This pull request includes: