Skip to content

feat(experimentation): route external warehouse events to a static Kafka topic - #8530

Merged
gagantrivedi merged 4 commits into
mainfrom
feat/external-warehouse-kafka-topic
Sep 16, 2026
Merged

gagantrivedi merged 4 commits into
mainfrom
feat/external-warehouse-kafka-topic

Conversation

@gagantrivedi

@gagantrivedi gagantrivedi commented Sep 15, 2026

Copy link
Copy Markdown
Member

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

The ingestion server now produces events to Kafka, so external warehouse connections no longer need a per-organisation S3 bucket and Firehose stream.

  • Creating or deleting a connection enqueues one sync_environment_ingestion task, which reads the active connection and converges Redis on it: external connections get the static external_warehouse_events topic as destination before their keys are whitelisted, Flagsmith ones follow the default pipeline, and an environment with no connection has its keys and destination removed
  • Removed per-organisation S3/Firehose/CloudWatch provisioning and teardown, the OrganisationIngestionInfrastructure and WarehouseDeliveryLog models, and the S3 to ClickHouse delivery tasks.
  • Removed the INGESTION_FIREHOSE_DELIVERY_ROLE_ARN setting and its ECS task definition entries.

Deploy notes:

  • Existing external connections still have Firehose stream names as their Redis destinations. Run sync_environment_ingestion(environment_id) for each affected environment.
  • Per-organisation buckets, delivery streams and log groups created so far need deleting by hand.

How did you test this code?

Unit tests under api/tests/unit/experimentation and api/tests/unit/organisations, plus mypy, ruff and the docgen pre-commit hook.

…fka topic

External warehouse connections no longer provision a per-organisation S3
bucket and Firehose stream. The ingestion server produces to Kafka, so
the environment's Redis destination is set to the shared
external_wh_events topic instead. The S3-based delivery to customer
ClickHouse instances and the per-organisation infrastructure models are
removed along with it.
@gagantrivedi
gagantrivedi requested review from a team as code owners September 15, 2026 08:39
@gagantrivedi
gagantrivedi requested review from matthewelwell and removed request for a team September 15, 2026 08:39
@vercel

vercel Bot commented Sep 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 16, 2026 6:46am UTC
2 Skipped Deployments
Project Deployment Actions Updated
flagsmith-frontend-preview Ignored Ignored Preview Sep 16, 2026 6:46am UTC
flagsmith-frontend-staging Ignored Ignored Preview Sep 16, 2026 6:46am UTC

Request Review

@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates infrastructure labels Sep 15, 2026
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: d708337b-f6a7-46f1-8356-6222e666e45a

📥 Commits

Reviewing files that changed from the base of the PR and between ac7139c and f1e55ed.

📒 Files selected for processing (1)
  • api/experimentation/tasks.py

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change removes per-organisation AWS ingestion infrastructure and S3-based warehouse event delivery. External warehouse events now use the external_warehouse_events topic. Related models, tasks, metrics, lifecycle hooks, tests, observability entries, and deployment environment variables were removed or updated. ClickHouse connection verification remains.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: ⚪ Minimal · up to f1e55

New and deleted warehouse connections trigger ingestion synchronization, so routing and cleanup remain reconciled.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot removed infrastructure docs Documentation updates labels Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-8530 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-8530 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-8530 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-8530 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8530 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8530 Finished ✅ Results

@github-actions github-actions Bot added docs Documentation updates infrastructure feature New feature or request and removed feature New feature or request infrastructure docs Documentation updates labels Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-16 — run #20476 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  58.3 seconds
commit  aee4cb0
info  🔄 Run: #20476 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #20476 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  3.8 seconds
commit  aee4cb0
info  🔄 Run: #20476 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #20476 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  40.2 seconds
commit  aee4cb0
info  🔄 Run: #20476 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #20476 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.6 seconds
commit  aee4cb0
info  🔄 Run: #20476 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #20452 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  37.8 seconds
commit  f1e55ed
info  🔄 Run: #20452 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #20451 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  1 minute, 10 seconds
commit  ac7139c
info  🔄 Run: #20451 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #20452 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  41.1 seconds
commit  f1e55ed
info  🔄 Run: #20452 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #20451 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  1 minute, 4 seconds
commit  ac7139c
info  🔄 Run: #20451 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #20452 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  42.4 seconds
commit  f1e55ed
info  🔄 Run: #20452 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #20452 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  3.4 seconds
commit  f1e55ed
info  🔄 Run: #20452 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #20451 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  32.9 seconds
commit  ac7139c
info  🔄 Run: #20451 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #20451 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  34.9 seconds
commit  ac7139c
info  🔄 Run: #20451 (attempt 1)

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.81%. Comparing base (9180452) to head (aee4cb0).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8530      +/-   ##
==========================================
- Coverage   98.82%   98.81%   -0.02%     
==========================================
  Files        1622     1619       -3     
  Lines       66727    66053     -674     
==========================================
- Hits        65942    65268     -674     
  Misses        785      785              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 7c364438-b725-4eab-981c-d6f423688160

📥 Commits

Reviewing files that changed from the base of the PR and between e2fb680 and 438cdcd.

