Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(hcc): ignore controller readiness handshake
Alfredo Lopez122b5da2d9cb
diff --git a/host-context-controller/src/k8sClient.test.ts b/host-context-controller/src/k8sClient.test.tsindex ba373b457..06eb0b336 100644--- a/host-context-controller/src/k8sClient.test.ts+++ b/host-context-controller/src/k8sClient.test.ts@@ -1160,6 +1160,44 @@ describe('McpServerWatcher startup', () => {await watcher.stop()})+ it('does not advance desired revision for the controller-owned network-ready handshake', async () => {+ const previousServer = {+ name: 'network-ready-server',+ namespace: 'mcp-server',+ uid: 'network-ready-server-uid',+ generation: 7,+ annotations: { 'clerum.io/pre-deploy': 'true' },+ labels: { 'clerum.io/workload': 'network-ready-server' },+ spec: {+ contextRef: 'default',+ image: 'clerum/network-ready-server:test',+ transport: { type: 'streamableHttp' as const, port: 3000 },+ },+ }+ const watcher = new McpServerWatcher()+ ;(watcher as any).servers.set(previousServer.name, previousServer)+ const callback = (watcher as any).getMcpServerWatchCallback()++ await callback('MODIFIED', {+ metadata: {+ name: previousServer.name,+ namespace: previousServer.namespace,+ uid: previousServer.uid,+ generation: previousServer.generation,+ annotations: {+ ...previousServer.annotations,+ 'clerum.io/network-ready': 'true',+ },+ labels: previousServer.labels,+ },+ spec: previousServer.spec,+ })++ expect((watcher as any).mcpServerDesiredRevision).toBe(0)+ expect((watcher as any).reconciler.reconcile).not.toHaveBeenCalled()+ await watcher.stop()+ })+it('advances McpServer desired revision for owner addition and deletion', async () => {const serverObject = {metadata: {diff --git a/host-context-controller/src/mcpServerSafety.test.ts b/host-context-controller/src/mcpServerSafety.test.tsindex ce4e3bcb7..d68d7f029 100644--- a/host-context-controller/src/mcpServerSafety.test.ts+++ b/host-context-controller/src/mcpServerSafety.test.ts@@ -93,6 +93,19 @@ describe('sameMcpServerDesiredRevision', () => {)).toBe(false)})++ it('ignores the controller-owned network-ready handshake annotation', () => {+ const expected = makeServer({ annotations: { 'clerum.io/pre-deploy': 'true' } })+ const current = makeServer({+ annotations: {+ 'clerum.io/pre-deploy': 'true',+ 'clerum.io/network-ready': 'true',+ },+ })++ expect(sameMcpServerDesiredRevision(expected, current)).toBe(true)+ expect(sameMcpServerDesiredRevision(current, expected)).toBe(true)+ })})describe('isMcpServerStatusOnlyUpdate', () => {@@ -122,6 +135,18 @@ describe('isMcpServerStatusOnlyUpdate', () => {expect(isMcpServerStatusOnlyUpdate(previous, current)).toBe(false)})++ it('treats the controller-owned network-ready handshake as a status-only update', () => {+ const previous = makeServer({ annotations: { 'clerum.io/pre-deploy': 'true' } })+ const current = makeServer({+ annotations: {+ 'clerum.io/pre-deploy': 'true',+ 'clerum.io/network-ready': 'true',+ },+ })++ expect(isMcpServerStatusOnlyUpdate(previous, current)).toBe(true)+ })})describe('confirmAuthoritativeMcpServerAbsence', () => {diff --git a/host-context-controller/src/mcpServerSafety.ts b/host-context-controller/src/mcpServerSafety.tsindex 1cad6c02a..cacbbe2a4 100644--- a/host-context-controller/src/mcpServerSafety.ts+++ b/host-context-controller/src/mcpServerSafety.ts@@ -1,6 +1,21 @@import type { McpServerCRD } from './types'import { getErrorCode } from './utils'+const NETWORK_READY_ANNOTATION = 'clerum.io/network-ready'++/**+ * This acknowledgement is written by HCC after it has applied a server's+ * NetworkPolicies so WRC can admit its workload. It is not user intent and it+ * cannot change any NetworkPolicy decision. Treating that write as desired+ * state makes HCC invalidate its own authoritative revocation pass under a+ * large startup fleet, coupling /ready to additive runtime convergence again.+ */+function desiredAnnotations(annotations: Record<string, string> | undefined): Record<string, string> {+ if (!annotations?.[NETWORK_READY_ANNOTATION]) return annotations ?? {}+ const { [NETWORK_READY_ANNOTATION]: _networkReady, ...remaining } = annotations+ return remaining+}+export function sameMcpServerDesiredRevision(expected: McpServerCRD,current: McpServerCRD@@ -17,7 +32,8 @@ export function sameMcpServerDesiredRevision(return (JSON.stringify(expected.spec) === JSON.stringify(current.spec) &&- JSON.stringify(expected.annotations ?? {}) === JSON.stringify(current.annotations ?? {}) &&+ JSON.stringify(desiredAnnotations(expected.annotations)) ===+ JSON.stringify(desiredAnnotations(current.annotations)) &&JSON.stringify(expected.labels ?? {}) === JSON.stringify(current.labels ?? {}))}