Skip to content

fix(orchestrator): let build-cache threshold flag raise above its fal…#3175

Merged
wj-e2b merged 1 commit into
mainfrom
wj-fix-race
Jul 2, 2026
Merged

fix(orchestrator): let build-cache threshold flag raise above its fal…#3175
wj-e2b merged 1 commit into
mainfrom
wj-fix-race

Conversation

@wj-e2b

@wj-e2b wj-e2b commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

…lback

startDiskSpaceEviction seeded the eviction threshold with the flag fallback (85) and only ever lowered it, so a
build-cache-max-usage-percentage flag value above 85 was silently capped at the fallback.

Extract the computation into evictionThreshold: take the minimum across the configured services' flag values (each of which already falls back inside IntFlag on evaluation failure), and use the fallback directly only when no services are configured.

…lback

startDiskSpaceEviction seeded the eviction threshold with the flag
fallback (85) and only ever lowered it, so a
build-cache-max-usage-percentage flag value above 85 was silently
capped at the fallback.

Extract the computation into evictionThreshold: take the minimum
across the configured services' flag values (each of which already
falls back inside IntFlag on evaluation failure), and use the fallback
directly only when no services are configured.
@cursor

cursor Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Localized change to cache eviction threshold logic with unit tests; affects disk usage behavior only when flags exceed the fallback.

Overview
Build cache disk eviction was capping the usage threshold at the flag fallback (85) even when build-cache-max-usage-percentage was set higher, because the loop only ever lowered an initial fallback value. Threshold selection is moved into evictionThreshold, which uses the fallback only when no services are configured and otherwise takes the minimum per-service flag value so raised limits apply and the strictest limit still wins across services.

Reviewed by Cursor Bugbot for commit 9430946. Bugbot is set up for automated code reviews on this repo. Configure here.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

No critical findings or correctness issues were identified in this pull request.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@claude claude 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.

LGTM — small, well-tested fix that lets the build-cache threshold flag raise above its fallback.

Extended reasoning...

Overview

This PR extracts eviction threshold computation into a helper evictionThreshold in packages/orchestrator/pkg/sandbox/build/cache.go. The previous code seeded the threshold with the flag fallback (85) and only lowered it via min, silently capping any configured value above the fallback. The new helper initializes with math.MaxInt and takes the minimum across configured services (with per-service IntFlag already handling its own fallback on evaluation failure), falling back to the flag default only when no services are configured.

Security risks

None. The change only affects a disk-space eviction threshold percentage inside an internal cache; it does not touch auth, crypto, permissions, or external I/O.

Level of scrutiny

Low. This is a small (~20 line) logic fix in a well-isolated helper with a clear behavioral bug and no cross-cutting implications.

Other factors

Test coverage is thorough — TestEvictionThreshold covers no-services fallback, flag raising above fallback, flag lowering below fallback, and the multi-service lowest-wins case using a proper LaunchDarkly test datastore. The refactor is a pure extraction plus the bug fix, no incidental changes. The bug hunter found no issues.

@wj-e2b wj-e2b enabled auto-merge (squash) July 2, 2026 00:23
@wj-e2b wj-e2b merged commit 06393c3 into main Jul 2, 2026
54 checks passed
@wj-e2b wj-e2b deleted the wj-fix-race branch July 2, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants