Skip to content

feat(Segment Membership): Seed organisations too large for the task processor - #8517

Open
matthewelwell wants to merge 1 commit into
mainfrom
feat/seed-segment-membership-command
Open

matthewelwell wants to merge 1 commit into
mainfrom
feat/seed-segment-membership-command

Conversation

@matthewelwell

Copy link
Copy Markdown
Contributor

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

A seed that outlives its 4h task timeout is marked failed while its thread keeps running, retried alongside that thread, and re-enqueued hourly once the retries are exhausted. Adds a seed_segment_membership management command that calls the task inline instead, so an organisation too large to finish inside the timeout can be seeded as a standalone ECS task that no deployment interrupts and nothing retries.

--ignore-feature-flag seeds an organisation that doesn't have segment_membership_inspection yet, so ClickHouse can be populated before the feature is exposed and the first counts shown are complete.

How did you test this code?

Unit tests cover the command running the seed inline rather than queuing it, and the task seeding with the flag off when told to. The existing seed tests still pass unchanged.

…rocessor

A seed that outlives its 4h task timeout is marked failed while its thread
keeps running, retried alongside that thread, and re-enqueued hourly once
the retries are exhausted. A management command calls the task inline
instead, so it can run as a standalone ECS task that no deployment
interrupts and nothing retries.

`--ignore-feature-flag` populates ClickHouse before an organisation is
given the feature, so the first membership counts it sees are complete.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 14, 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 14, 2026 9:42am UTC
2 Skipped Deployments
Project Deployment Actions Updated
flagsmith-frontend-preview Ignored Ignored Sep 14, 2026 9:42am UTC
flagsmith-frontend-staging Ignored Ignored Sep 14, 2026 9:42am UTC

Request Review

@matthewelwell
matthewelwell requested review from a team as code owners September 14, 2026 09:41
@matthewelwell
matthewelwell requested review from emyller and removed request for a team September 14, 2026 09:41
@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates and removed docs Documentation updates labels Sep 14, 2026
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The pull request adds a Django management command for synchronous organisation identity seeding. The command accepts an organisation ID and an optional feature-flag override. The seeding task now supports this override while retaining the default feature-flag check. Unit tests cover command execution and override behaviour. The events catalogue updates source line references for segment-membership events.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🔵 Low · up to 79966

Operators consulting the event catalogue may look for this skipped-seed event at the wrong log level. Correct the documentation before merge.


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 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

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

@github-actions

github-actions Bot commented Sep 14, 2026

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  38.3 seconds
commit  79966d7
info  🔄 Run: #20423 (attempt 1)

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

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

passed  3 passed

Details

stats  3 tests across 3 suites
duration  32.7 seconds
commit  79966d7
info  🔄 Run: #20423 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  46.4 seconds
commit  79966d7
info  🔄 Run: #20423 (attempt 1)

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

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

passed  1 passed

Details

stats  1 test across 1 suite
duration  33.5 seconds
commit  79966d7
info  🔄 Run: #20423 (attempt 1)

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: ad4098e1-173e-46e4-b963-3a4bc54c4b0e

📥 Commits

Reviewing files that changed from the base of the PR and between a82c3d6 and 79966d7.

📒 Files selected for processing (7)
  • api/segment_membership/management/__init__.py
  • api/segment_membership/management/commands/__init__.py
  • api/segment_membership/management/commands/seed_segment_membership.py
  • api/segment_membership/tasks.py
  • api/tests/unit/segment_membership/test_unit_segment_membership_commands.py
  • api/tests/unit/segment_membership/test_unit_segment_membership_tasks.py
  • docs/docs/deployment-self-hosting/observability/_events-catalogue.md

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

@github-actions

Copy link
Copy Markdown
Contributor

Visual Regression

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

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8517   +/-   ##
=======================================
  Coverage   98.82%   98.82%           
=======================================
  Files        1622     1624    +2     
  Lines       66727    66768   +41     
=======================================
+ Hits        65942    65983   +41     
  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.

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.

1 participant