Skip to content

fix(scaletozero): skip scale-to-zero toggle for loopback connections#151

Merged
tnsardesai merged 1 commit intomainfrom
tanmay/kernel-965-billing-swap-debug-high-browser-usage-costs-from-orphaned-internal-vm-stz
Feb 11, 2026
Merged

fix(scaletozero): skip scale-to-zero toggle for loopback connections#151
tnsardesai merged 1 commit intomainfrom
tanmay/kernel-965-billing-swap-debug-high-browser-usage-costs-from-orphaned-internal-vm-stz

Conversation

@tnsardesai
Copy link
Contributor

@tnsardesai tnsardesai commented Feb 11, 2026

Summary

Loopback requests — such as internal health checks / playwright daemon connections — were toggling the scale-to-zero control file, keeping VMs alive indefinitely and driving up usage costs.

Changes:

  • Middleware now detects loopback source addresses and passes them through without touching scale-to-zero state
  • Added info-level logging around control-file writes for better observability
  • Added unit tests for the middleware and the loopback detection helper

Note

Low Risk
Small, localized change to request middleware behavior plus additional logging and tests; primary risk is mis-detecting client IPs when RemoteAddr doesn’t reflect the true origin behind proxies.

Overview
Prevents internal/loopback HTTP traffic from affecting VM scale-to-zero behavior by having the scaletozero HTTP middleware bypass Disable/Enable when RemoteAddr is a loopback IP (via new isLoopbackAddr).

Adds unit coverage for the middleware behavior (external vs loopback, and disable error handling) and increases controller observability by logging info-level messages when the scale-to-zero control file is missing or successfully written.

Written by Cursor Bugbot for commit 8cee14f. This will update automatically on new commits. Configure here.

Loopback (localhost) requests such as internal health checks were
toggling the scale-to-zero control file, keeping VMs alive
indefinitely. The middleware now detects loopback addresses and
passes them through without touching scale-to-zero state.

Also adds info-level logging around the control-file writes and
covers the new behaviour with unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
@tnsardesai tnsardesai marked this pull request as ready for review February 11, 2026 23:02
@tnsardesai tnsardesai requested a review from Sayan- February 11, 2026 23:02
Copy link
Contributor

@Sayan- Sayan- left a comment

Choose a reason for hiding this comment

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

yeet

@tnsardesai tnsardesai merged commit 134924c into main Feb 11, 2026
7 of 8 checks passed
@tnsardesai tnsardesai deleted the tanmay/kernel-965-billing-swap-debug-high-browser-usage-costs-from-orphaned-internal-vm-stz branch February 11, 2026 23:33
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.

2 participants