Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(hcc): bound the SharedFileSystem inventory at the request, not the wait

Alfredo Lopez875755582a1a
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index f691dec4c..5b698d951 100644
--- a/host-context-controller/package-lock.json
+++ b/host-context-controller/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-host-context-controller",
- "version": "0.1.187",
+ "version": "0.1.188",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.187",
+ "version": "0.1.188",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
diff --git a/host-context-controller/package.json b/host-context-controller/package.json
index b707789fb..3664f50a5 100644
--- a/host-context-controller/package.json
+++ b/host-context-controller/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-host-context-controller",
- "version": "0.1.187",
+ "version": "0.1.188",
"description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API",
"main": "dist/main.js",
"engines": {
diff --git a/host-context-controller/src/config.ts b/host-context-controller/src/config.ts
index f7aa27439..decfeaeb8 100644
--- a/host-context-controller/src/config.ts
+++ b/host-context-controller/src/config.ts
@@ -200,13 +200,6 @@ export interface Config {
// safety convergence indefinitely.
externalEgressDnsResolveTimeoutMs: number
- // Deadline for the cold-start SharedFileSystem inventory that the first Host
- // fleet pass waits on. Waiting is deliberate — a pass without the inventory
- // writes mount-less templates and rerolls the fleet — but an apiserver that
- // never answers must not strand the fleet pass behind an already-certified
- // readiness.
- hostFleetSfsInventoryTimeoutMs: number
-
// Plugin image-host allowlist (Phase 2.3). Trusted raw-image prefixes for
// local-mode McpServer images. Audit mode (default) logs would-be denials
// without blocking; enforce mode blocks the workload build.
@@ -240,17 +233,6 @@ function getEnvInt(key: string, defaultValue: number): number {
return isNaN(parsed) ? defaultValue : parsed
}
-export function parseHostFleetSfsInventoryTimeoutMs(raw: string | undefined): number {
- if (raw === undefined || raw.trim() === '') return 30_000
- const parsed = Number(raw)
- if (!Number.isSafeInteger(parsed) || parsed <= 0 || parsed > 2_147_483_647) {
- throw new Error(
- `HCC_HOST_FLEET_SFS_INVENTORY_TIMEOUT_MS must be a positive integer no greater than 2147483647, got '${raw}'`
- )
- }
- return parsed
-}
-
export function parseExternalEgressDnsTimeoutMs(raw: string | undefined): number {
if (raw === undefined || raw.trim() === '') return 5_000
const parsed = Number(raw)
@@ -629,9 +611,6 @@ export const config: Config = {
// Periodic external-egress DNS resync (default 5 min). 0 disables.
externalEgressResyncIntervalSec: getEnvInt('HCC_EXTERNAL_EGRESS_RESYNC_SEC', 300),
- hostFleetSfsInventoryTimeoutMs: parseHostFleetSfsInventoryTimeoutMs(
- getEnv('HCC_HOST_FLEET_SFS_INVENTORY_TIMEOUT_MS')
- ),
externalEgressDnsResolveTimeoutMs: parseExternalEgressDnsTimeoutMs(
getEnv('HCC_EXTERNAL_EGRESS_DNS_TIMEOUT_MS')
),
diff --git a/host-context-controller/src/k8sClient.test.ts b/host-context-controller/src/k8sClient.test.ts
index b5e418844..95e8af758 100644
--- a/host-context-controller/src/k8sClient.test.ts
+++ b/host-context-controller/src/k8sClient.test.ts
@@ -157,7 +157,6 @@ vi.mock('./config', () => ({
port: 8081,
runtimeNamespaces: ['mcp-server', 'mcp-host', 'sandbox-recipes', 'rpc-proxy'],
hostK8sRequestTimeoutMs: 30_000,
- hostFleetSfsInventoryTimeoutMs: 30_000,
hostResyncIntervalSec: 0,
externalEgressResyncIntervalSec: 0,
controlApiBaseUrl: 'http://control-api.test:8090',
@@ -434,16 +433,15 @@ describe('McpServerWatcher startup', () => {
}
})
- it('schedules the first Host fleet pass when the SharedFileSystem inventory never settles', async () => {
- vi.useFakeTimers()
- // A SharedFileSystem LIST that never settles must not strand the initial
- // Host fleet pass: readiness can already be certified, so a Host fleet that
- // never reconciles is invisible to every probe.
- const neverSettles = new Promise<{ items: unknown[] }>(() => undefined)
+ it('schedules the first Host fleet pass when the SharedFileSystem inventory fails', async () => {
+ // The inventory LIST runs on the deadline-bearing client, so an apiserver
+ // that never answers is aborted and surfaces here as a rejection. The Host
+ // fleet must still converge: stranding it would leave every Host
+ // unreconciled behind an already-certified readiness.
mocks.listNamespacedCustomObject.mockImplementation(async ({ plural }: { plural: string }) => {
- if (plural === 'sharedfilesystems') return neverSettles
+ if (plural === 'sharedfilesystems') throw new Error('sharedfilesystems LIST aborted')
if (plural === 'communicationchannels') {
- return { metadata: { resourceVersion: 'sfs-stall-cc-rv' }, items: [] }
+ return { metadata: { resourceVersion: 'sfs-abort-cc-rv' }, items: [] }
}
return { items: [] }
})
@@ -451,41 +449,11 @@ describe('McpServerWatcher startup', () => {
const start = watcher.start()
try {
- await vi.advanceTimersByTimeAsync(config.hostFleetSfsInventoryTimeoutMs + 1000)
+ await start
await vi.waitFor(() => expect(mocks.hostFullReconcile).toHaveBeenCalledOnce())
} finally {
await watcher.stop()
await start.catch(() => undefined)
- vi.useRealTimers()
- }
- })
-
- it('coalesces sustained convergence churn into a single trailing pass', async () => {
- // Sustained churn must not turn the trailing loop into one apiserver pass
- // per request. `trailingRequested` is a boolean latch, so an unbounded
- // burst arriving during one in-flight pass may cost at most one more pass.
- const watcher = new McpServerWatcher()
- const inFlight = deferred()
- let coreRuns = 0
- ;(watcher as any).runInitialNetworkPolicyConvergenceCore = async () => {
- coreRuns += 1
- if (coreRuns === 1) await inFlight.promise
- }
-
- try {
- const first = (watcher as any).runInitialNetworkPolicyConvergence() as Promise<void>
- await flushMicrotasks()
- for (let burst = 0; burst < 50; burst += 1) {
- void (watcher as any).runInitialNetworkPolicyConvergence()
- }
- inFlight.resolve(undefined)
- await first
- await flushMicrotasks()
-
- expect(coreRuns).toBeLessThanOrEqual(2)
- } finally {
- inFlight.resolve(undefined)
- await watcher.stop()
}
})
diff --git a/host-context-controller/src/k8sClient.ts b/host-context-controller/src/k8sClient.ts
index 59c82dd8e..18fca3e8e 100644
--- a/host-context-controller/src/k8sClient.ts
+++ b/host-context-controller/src/k8sClient.ts
@@ -455,12 +455,16 @@ export async function getAuthToken(
* SharedFileSystems are allowed to live in, per CRD validation).
*/
export async function listAllSharedFileSystems(): Promise<SharedFileSystemCRD[]> {
- if (!customObjectsApi) {
+ if (!hostCustomObjectsApi) {
throw new Error('K8s client not initialized - are you in dev mode?')
}
try {
console.log(`[K8s] Listing all SharedFileSystems in namespace ${config.hostNamespace}`)
- const response = await customObjectsApi.listNamespacedCustomObject({
+ // Deadline-bearing client, like listHostSnapshot: the cold-start Host fleet
+ // pass waits on this inventory, so an apiserver that never answers would
+ // otherwise strand the fleet behind an already-certified readiness — and
+ // leave the SharedFileSystem watch, which starts after this await, dead.
+ const response = await hostCustomObjectsApi.listNamespacedCustomObject({
group: GROUP,
version: VERSION,
namespace: config.hostNamespace,
@@ -1581,25 +1585,11 @@ export class McpServerWatcher implements McpServerProvider {
if (initialSfsInventory) {
// Waiting for the inventory is deliberate: a Host fleet pass without it
// writes mount-less templates and immediately rerolls the whole fleet.
- // An apiserver that never answers the LIST, though, would strand the
- // fleet pass behind an already-certified readiness — no Host would ever
- // reconcile while `/ready` reports 200 — so the wait is bounded.
- let fleetPassRequested = false
- const requestFleetPassOnce = () => {
- if (fleetPassRequested) return
- fleetPassRequested = true
- requestFleetPass()
- }
- const inventoryDeadline = setTimeout(() => {
- console.error(
- `[K8s] SharedFileSystem inventory did not settle within ${config.hostFleetSfsInventoryTimeoutMs}ms — scheduling the initial Host fleet pass without it`
- )
- requestFleetPassOnce()
- }, config.hostFleetSfsInventoryTimeoutMs)
- void initialSfsInventory.then(() => {
- clearTimeout(inventoryDeadline)
- requestFleetPassOnce()
- })
+ // The wait cannot strand the fleet, because the LIST underneath runs on
+ // the deadline-bearing client: an apiserver that never answers aborts
+ // the request, `startSharedFileSystemInventoryAndWatch` logs and
+ // resolves false, and this settles. One path, one pass.
+ void initialSfsInventory.then(() => requestFleetPass())
} else {
requestFleetPass()
}