Skip to content

feat(cubestore): GCS Workload Identity Federation (WIF/ADC) support#10498

Open
KrishnaRMaddikara wants to merge 3 commits intocube-js:masterfrom
KrishnaRMaddikara:feat/cubestore-gcs-workload-identity-adc
Open

feat(cubestore): GCS Workload Identity Federation (WIF/ADC) support#10498
KrishnaRMaddikara wants to merge 3 commits intocube-js:masterfrom
KrishnaRMaddikara:feat/cubestore-gcs-workload-identity-adc

Conversation

@KrishnaRMaddikara
Copy link

@KrishnaRMaddikara KrishnaRMaddikara commented Mar 16, 2026

Problem

CubeStore's GCS remote storage implementation uses the cloud_storage crate,
which requires SERVICE_ACCOUNT or SERVICE_ACCOUNT_JSON environment variables
and panics when they are absent. This makes CubeStore completely non-functional
on GKE clusters that use Workload Identity Federation (WIF) — the recommended
GCP authentication model for Kubernetes workloads — where no service account key
file is needed or available.

Affects:

Solution

Replace cloud_storage with object_store crate for GCS operations.
object_store is already a transitive dependency of CubeStore via Apache
Arrow/DataFusion, so this adds no new dependencies.

GoogleCloudStorageBuilder::from_env() supports the full ADC credential chain
in priority order:

  1. CUBESTORE_GCP_KEY_FILE — existing env var, backward compatible
  2. CUBESTORE_GCP_CREDENTIALS — existing env var, backward compatible
  3. GKE Workload Identity via metadata server at 169.254.169.254main fix
  4. GOOGLE_APPLICATION_CREDENTIALS file path (standard ADC)
  5. gcloud CLI credentials (developer machines)

Backward Compatibility

Backward compatible for existing CUBESTORE_GCP_KEY_FILE,
CUBESTORE_GCP_CREDENTIALS, and common ADC-based environments.
Legacy JSON aliases (SERVICE_ACCOUNT_JSON,
GOOGLE_APPLICATION_CREDENTIALS_JSON) are mapped with deprecation warnings.

Testing

Tested on GKE with:

  • Workload Identity binding: serviceAccount@project.iam.gserviceaccount.com
  • IAM role: roles/storage.objectAdmin on the export bucket
  • CubeStore successfully reads/writes pre-aggregation files without any key file

Changes in v2 (follow-up commit)

  • Upload/download changed from full in-memory buffer to streaming
    (prevents OOM on workers with large pre-aggregation files)
  • Legacy env var aliases mapped explicitly for full backward compatibility
  • Fixed page count ceiling division
  • Fixed misleading GCS consistency comment

Addressed all review feedback — pushed 2 follow-up commits:

Commit 2 (fix: streaming + legacy aliases):

  • Upload: replaced fs::read() full-buffer with PutPayload::from_stream() — prevents OOM on large pre-aggregation files
  • Download: replaced bytes().await full-buffer with chunked into_stream() write to disk
  • Added explicit mapping for legacy SERVICE_ACCOUNT_JSON / GOOGLE_APPLICATION_CREDENTIALS_JSON aliases with deprecation warnings
  • Fixed page count ceiling division: (len + 999) / 1000
  • Fixed head() comment — workaround is for object_store path normalization, not GCS consistency

Commit 3 (fix: compile blockers):

  • Removed stale second store.put(data) call in upload_file (leftover from old buffered implementation, data was undefined)
  • Removed get_result.bytes().await before into_stream() — both consume GetResult, only streaming path remains
  • Softened "GCS consistency error" wording to "post-upload verification"

PR description updated: "Fully backward compatible" → scoped to commonly used credential env vars.

Closes #9837
Closes #7279

…ote storage

Replace cloud_storage crate with object_store crate for GCS remote filesystem.

Problem:
- cloud_storage crate requires SERVICE_ACCOUNT or SERVICE_ACCOUNT_JSON env vars
- Panics without them on GKE with Workload Identity (WIF) configured
- Affects all GKE users running CubeStore with Workload Identity

Fix:
- Switch to object_store crate (already a transitive dep via Arrow/DataFusion)
- GoogleCloudStorageBuilder::from_env() supports full ADC credential chain:
  1. CUBESTORE_GCP_KEY_FILE (backward compat)
  2. CUBESTORE_GCP_CREDENTIALS (backward compat)
  3. GKE Workload Identity via metadata server (the main fix)
  4. GOOGLE_APPLICATION_CREDENTIALS file
  5. gcloud CLI credentials (dev machines)

Backward compatible: existing SA key file deployments continue to work unchanged.

Closes cube-js#9837
Closes cube-js#7279
@KrishnaRMaddikara KrishnaRMaddikara requested a review from a team as a code owner March 16, 2026 03:48
@github-actions github-actions bot added pr:community Contribution from Cube.js community members. cube store Issues relating to Cube Store rust Pull requests that update Rust code labels Mar 16, 2026
…nt, comments

- Upload: replace fs::read() full-buffer with streaming PutPayload::from_stream()
- Download: replace bytes().await full-buffer with chunked stream to disk
- Add legacy mapping for SERVICE_ACCOUNT_JSON, GOOGLE_APPLICATION_CREDENTIALS_JSON
- Fix page count ceiling division: (len + 999) / 1000
- Fix head() comment: workaround is for object_store path handling, not GCS consistency
…tResult

- Remove leftover second store.put(data) call in upload_file (data undefined)
- Remove get_result.bytes().await before into_stream() — both consume GetResult
- Fix misleading 'GCS consistency error' wording in check_upload_file
@KrishnaRMaddikara
Copy link
Author

Both blockers are resolved in commit 59e7538:

  • upload_file: removed the stale second store.put(data) call —
    only the streaming put(&obj_path, payload) path remains
  • download_file: removed get_result.bytes().await entirely —
    only get_result.into_stream() is used now
  • check_upload_file error message changed to
    "not found during post-upload verification"
  • PR description updated: softened "Fully backward compatible" to
    "backward compatible for existing CUBESTORE_GCP_KEY_FILE,
    CUBESTORE_GCP_CREDENTIALS, and common ADC-based environments"

Ready for review.

@KrishnaRMaddikara
Copy link
Author

I’ve addressed the follow-up review points in the latest commits:
• removed the stale duplicate put(...) path in upload_file
• removed get_result.bytes().await; download_file now uses only streaming via into_stream()
• changed the post-upload verification message to neutral wording
• improved compatibility handling and updated the PR description wording

Latest commits on the PR branch:
59e7538 fix(cubestore/gcs): remove stale second put, fix double-consume of GetResult
aa6b4c1 fix(cubestore/gcs): streaming transfers, legacy env aliases, page count, comments

This should now be ready for another review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cube store Issues relating to Cube Store pr:community Contribution from Cube.js community members. rust Pull requests that update Rust code

Projects

None yet

1 participant