Skip to content

outposts: refresh channel groups on hello - #27136

Merged
dewi-tik merged 2 commits into
goauthentik:mainfrom
ketchupz1999:fix/outpost-group-membership-refresh
Oct 27, 2026
Merged

dewi-tik merged 2 commits into
goauthentik:mainfrom
ketchupz1999:fix/outpost-group-membership-refresh

Conversation

@ketchupz1999

@ketchupz1999 ketchupz1999 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Details

What does this PR change?

  • Re-adds an outpost websocket to its outpost-wide and instance-specific channel groups whenever it sends HELLO.
  • Changes the PostgreSQL channel layer's group_add operation to refresh an existing membership expiry and insert only when the membership does not exist.
  • Adds a websocket regression test that expires and cleans both memberships, sends HELLO, and verifies that the memberships and instance-group delivery recover without duplicate rows.

Why is this change needed?

Channel group memberships expire 24 hours after group_add, but an outpost can keep the same websocket open beyond that point. Once cleanup removes the membership rows, the websocket still appears healthy while server-to-outpost messages are silently dropped. RAC sessions can then hang until the outpost reconnects.

Refreshing on the periodic HELLO keeps membership lifetime aligned with the live connection. Updating an existing row avoids accumulating a new row for every heartbeat. group_add is changed in the shared layer rather than only in the outpost consumer: re-adding on every HELLO (about every 10 s) would otherwise insert a new row each time, roughly 17,000 rows per outpost per day.

How was this tested?

  • python manage.py test authentik/outposts --keepdb --noinput (28 passed)
  • focused regression test verified failing behavior before the fix and passing behavior after it
  • Black and Ruff on all changed files
  • strict mypy on all changed files
  • Bandit on the changed production files
  • git diff --check

Linked issues

Closes #27101

AI assistance disclosure

I used Opus 5.5 and gpt 5.6 sol (high) as a learning and development assistant while studying the authentik codebase. During that work, I found this existing issue, reproduced the reported behavior, traced the root cause, implemented the fix, and added the regression test with its assistance. I personally reviewed the final diff and verification results, understand the changes, and take responsibility for the submitted code.


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)
  • I have read the AI usage policy.

The first two items are not checked because this focused backend change was validated with the commands listed above rather than the full polyglot make all, and it does not change documentation.

@ketchupz1999
ketchupz1999 requested a review from a team as a code owner October 23, 2026 18:37
@netlify

netlify Bot commented Oct 23, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 61ff5ce
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6adba969254ee32cddbe0598
😎 Deploy Preview https://deploy-preview-27136--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dewi-tik dewi-tik added this to the Release 2026.11.0 milestone Oct 27, 2026
@dewi-tik
dewi-tik enabled auto-merge (squash) October 27, 2026 11:05
@dewi-tik

Copy link
Copy Markdown
Contributor

Thanks for this @ketchupz1999!

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.38%. Comparing base (76caff2) to head (eecf96e).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
authentik/outposts/consumer.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27136      +/-   ##
==========================================
- Coverage   92.41%   92.38%   -0.03%     
==========================================
  Files        1192     1192              
  Lines       80462    80509      +47     
  Branches     4351     4351              
==========================================
+ Hits        74358    74378      +20     
- Misses       6038     6065      +27     
  Partials       66       66              
Flag Coverage Δ
conformance 32.28% <2.00%> (-0.02%) ⬇️
e2e 36.95% <12.00%> (-0.02%) ⬇️
integration 28.82% <2.00%> (-0.37%) ⬇️
rust 44.42% <ø> (ø)
unit 94.07% <98.00%> (+<0.01%) ⬆️
unit-migrate 94.06% <98.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@dewi-tik
dewi-tik merged commit d428a99 into goauthentik:main Oct 27, 2026
162 of 163 checks passed
kensternberg-authentik added a commit that referenced this pull request Nov 5, 2026
* main: (89 commits)
  providers/scim: scope-aware adoption (#26174)
  sources/ldap: respect accountExpires attributes (#26135)
  web/flows: never let continuous login block the final redirect (#26269)
  website: document password hash import restrictions (#24235)
  core: restrict imported password hashers (#24234)
  core, web: update translations (#27148)
  server: retry requests on connections closed by a recycled worker (#27275)
  packages/django-postgres-cache, flows: count cache keys in the database (#25808)
  events: simplify execution of event rules/notifications (#26873)
  core: bump github.com/pires/go-proxyproto from 0.15.0 to 0.16.0 (#27260)
  core: bump goauthentik/platform-ssh from 26.04-ak-0.72.3 to 26.04-ak-0.72.4 in /tests/e2e (#27263)
  core: bump goauthentik/selenium from 155.0-ak-0.72.3 to 155.0-ak-0.72.4 in /tests/e2e (#27261)
  core: bump astral-sh/uv from 0.13.5 to 0.13.6 in /lifecycle/container (#27264)
  core: bump jsonpatch from 1.35 to 1.36 (#27269)
  outposts: refresh channel groups on hello (#27136)
  core: bump certifi from 2026.10.19 to 2026.10.23 (#27266)
  core: bump pluggy from 1.6.0 to v1.7.0 (#27238)
  core: bump markupsafe from 3.0.3 to v3.0.4 (#27225)
  core: bump httptools from 0.8.0 to v0.9.0 (#27219)
  core: bump iniconfig from 2.3.0 to v2.3.1 (#27221)
  ...
@BeryJu BeryJu added the backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 label Nov 10, 2026
@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #27737

BeryJu pushed a commit that referenced this pull request Nov 10, 2026
…up_send (#27717)

group_send and group_send_blocking looked up a group's channels without filtering on expires, so every expired GroupChannel row still received a copy of every broadcast. Each copy is a Message row insert plus a NOTIFY from the trigger. On one deployment with about 53,000 expired group rows, each outpost broadcast inserted about 53,000 messages, which contributed heavily to a 2.6 TB django_channels_postgres_message table.

Filter the lookup on expires >= now(), passing now() as a query parameter like the receive path does. Expired memberships are already treated as gone elsewhere (clean_expired_models deletes them), so only dead channels are skipped. The existing (group_key, expires) index covers the query.

This depends on #27136, which refreshes outpost group membership expiry on every hello. Any backport to a version branch must include #27136 as well; without it, outposts connected for longer than group_expiry (24 hours) would stop receiving broadcasts.
BeryJu pushed a commit that referenced this pull request Nov 10, 2026
…ion-2026.8) (#27737)

outposts: refresh channel groups on hello (#27136)

Co-authored-by: KetchupZ <[email protected]>
Co-authored-by: Dewi Roberts <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Outposts stop receiving messages after 24 h connected: channel group membership expires (breaks RAC)

3 participants