Skip to content
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

[usage] Ensure Content-Type headers are set for GCP object storage uploads #11730

Merged
merged 2 commits into from
Aug 2, 2022

Conversation

andrew-farries
Copy link
Contributor

@andrew-farries andrew-farries commented Jul 28, 2022

Description

As part of the move towards usage based pricing (#9036), we'd like for the usage aggregator (components/usage) to be able to upload its usage reports to cloud storage. This will provide an audit trail of usage reports, allowing us to cross reference usage entries in the database with the usage reports that provided the data. In future, we may also allow access to these reports to users directly.

In order to be able to upload these reports to GCP Cloud Storage, the signed URL can be created for a specific Content-Type; only PUT requests to that URL that set the same Content-Type header will be accepted.

This PR sets the Content-Type header when generating the signed URL and sets it on the usage component PUT to that URL.

Minio object storage has no such requirements on the Content-Type header which is why we only hit this problem in staging/production.

Related Issue(s)

Fixes #11688

How to test

This is difficult to test as preview uses minio for object storage, not GCP.

Tested by taking the images built for this branch and hot-patching the images for content-service and usage in staging.

Reports are uploaded to the bucket:

image

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@andrew-farries andrew-farries requested review from a team July 28, 2022 17:13
@github-actions github-actions bot added team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team labels Jul 28, 2022
@andrew-farries
Copy link
Contributor Author

andrew-farries commented Jul 28, 2022

/hold as it's based on #11689

@andrew-farries
Copy link
Contributor Author

andrew-farries commented Jul 29, 2022

/werft run with-preview

👍 started the job as gitpod-build-af-forbidden-bucket-upload.17
(with .werft/ from main)

Copy link
Member

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Déjà-vu

Base automatically changed from af/rename-usage-report-bucket to main August 2, 2022 07:43
@roboquat roboquat requested a review from a team August 2, 2022 07:43
@roboquat roboquat added size/L and removed size/XS labels Aug 2, 2022
Andrew Farries added 2 commits August 2, 2022 07:48
Setting '*/*' doesn't work - it needs to be explict about the exact type
of content that that the signed URL will receive.
The signed upload URL only accepts requests with this Content-Type.
@andrew-farries
Copy link
Contributor Author

/unhold

@geropl
Copy link
Member

geropl commented Aug 2, 2022

/hold

@andrew-farries
Copy link
Contributor Author

andrew-farries commented Aug 2, 2022

/werft run

👍 started the job as gitpod-build-af-forbidden-bucket-upload.19
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-af-forbidden-bucket-upload.20 because the annotations in the pull request description changed
(with .werft/ from main)

@andrew-farries
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit a043243 into main Aug 2, 2022
@roboquat roboquat deleted the af/forbidden-bucket-upload branch August 2, 2022 09:58
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed: workspace Workspace team change is running in production deployed Change is completely running in production labels Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed: workspace Workspace team change is running in production deployed Change is completely running in production release-note-none size/XS team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usage report upload fails with GCS 403
5 participants