Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(hcc): gate the workspace layout merge init behind a config flag
Alfredo Lopez7072ccbcaaf6
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex ff63c4035..ce2071261 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.384",+ "version": "0.1.385","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.384",+ "version": "0.1.385","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 eefa0f2ba..451d7351a 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.384",+ "version": "0.1.385","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.tsindex fd7697a4b..a38396937 100644--- a/host-context-controller/src/config.ts+++ b/host-context-controller/src/config.ts@@ -206,6 +206,10 @@ export interface Config {// budget. Integer 1..8, default 2 (see parseHostFullReconcileConcurrency).hostFullReconcileConcurrency: number+ // Render the `workspace-layout-merge` init on every Host (see+ // parseWorkspaceLayoutMerge). Default true.+ workspaceLayoutMerge: boolean+// Periodic SharedFileSystem fullReconcile interval (seconds). The SFS watch// fires only on SFS CRD changes, not on PVC binding / wfc pod readiness, so// this drives truthful-status auto-recovery (#592): a SharedFileSystem stuck@@ -389,6 +393,22 @@ export function parseHostFullReconcileConcurrency(raw: string | undefined): numbreturn parsed}+/**+ * CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE — whether Host Deployments render the+ * `workspace-layout-merge` init that moves a PVC split by the earlier stateless+ * layout back to the root layout. The merge is needed once per Host; a cluster+ * turns it off once every Host has started with it. Unset or empty means true,+ * so a deploy that ships this HCC merges without an overlay change. Only the+ * exact strings 'true' and 'false' are accepted: a typo read as false would+ * start split Hosts on an empty database without any error.+ */+export function parseWorkspaceLayoutMerge(raw: string | undefined): boolean {+ if (raw === undefined || raw === '') return true+ if (raw === 'true') return true+ if (raw === 'false') return false+ throw new Error(`CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE must be 'true' or 'false', got '${raw}'`)+}+export function validateRemovedStatelessCommunicationChannelPolicy(raw: string | undefined): void {if (raw === undefined || raw.trim() === '') returnthrow new Error(@@ -816,6 +836,9 @@ export const config: Config = {hostFullReconcileConcurrency: parseHostFullReconcileConcurrency(getEnv('HCC_HOST_FULL_RECONCILE_CONCURRENCY')),+ workspaceLayoutMerge: parseWorkspaceLayoutMerge(+ process.env.CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE+ ),// Periodic SharedFileSystem resync (default 60s). Re-evaluates PVC bind + wfc// readiness so a transient Initializing/Degraded converges to Ready (#592).diff --git a/host-context-controller/src/hostReconciler.ts b/host-context-controller/src/hostReconciler.tsindex f11f4740b..d7ca0d993 100644--- a/host-context-controller/src/hostReconciler.ts+++ b/host-context-controller/src/hostReconciler.ts@@ -3814,16 +3814,19 @@ export class HostReconciler {imagePullSecrets: config.hostImagePullSecretName? [{ name: config.hostImagePullSecretName }]: undefined,- // Every Host merges a PVC split by the earlier stateless layout- // back to the root layout before mcp-host starts; on any other- // tree the init exits 0 without touching it.- initContainers: [- buildWorkspaceLayoutMergeContainer(- image,- imagePullPolicy,- hostContainerSecurityContext()- ),- ],+ // While CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE is on, every Host+ // merges a PVC split by the earlier stateless layout back to the+ // root layout before mcp-host starts; on any other tree the init+ // exits 0 without touching it.+ initContainers: config.workspaceLayoutMerge+ ? [+ buildWorkspaceLayoutMergeContainer(+ image,+ imagePullPolicy,+ hostContainerSecurityContext()+ ),+ ]+ : undefined,containers: [{name: 'mcp-host',diff --git a/host-context-controller/test/config.workspaceLayoutMerge.test.ts b/host-context-controller/test/config.workspaceLayoutMerge.test.tsnew file mode 100644index 000000000..019457bd2--- /dev/null+++ b/host-context-controller/test/config.workspaceLayoutMerge.test.ts@@ -0,0 +1,48 @@+import { afterEach, describe, expect, it, vi } from 'vitest'+import { parseWorkspaceLayoutMerge } from '../src/config'++describe('parseWorkspaceLayoutMerge', () => {+ it('defaults to true when the env var is unset or empty', () => {+ expect(parseWorkspaceLayoutMerge(undefined)).toBe(true)+ expect(parseWorkspaceLayoutMerge('')).toBe(true)+ })++ it('accepts exactly true and false', () => {+ expect(parseWorkspaceLayoutMerge('true')).toBe(true)+ expect(parseWorkspaceLayoutMerge('false')).toBe(false)+ })++ it.each(['ture', 'yes', '1', '0', 'TRUE', 'False', 'off', 'false ', ' true'])(+ 'refuses %j instead of guessing',+ raw => {+ expect(() => parseWorkspaceLayoutMerge(raw)).toThrow(+ `CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE must be 'true' or 'false', got '${raw}'`+ )+ }+ )+})++describe('config.workspaceLayoutMerge', () => {+ afterEach(() => {+ delete process.env.CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE+ vi.resetModules()+ })++ it('is enabled when the env var is absent', async () => {+ const { config } = await import('../src/config')+ expect(config.workspaceLayoutMerge).toBe(true)+ })++ it('is disabled by an explicit false', async () => {+ process.env.CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE = 'false'+ const { config } = await import('../src/config')+ expect(config.workspaceLayoutMerge).toBe(false)+ })++ it('fails config load on an invalid value', async () => {+ process.env.CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE = 'ture'+ await expect(import('../src/config')).rejects.toThrow(+ /CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE must be 'true' or 'false'/+ )+ })+})diff --git a/host-context-controller/test/hostReconciler.lifecycle.test.ts b/host-context-controller/test/hostReconciler.lifecycle.test.tsindex 807702749..f5dd061bb 100644--- a/host-context-controller/test/hostReconciler.lifecycle.test.ts+++ b/host-context-controller/test/hostReconciler.lifecycle.test.ts@@ -58,6 +58,7 @@ vi.mock('../src/config', () => ({hostWorkspaceStorageClassName: 'do-block-storage-retain',hostWorkspaceStorageSize: '10Gi',hostWorkspacePath: '/workspace',+ workspaceLayoutMerge: true,hostResources: {requests: { memory: '128Mi', cpu: '100m' },limits: { memory: '512Mi', cpu: '500m' },@@ -5209,6 +5210,33 @@ describe('HostReconciler storage layout — one shape for every lifecycle', () ='workspace-layout-merge',])})++ describe('with CONTEXT_MAPPER_WORKSPACE_LAYOUT_MERGE=false', () => {+ afterEach(() => {+ config.workspaceLayoutMerge = true+ })++ it.each(kinds)(+ 'renders no merge init and keeps the root layout for a $kind Host',+ ({ host, workspacePath }) => {+ const { reconciler } = createReconciler()+ // Witness: with the flag on, the same Host renders the merge init.+ expect(+ reconciler.buildDeployment(host()).spec?.template?.spec?.initContainers?.map(i => i.name)+ ).toEqual(['workspace-layout-merge'])++ config.workspaceLayoutMerge = false+ const dep = reconciler.buildDeployment(host())+ expect(dep.spec?.template?.spec?.initContainers).toBeUndefined()+ expect(dep.spec?.template?.spec?.containers?.[0]?.volumeMounts).toContainEqual({+ name: 'workspace',+ mountPath: workspacePath,+ })+ expect(envValue(dep, 'CLERUM_SESSION_DB_DIR')).toBe(workspacePath)+ expect(JSON.stringify(dep)).not.toContain('subPath')+ }+ )+ })})describe('HostReconciler stateless lifecycle — suspension durability', () => {