Skip to content

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

TypeScript

fix(hcc): strip probe timeout/failureThreshold and default serviceAccountName

Alfredo Lopezb11141f5dedd
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index d8379c43d..2cce0454f 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.273",
+ "version": "0.1.274",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.273",
+ "version": "0.1.274",
"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.json
index 421cc7f34..f81478385 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.273",
+ "version": "0.1.274",
"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/__tests__/deploymentMatchesDesired.test.ts b/host-context-controller/src/__tests__/deploymentMatchesDesired.test.ts
index 61fb09255..c0a00d2dd 100644
--- a/host-context-controller/src/__tests__/deploymentMatchesDesired.test.ts
+++ b/host-context-controller/src/__tests__/deploymentMatchesDesired.test.ts
@@ -12,7 +12,11 @@ import {
} from '../../test/__fixtures__/testMocks'
import { HostReconciler } from '../hostReconciler'
import type { HostCRD } from '../types'
-import { deploymentMatchesDesired, preserveDeploymentAnnotations } from '../utils'
+import {
+ deploymentMatchesDesired,
+ normalizeDeploymentForComparison,
+ preserveDeploymentAnnotations,
+} from '../utils'
import { asApiserverDeployment } from './asApiserverDeployment'
import { cloneAndMutateLeaf, collectLeafPaths, formatLeafPath } from './mutateJsonLeaves'
@@ -134,6 +138,90 @@ describe('asApiserverDeployment', () => {
})
})
+type CanonicalPodSpec = {
+ serviceAccountName?: string
+ containers?: Array<{
+ livenessProbe?: { timeoutSeconds?: number; failureThreshold?: number }
+ }>
+}
+
+function canonicalPodSpec(normalized: unknown): CanonicalPodSpec | undefined {
+ return (normalized as { spec?: { template?: { spec?: CanonicalPodSpec } } }).spec?.template?.spec
+}
+
+function deploymentWithProbe(
+ probe: Partial<k8s.V1Probe>,
+ serviceAccountName?: string
+): k8s.V1Deployment {
+ return {
+ apiVersion: 'apps/v1',
+ kind: 'Deployment',
+ metadata: { name: 'probe-guard', namespace: 'ns' },
+ spec: {
+ replicas: 1,
+ selector: { matchLabels: { app: 'probe-guard' } },
+ template: {
+ metadata: { labels: { app: 'probe-guard' } },
+ spec: {
+ ...(serviceAccountName !== undefined ? { serviceAccountName } : {}),
+ containers: [
+ {
+ name: 'c',
+ image: 'img:1',
+ livenessProbe: {
+ httpGet: { path: '/live', port: 80 },
+ periodSeconds: 5,
+ ...probe,
+ },
+ },
+ ],
+ },
+ },
+ },
+ }
+}
+
+describe('safe-strip lemma equality guards', () => {
+ it('strips timeoutSeconds === 1 and keeps a non-default 2', () => {
+ const stripped = canonicalPodSpec(
+ normalizeDeploymentForComparison(deploymentWithProbe({ timeoutSeconds: 1 }))
+ )
+ const kept = canonicalPodSpec(
+ normalizeDeploymentForComparison(deploymentWithProbe({ timeoutSeconds: 2 }))
+ )
+ expect(stripped?.containers?.[0]?.livenessProbe?.timeoutSeconds).toBeUndefined()
+ expect(kept?.containers?.[0]?.livenessProbe?.timeoutSeconds).toBe(2)
+ })
+
+ it('strips failureThreshold === 3 and keeps a non-default 6', () => {
+ const stripped = canonicalPodSpec(
+ normalizeDeploymentForComparison(deploymentWithProbe({ failureThreshold: 3 }))
+ )
+ const kept = canonicalPodSpec(
+ normalizeDeploymentForComparison(deploymentWithProbe({ failureThreshold: 6 }))
+ )
+ expect(stripped?.containers?.[0]?.livenessProbe?.failureThreshold).toBeUndefined()
+ expect(kept?.containers?.[0]?.livenessProbe?.failureThreshold).toBe(6)
+ })
+
+ it("strips serviceAccountName === 'default' and keeps a non-default name", () => {
+ const stripped = canonicalPodSpec(
+ normalizeDeploymentForComparison(deploymentWithProbe({}, 'default'))
+ )
+ const kept = canonicalPodSpec(
+ normalizeDeploymentForComparison(deploymentWithProbe({}, 'clerum-x'))
+ )
+ expect(stripped?.serviceAccountName).toBeUndefined()
+ expect(kept?.serviceAccountName).toBe('clerum-x')
+ })
+
+ it('omitted probe timeout/failure and SA match the apiserver defaults after merge', () => {
+ const desired = deploymentWithProbe({ periodSeconds: 5 })
+ const existing = asApiserverDeployment(desired)
+ expect(deploymentMatchesDesired(mergedForCompare(desired, existing), existing)).toBe(true)
+ })
+})
+
describe('deploymentMatchesDesired', () => {
it('returns false when either spec is missing (fail-open-to-write)', () => {
const desired = sparseDeployment()
diff --git a/host-context-controller/src/utils.ts b/host-context-controller/src/utils.ts
index 864b3f831..326e3a340 100644
--- a/host-context-controller/src/utils.ts
+++ b/host-context-controller/src/utils.ts
@@ -349,6 +349,7 @@ export function normalizeDeploymentForComparison(deployment: k8s.V1Deployment):
if (podSpec.enableServiceLinks === true) delete podSpec.enableServiceLinks
if (podSpec.preemptionPolicy === 'PreemptLowerPriority') delete podSpec.preemptionPolicy
if (podSpec.serviceAccount === podSpec.serviceAccountName) delete podSpec.serviceAccount
+ if (podSpec.serviceAccountName === 'default') delete podSpec.serviceAccountName
if (Object.keys(podSpec.securityContext ?? {}).length === 0) delete podSpec.securityContext
for (const container of [
...(podSpec.initContainers ?? []),
@@ -372,7 +373,9 @@ export function normalizeContainerDefaults(container: k8s.V1Container): void {
for (const probe of [container.startupProbe, container.livenessProbe, container.readinessProbe]) {
if (!probe) continue
if (probe.initialDelaySeconds === 0) delete probe.initialDelaySeconds
+ if (probe.timeoutSeconds === 1) delete probe.timeoutSeconds
if (probe.successThreshold === 1) delete probe.successThreshold
+ if (probe.failureThreshold === 3) delete probe.failureThreshold
if (probe.httpGet?.scheme === 'HTTP') delete probe.httpGet.scheme
}
for (const env of container.env ?? []) {