feat(experimentation): add per-organisation ingestion infrastructure service#8035
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughAdds an environment setting and immutable return type for ingestion infrastructure. Implements organisation-scoped S3 bucket and AWS Firehose delivery stream provisioning, including lifecycle, access, partitioning, compression, and error-output configuration. Updates production and staging task definitions with the delivery-role ARN, documents creation events, and adds mocked AWS tests covering validation, configuration, headers, logging, and error propagation. Estimated code review effort: 4 (Complex) | ~45 minutes Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8035 +/- ##
==========================================
+ Coverage 98.64% 98.65% +0.01%
==========================================
Files 1506 1514 +8
Lines 59573 60110 +537
==========================================
+ Hits 58767 59304 +537
Misses 806 806 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
e75bdc5 to
ab5cb97
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
api/experimentation/ingestion_infra_service.py (1)
195-200: 🩺 Stability & Availability | 🔴 Critical | 🏗️ Heavy liftHandle partial provisioning failures to avoid permanently breaking retries.
Because
_create_events_bucketand_create_delivery_streamunconditionally propagate all AWS client exceptions, a transient failure halfway through provisioning (for instance, if_create_delivery_streamfails after the S3 bucket is created) will cause subsequent retries to fail immediately. On the next attempt,s3.create_bucketwill raise aBucketAlreadyOwnedByYou(or similar) exception, which propagates and halts execution before the stream can be created.To ensure the provisioning workflow can safely recover from partial failures, either catch and handle "already exists" exceptions in the helper functions to restore idempotency, or explicitly check for resource existence here before attempting creation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f42141b3-6a0e-4f6f-832c-eb7fc8397be9
📒 Files selected for processing (3)
api/experimentation/ingestion_infra_service.pyapi/tests/unit/experimentation/test_ingestion_infra_service.pydocs/docs/deployment-self-hosting/observability/_events-catalogue.md
⚖️ Themis judgement: ✅ Ship itWell-structured service layer for provisioning per-organisation S3 event buckets and Firehose delivery streams. The create-then-reconcile pattern for the bucket (public access block and lifecycle reapplied on every call) is a good security habit, and the deliberate create-only semantics for the stream are documented in the docstring. Error handling correctly distinguishes "resource already exists" from real failures in both S3 and Firehose paths. Tests are thorough — happy path with full destination config verification, idempotency, header injection for account-regional namespace, settings guard, and error propagation for both AWS services.
Test coverage gets a 4 because the main integration test does heavy lifting (full destination config assertion, lifecycle, public access block, log events), but there are no direct unit tests for 📝 Walkthrough
🧪 How to verify
Automate: CI already covers steps 1–2 via the Product take: Infrastructure plumbing for per-organisation experiment event ingestion — no user-visible change yet, but it lays the foundation for the experimentation data pipeline. Solid improvement to the platform's experimentation capabilities once wired up. 🧭 Assumptions & unverified claims
A service that provisions its own buckets and streams — the infrastructure is bootstrapping itself, one org at a time. · reviewed at d9291a6 |
Zaimwa9
left a comment
There was a problem hiding this comment.
2 comments more than requesting changes. For the create flow, a comment would be satisfying imo.
For the tags, it looks interesting to keep track of the costs precisely
Add an organisation_id cost-allocation tag to the per-organisation S3 bucket and Firehose delivery stream so AWS billing can be attributed per organisation.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Adds a service layer for provisioning per-organisation experiment events ingestion infrastructure, to be consumed by the events ingestion server and hooked up to an API later.
experimentation/ingestion_infra_service.py:provision_ingestion_infrastructure(organisation_id)idempotently creates an S3 events bucket and a DirectPut Firehose delivery stream per organisation.environment_key, so objects land under per-environment S3 namespaces (events/env_key=.../year=.../...) and are batched per environment.INGESTION_EVENTS_BUCKET_PREFIX,INGESTION_FIREHOSE_DELIVERY_ROLE_ARN(a single shared Firehose delivery role, provisioned out-of-band, scoped by bucket naming convention).Note: with a shared delivery role, per-stream/bucket isolation is enforced by the control plane (only this service sets stream destinations), not IAM; per-organisation roles are a possible v2 hardening.
How did you test this code?
Unit tests with moto covering fresh provisioning (full destination config), idempotent re-runs, missing-settings errors, and AWS client error propagation.
make lint,make typecheck, and the full experimentation unit suite pass locally.