Skip to content

Comments

Retry device api call when tunnel proxy returns 502 to re-set the device affinity token#6748

Merged
cstns merged 3 commits intomainfrom
6747_retry-setting-device-affinity-token-in-scaled-environment
Feb 20, 2026
Merged

Retry device api call when tunnel proxy returns 502 to re-set the device affinity token#6748
cstns merged 3 commits intomainfrom
6747_retry-setting-device-affinity-token-in-scaled-environment

Conversation

@cstns
Copy link
Contributor

@cstns cstns commented Feb 20, 2026

Description

The Load Balancer (LB) occasionally delegates requests to stale or incorrect tunnel instances. Because the LB uses sticky sessions, once a "bad" path is established, subsequent requests fail until the affinity is reset.

Addresses the ~50% failure rate where the Load Balancer routes requests to improper tunnel backends. This PR introduces a retry mechanism that refreshes the device affinity token upon encountering an HTTP 502.

Statistical Impact (5 Attempts)
Initial Call 50%
Retry 1 75%
Retry 2 87.5%
Retry 3 93.75%
Retry 4 96.875%

Related Issue(s)

closes #6747

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed.

Labels

  • Includes a DB migration? -> add the area:migration label

@cstns cstns requested a review from hardillb February 20, 2026 11:13
@cstns cstns self-assigned this Feb 20, 2026
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.65%. Comparing base (6a2bf39) to head (0f744ff).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6748   +/-   ##
=======================================
  Coverage   76.65%   76.65%           
=======================================
  Files         398      398           
  Lines       20108    20108           
  Branches     4844     4844           
=======================================
  Hits        15414    15414           
  Misses       4694     4694           
Flag Coverage Δ
backend 76.65% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

@cstns cstns merged commit 93ad7ee into main Feb 20, 2026
29 checks passed
@cstns cstns deleted the 6747_retry-setting-device-affinity-token-in-scaled-environment branch February 20, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set device affinity cookie before opening the device tunnel

3 participants