Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(hcc): pin the controller Deployment to Recreate to hold single-writer
Alfredo Lopezd6c0ee8ba916
diff --git a/deploy/base/control-plane/host-context-controller.yaml b/deploy/base/control-plane/host-context-controller.yamlindex 31d171eb6..72b86f960 100644--- a/deploy/base/control-plane/host-context-controller.yaml+++ b/deploy/base/control-plane/host-context-controller.yaml@@ -13,6 +13,16 @@ metadata:app: host-context-controllerspec:replicas: 1+ # HCC's safety model assumes a single NetworkPolicy writer: replicas:1 with no+ # leader election (see statelessLifecycleExecutor.ts). RollingUpdate (the+ # default) starts the new pod before terminating the old one, so every rollout+ # would overlap two writers — during which the outgoing replica can win a+ # conflict-retry replace and land its wider spec back over a policy the new+ # replica just hardened and certified, with no NetworkPolicy resync to heal it+ # and /ready still 200. Recreate terminates the old pod first, honouring the+ # single-writer assumption through the rollout too.+ strategy:+ type: Recreateselector:matchLabels:app: host-context-controllerdiff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 6dda9067c..ef1b54a93 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.199",+ "version": "0.1.200","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.199",+ "version": "0.1.200","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.jsonindex 07761bad5..b75f317f1 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.199",+ "version": "0.1.200","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/deploymentStrategy.test.ts b/host-context-controller/src/deploymentStrategy.test.tsnew file mode 100644index 000000000..655fd4a11--- /dev/null+++ b/host-context-controller/src/deploymentStrategy.test.ts@@ -0,0 +1,45 @@+import { describe, expect, it } from 'vitest'+import { loadAll } from 'js-yaml'+import { readFileSync } from 'node:fs'+import path from 'node:path'++/**+ * HCC's safety model assumes a single writer: replicas:1 with NO leader+ * election (see statelessLifecycleExecutor.ts — "Running >1 replica risks two+ * controllers racing"). The default Deployment strategy is RollingUpdate with+ * maxSurge>0, which starts the new pod before the old one exits — a guaranteed+ * two-replica overlap on every rollout. During that window the outgoing replica+ * can win a conflict-retry replace (applyNetworkPolicy → replaceWithConflictRetry)+ * and land its wider spec back over a policy the new replica just hardened and+ * certified. There is no NetworkPolicy watch or periodic resync to heal it, and+ * the new replica's safety fence only sees failures in its own process — so+ * /ready stays 200 over a stale allow. Recreate closes the overlap, which is the+ * only way to honour the documented single-writer assumption during a rollout.+ */+describe('host-context-controller Deployment strategy', () => {+ const docs = loadAll(+ readFileSync(+ path.join(__dirname, '../../deploy/base/control-plane/host-context-controller.yaml'),+ 'utf8'+ )+ ) as Array<{ kind?: string; metadata?: { name?: string }; spec?: Record<string, unknown> }>++ const deployment = docs.find(+ d => d?.kind === 'Deployment' && d?.metadata?.name === 'host-context-controller'+ )++ it('defines the host-context-controller Deployment', () => {+ expect(deployment).toBeDefined()+ })++ it('runs a single replica', () => {+ expect(deployment?.spec?.replicas).toBe(1)+ })++ it('uses Recreate so a rollout never overlaps two writers', () => {+ // RollingUpdate (the default) would start the new pod before terminating the+ // old one; with no leader election that races two NetworkPolicy writers.+ const strategy = deployment?.spec?.strategy as { type?: string } | undefined+ expect(strategy?.type).toBe('Recreate')+ })+})