📒 Files selected for processing (27)
  • api/app/settings/common.py
  • api/experimentation/constants.py
  • api/experimentation/dataclasses.py
  • api/experimentation/ingestion_infra_service.py
  • api/experimentation/ingestion_sync_service.py
  • api/experimentation/metrics.py
  • api/experimentation/migrations/0014_drop_ingestion_infrastructure_and_delivery_log.py
  • api/experimentation/models.py
  • api/experimentation/organisation_ingestion_service.py
  • api/experimentation/services.py
  • api/experimentation/tasks.py
  • api/experimentation/warehouse_delivery_service.py
  • api/organisations/models.py
  • api/tests/unit/experimentation/conftest.py
  • api/tests/unit/experimentation/test_ingestion_infra_service.py
  • api/tests/unit/experimentation/test_ingestion_sync_service.py
  • api/tests/unit/experimentation/test_models.py
  • api/tests/unit/experimentation/test_organisation_ingestion_service.py
  • api/tests/unit/experimentation/test_tasks.py
  • api/tests/unit/experimentation/test_warehouse_delivery_service.py
  • api/tests/unit/organisations/test_unit_organisations_models.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md
  • docs/docs/deployment-self-hosting/observability/_metrics-catalogue.md
  • infrastructure/aws/production/ecs-task-definition-admin-api.json
  • infrastructure/aws/production/ecs-task-definition-task-processor.json
  • infrastructure/aws/staging/ecs-task-definition-admin-api.json
  • infrastructure/aws/staging/ecs-task-definition-task-processor.json
💤 Files with no reviewable changes (16)
  • api/experimentation/dataclasses.py
  • api/organisations/models.py
  • api/tests/unit/organisations/test_unit_organisations_models.py
  • infrastructure/aws/staging/ecs-task-definition-admin-api.json
  • api/experimentation/ingestion_infra_service.py
  • api/app/settings/common.py
  • api/tests/unit/experimentation/conftest.py
  • docs/docs/deployment-self-hosting/observability/_metrics-catalogue.md
  • api/tests/unit/experimentation/test_organisation_ingestion_service.py
  • api/experimentation/services.py
  • infrastructure/aws/production/ecs-task-definition-admin-api.json
  • api/experimentation/organisation_ingestion_service.py
  • infrastructure/aws/production/ecs-task-definition-task-processor.json
  • api/tests/unit/experimentation/test_ingestion_infra_service.py
  • infrastructure/aws/staging/ecs-task-definition-task-processor.json
  • api/experimentation/metrics.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread api/experimentation/models.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Backfill existing external warehouse destinations before removing the old infrastructure. · api/experimentation/models.py:91-95

91-95: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Backfill existing external warehouse destinations before removing the old infrastructure.

Before this change, the AFTER_CREATE hook provisioned per-organisation infrastructure and stored its stream name in Redis. Existing WarehouseConnection rows do not run that hook again, so they retain that destination.

Migration 0014_drop_ingestion_infrastructure_and_delivery_log.py removes the old infrastructure models but does not update Redis. The deployment paths only run migrations. If the old stream is unavailable, those connections can stop delivering external events.

Set external_warehouse_events for every existing external connection before removing the old infrastructure. The new creation hook already sets this destination for new connections, so no separate caller fix is required.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: ae0eb8d9-213e-4ed6-92f2-015ed2d54a0d

📥 Commits

Reviewing files that changed from the base of the PR and between 438cdcd and ad9b8a1.

📒 Files selected for processing (4)
  • api/experimentation/constants.py
  • api/tests/unit/experimentation/test_ingestion_sync_service.py
  • api/tests/unit/experimentation/test_models.py
  • api/tests/unit/experimentation/test_tasks.py

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@github-actions github-actions Bot added the docs Documentation updates label Sep 15, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request infrastructure docs Documentation updates labels Sep 15, 2026
…tion

Creating and deleting a connection enqueued independent write and remove
tasks, and the task processor does not order tasks per environment, so
recreating a connection could leave the remove task running last and
wipe the new keys. One task now reads the active connection and converges
Redis on it, so a delete-then-create pair ends up correct whichever task
runs last.
@gagantrivedi
gagantrivedi force-pushed the feat/external-warehouse-kafka-topic branch from ac7139c to f1e55ed Compare September 15, 2026 09:15
@github-actions github-actions Bot added docs Documentation updates infrastructure feature New feature or request and removed feature New feature or request infrastructure docs Documentation updates labels Sep 15, 2026
@gagantrivedi
gagantrivedi requested review from Zaimwa9 and removed request for a team and matthewelwell September 15, 2026 09:20

@Zaimwa9 Zaimwa9 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall looking good but 2 minors:

  • resync on warehouse switch
  • managing environment soft deletes

Comment thread api/experimentation/tasks.py Outdated
Comment thread api/experimentation/models.py
Comment thread api/experimentation/services.py
…environment deletion

Changing a connection's warehouse type left the old Redis destination in
place, and deleting an environment left its keys behind because the sync
task could no longer find the soft-deleted environment.
@github-actions github-actions Bot added docs Documentation updates infrastructure feature New feature or request and removed feature New feature or request infrastructure docs Documentation updates labels Sep 16, 2026
@gagantrivedi
gagantrivedi merged commit 89ce13c into main Sep 16, 2026
35 checks passed
@gagantrivedi
gagantrivedi deleted the feat/external-warehouse-kafka-topic branch September 16, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants