Skip to content

Aggregator: Re-implement the CloudBackendUploader with gcloud-storage crate #2475

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

Merged
merged 7 commits into from
May 14, 2025

Conversation

Alenar
Copy link
Collaborator

@Alenar Alenar commented May 13, 2025

Content

This PR re-implement the GCP Storage CloudBackendUploader using gcloud-storage, replacing the previous implementation that was using cloud-storage.

cloud-storage have not seen any update in three years and, since it make external requests, can pose security risks. The new gcloud-storage is more "bare metal" but is actively maintained.

Changes

  • Reorganize the gcp_uploader module:
    • promoted to a directory
    • renamed to cloud_uploader as it's the backend that ties to a specific provider
    • separated the backend from other the part
  • Extract the get_location from the legacy uploader to the CloudRemotePath (renamed to to_gcloud_storage_location) since we need to reuse it in the new uploader
  • Rename the previous uploader to GcpBackendUploaderLegacy then delete it and remove the cloud-storage dependency
  • Add a new CloudBackendUploader using gcloud-storage: it should be functionally equivalent (I made extra care to ensure the same api paths are called with the same parameters), but since there's no easy way to unit test it we will have to do it directly on testing-preview

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • No new TODOs introduced

Comments

If the new implementation crash on testing-preview and can't be easily fixed, revert the commit named chore(aggregator): remove legacy gcp storage uploader backend and rewire the GcpBackendUploaderLegacy in dependency injection.

Issue(s)

Relates to #2460

@Alenar Alenar self-assigned this May 13, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR re-implements the Google Cloud Storage uploader to use the actively maintained gcloud-storage crate, replacing the legacy cloud-storage implementation. Key changes include renaming and reorganizing modules within the gcp_uploader directory, adapting asynchronous build functions in dependency injection, and updating the Cargo.toml dependency.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/file_uploaders/mod.rs Renamed import from GcpBackendUploader to GCloudBackendUploader to reflect the new implementation.
src/file_uploaders/gcp_uploader/mod.rs Organized the gcp_uploader module into separate sub-modules.
src/file_uploaders/gcp_uploader/interface.rs Introduced the CloudRemotePath type and the CloudBackendUploader trait with tests for URI generation.
src/file_uploaders/gcp_uploader/gcloud_backend.rs Implemented the new GCloudBackendUploader using the gcloud-storage client with async operations and error contexts.
src/file_uploaders/gcp_uploader/api.rs Provided the GcpUploader interactor that wraps the new uploader and added comprehensive tests.
src/dependency_injection/builder/protocol/artifacts.rs Updated async build functions to create instances of GCloudBackendUploader and adjusted related uploader builders.
Cargo.toml Removed the deprecated cloud-storage dependency and added gcloud-storage.

Copy link

github-actions bot commented May 13, 2025

Test Results

    3 files  ±0     57 suites  ±0   11m 35s ⏱️ +3s
1 905 tests ±0  1 905 ✅ ±0  0 💤 ±0  0 ❌ ±0 
2 379 runs  ±0  2 379 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 3c9f808. ± Comparison against base commit 9df5a56.

This pull request removes 9 and adds 9 tests. Note that renamed tests count towards both.
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::cloud_backend_uploader::upload_public_file_fails_when_file_exists_fails_and_without_overwriting_allowed
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::cloud_backend_uploader::upload_public_file_fails_when_make_public_fails
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::cloud_backend_uploader::upload_public_file_fails_when_upload_fails
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::cloud_backend_uploader::upload_public_file_succeeds_when_file_does_not_exist_remotely_and_without_overwriting_allowed
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::cloud_backend_uploader::upload_public_file_succeeds_when_file_exists_remotely_and_without_overwriting_allowed
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::cloud_backend_uploader::upload_public_file_succeeds_with_overwriting_allowed
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::gcp_backend_uploader::get_location_not_using_cdn_domain_return_google_api_uri
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::gcp_backend_uploader::get_location_using_cdn_domain_return_cdn_in_uri
mithril-aggregator ‑ file_uploaders::gcp_uploader::tests::retry_policy_from_file_uploader_trait_should_be_implemented
mithril-aggregator ‑ file_uploaders::cloud_uploader::api::tests::retry_policy_from_file_uploader_trait_should_be_implemented
mithril-aggregator ‑ file_uploaders::cloud_uploader::api::tests::upload_public_file_fails_when_file_exists_fails_and_without_overwriting_allowed
mithril-aggregator ‑ file_uploaders::cloud_uploader::api::tests::upload_public_file_fails_when_make_public_fails
mithril-aggregator ‑ file_uploaders::cloud_uploader::api::tests::upload_public_file_fails_when_upload_fails
mithril-aggregator ‑ file_uploaders::cloud_uploader::api::tests::upload_public_file_succeeds_when_file_does_not_exist_remotely_and_without_overwriting_allowed
mithril-aggregator ‑ file_uploaders::cloud_uploader::api::tests::upload_public_file_succeeds_when_file_exists_remotely_and_without_overwriting_allowed
mithril-aggregator ‑ file_uploaders::cloud_uploader::api::tests::upload_public_file_succeeds_with_overwriting_allowed
mithril-aggregator ‑ file_uploaders::cloud_uploader::interface::tests::get_location_not_using_cdn_domain_return_google_api_uri
mithril-aggregator ‑ file_uploaders::cloud_uploader::interface::tests::get_location_using_cdn_domain_return_cdn_in_uri

♻️ This comment has been updated with latest results.

@Alenar Alenar temporarily deployed to testing-preview May 13, 2025 09:56 — with GitHub Actions Inactive
Copy link
Member

@jpraynaud jpraynaud left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Collaborator

@dlachaume dlachaume left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@Alenar Alenar force-pushed the djo/2460/reimpl_gcp_uploader branch from bf257e4 to e78e57c Compare May 13, 2025 13:57
Alenar added 4 commits May 13, 2025 15:57
* promoted to a directory
* splited into several part in order to isolate the old backend since it
  will be removed soon
…o `CloudRemotePath`

* Renamed to `to_gcloud_storage_location`
* This allow easy reuse of this code with the new backend
@Alenar Alenar force-pushed the djo/2460/reimpl_gcp_uploader branch from e78e57c to 0972218 Compare May 13, 2025 13:57
Alenar added 3 commits May 13, 2025 16:05
@Alenar Alenar force-pushed the djo/2460/reimpl_gcp_uploader branch from 0972218 to 3c9f808 Compare May 13, 2025 14:06
@Alenar Alenar temporarily deployed to testing-preview May 13, 2025 14:16 — with GitHub Actions Inactive
Copy link
Collaborator

@turmelclem turmelclem left a comment

Choose a reason for hiding this comment

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

LGTM

@Alenar Alenar merged commit 8b40a70 into main May 14, 2025
38 checks passed
@Alenar Alenar deleted the djo/2460/reimpl_gcp_uploader branch May 14, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants