Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(hcc): report a held renewal failure as telemetry, not as a failed intent
Alfredo Lopez6ec74d72d1f8
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 122f3cf3d..bb3c7fe0c 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.374",+ "version": "0.1.375","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.374",+ "version": "0.1.375","license": "SEE LICENSE IN LICENSE","dependencies": {"@clerum/codex-catalog-projection": "file:../packages/codex-catalog-projection",diff --git a/host-context-controller/package.json b/host-context-controller/package.jsonindex e460edf62..dde8a1bec 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.374",+ "version": "0.1.375","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/hostReconciler.ts b/host-context-controller/src/hostReconciler.tsindex fc3087d3f..f262dd1cf 100644--- a/host-context-controller/src/hostReconciler.ts+++ b/host-context-controller/src/hostReconciler.ts@@ -5233,7 +5233,13 @@ export class HostReconciler {namespace: host.namespace,err: error instanceof Error ? error.message : String(error),})- this.enqueueControllerError(host, 'RuntimeCredentialRenewalFailed', error)+ // Telemetry only: this pass still ends with the runtime deployed and+ // Ready, so the administrative outcome it reports is `succeeded`. A+ // `failed` outcome here would give one intent both outcomes.+ this.enqueueHostTelemetry(host, 'controller_error', 'RuntimeCredentialRenewalFailed', {+ status: 'failed',+ error_class: error instanceof Error ? error.name : typeof error,+ })this.setStatus(host.name, {deployed: true,ready: runtimeIsReady,diff --git a/host-context-controller/test/hostReconciler.lifecycle.test.ts b/host-context-controller/test/hostReconciler.lifecycle.test.tsindex 1dce0b4b2..fc3abc162 100644--- a/host-context-controller/test/hostReconciler.lifecycle.test.ts+++ b/host-context-controller/test/hostReconciler.lifecycle.test.ts@@ -1,5 +1,6 @@import { afterEach, describe, expect, it, vi } from 'vitest'import * as k8s from '@kubernetes/client-node'+import type { AdministrativeOutcomeReporter } from '../src/administrativeOutcomeReporter'import { config } from '../src/config'import { mintHostGfsToken } from '../src/gfsHostBinding'import {@@ -169,6 +170,7 @@ function createReconciler(deps?: {isCommunicationChannelCacheSynced?: () => booleanresolveContextMounts?: (host: HostCRD) => Promise<ResolvedSfsMount[]>infrastructureTelemetryReporter?: InfrastructureTelemetryReporter+ administrativeOutcomeReporter?: AdministrativeOutcomeReporter}) {const appsApi = createMockAppsApi()const coreApi = createMockCoreApi()@@ -2602,13 +2604,26 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {})it('keeps a Ready held runtime deployed when its GFS renewal fails, without retry backoff', async () => {- const host = makeStatelessHost({- status: { lifecycle: { state: 'active', wakeHandledGeneration: 1 } },- })+ // An administrative intent on the Host: the pass that keeps the runtime+ // Ready must report exactly one outcome for it.+ const host: HostCRD = {+ ...makeStatelessHost({+ status: { lifecycle: { state: 'active', wakeHandledGeneration: 1 } },+ }),+ generation: 4,+ annotations: {+ 'clerum.io/administrative-intent-id': '22222222-2222-4222-8222-222222222222',+ },+ }const infrastructureTelemetryReporter = createTelemetryReporterMock()+ const administrativeOutcomeReporter = {+ enqueueHostOutcome: vi.fn(),+ stop: vi.fn(async () => undefined),+ }const { reconciler, appsApi, coreApi, customApi } = createReconciler({isCommunicationChannelCacheSynced: () => false,infrastructureTelemetryReporter,+ administrativeOutcomeReporter,})customApi.getNamespacedCustomObject.mockImplementation(async () => hostApiObject(host))reconciler.setHostFrontsOAuthServer(async () => false)@@ -2658,6 +2673,16 @@ describe('HostReconciler stateless lifecycle — rejection matrix', () => {reason_code: 'RuntimeCredentialRenewalFailed',status: 'failed',})+ // The renewal failure is telemetry; the intent's one outcome is the Ready+ // runtime, never a `failed` next to a `succeeded` for the same generation.+ expect(administrativeOutcomeReporter.enqueueHostOutcome).toHaveBeenCalledOnce()+ expect(administrativeOutcomeReporter.enqueueHostOutcome).toHaveBeenCalledWith(+ expect.objectContaining({+ sourceEventId:+ 'hcc-admin-outcome-v2:22222222-2222-4222-8222-222222222222:4:stateless-host-uid:succeeded',+ outcome: 'succeeded',+ })+ )expect(live().spec!.replicas).toBe(1)expect(live().spec!.template).toEqual(applied.spec!.template)expect(vi.mocked(issueMcpHostRuntimeTokens)).not.toHaveBeenCalled()