Skip to content

Add Cloudflare R2 support#2319

Merged
palfrey merged 1 commit into
TraceMachina:mainfrom
ashishsonamm:add-cloudflare-r2-store
May 18, 2026
Merged

Add Cloudflare R2 support#2319
palfrey merged 1 commit into
TraceMachina:mainfrom
ashishsonamm:add-cloudflare-r2-store

Conversation

@ashishsonamm
Copy link
Copy Markdown
Contributor

@ashishsonamm ashishsonamm commented May 10, 2026

Description

Adds Cloudflare R2 as a first-class CAS/AC backend by generalizing S3Store

Introduced 3 new optional fields in ExperimentalAwsSpec

  • endpoint
  • access_key_id
  • secret_access_key

If all the above three fields are unset, S3Store::new behaves exactly as before

Fixes #2293

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Unit Test
  • Bazel Test
  • E2E against Real R2 store

Checklist

  • Updated documentation if needed
  • Tests added/amended
  • bazel test //... passes locally
  • PR is contained in a single commit, using git amend see some docs

This change is Reviewable

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 10, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor Author

@ashishsonamm ashishsonamm left a comment

Choose a reason for hiding this comment

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

+@MarcusSorealheis

@ashishsonamm made 1 comment.
Reviewable status: 0 of 1 LGTMs obtained, and 0 of 8 files reviewed.

@MarcusSorealheis
Copy link
Copy Markdown
Collaborator

Hey @ashishsonamm thanks for coming through and opening a PR. We'd love to support you in landing your first PR here.

A couple initial thoughts:

  1. This feature is user-facing so we'd like to add documentation in the web/ dir where the user docs mostly live.

  2. This feature is more similar to https://github.com/TraceMachina/nativelink/blob/main/nativelink-store/src/ontap_s3_existence_cache_store.rs in its function in the sense that while Cloudflare does implement a lot of the s3 API, it should not affect the s3 store. I'm curious about your thoughts there. How can we minimize the surface area of the s3 store to support the addition of Cloudflare?

Really awesome work!!!

@ashishsonamm
Copy link
Copy Markdown
Contributor Author

ashishsonamm commented May 10, 2026

2. This feature is more similar to https://github.com/TraceMachina/nativelink/blob/main/nativelink-store/src/ontap_s3_existence_cache_store.rs in its function in the sense that while Cloudflare does implement a lot of the s3 API, it should not affect the s3 store. I'm curious about your thoughts there. How can we minimize the surface area of the s3 store to support the addition of Cloudflare?

I looked at the ontap_s3_existence_cache_store.rs, it composes the inner store and OntapS3Store stays untouched. My PR does this partially, the R2 store composes S3Store, but it also modifies ExperimentalAwsSpec and S3Store::new to inject the endpoint and creds, which is the surface area you're talking about.

The fix would be to rework R2Store so it builds its own aws S3 client with the endpoint and creds, and passes it to S3Store::new_with_client_and_jitter, this way S3Store stays untouched while still reusing most of the protocol code via the inner store.

I'll make this change and will also add the documentation

@ashishsonamm
Copy link
Copy Markdown
Contributor Author

Pushed the change for R2Store to build its own S3 client without touching any of the existing S3 store code.
For docs, the files under web are auto-generated from nativelink-config/README.md, so I have added the R2 section there.

@amankrx amankrx requested a review from palfrey May 11, 2026 16:20
@palfrey
Copy link
Copy Markdown
Member

palfrey commented May 18, 2026

Pushed the change for R2Store to build its own S3 client without touching any of the existing S3 store code.

Nice, liking this. If it's meant to be "S3 with another endpoint/region config" then this is the right way to go with this.

@palfrey palfrey force-pushed the add-cloudflare-r2-store branch from 1d6afc5 to f7cc5af Compare May 18, 2026 13:21
@palfrey palfrey merged commit 3d76991 into TraceMachina:main May 18, 2026
44 of 45 checks passed
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.

Add Cloudflare R2 object store support

4 participants