Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(hcc): enforce the single-writer rollout invariant on the rendered manifest
Alfredo Lopez9f7264e7b7d5
diff --git a/deploy/scripts/validate-postgres-single-writer-strategy.sh b/deploy/scripts/validate-postgres-single-writer-strategy.shindex f1a77091c..3a989705f 100755--- a/deploy/scripts/validate-postgres-single-writer-strategy.sh+++ b/deploy/scripts/validate-postgres-single-writer-strategy.sh@@ -2,15 +2,24 @@set -euo pipefailROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"-OVERLAYS=(- "deploy/overlays/minikube"- "deploy/overlays/gcp-dev"- "deploy/overlays/gcp-prod"-)+# Overlays to render. Defaults to the full production set; the gcp-* overlays+# live in keyper-labs/evenfire-infra, so this script's full coverage runs there.+# Override (space-separated) to validate only the overlays present in a given+# checkout — e.g. SINGLE_WRITER_OVERLAYS="deploy/overlays/minikube" in this repo.+read -r -a OVERLAYS <<<"${SINGLE_WRITER_OVERLAYS:-deploy/overlays/minikube deploy/overlays/gcp-dev deploy/overlays/gcp-prod}"DATABASE_DEPLOYS=("control-plane/control-postgres""registry/registry-postgres")+# Deployments whose safety model assumes a single writer with NO leader election+# (see host-context-controller/src/statelessLifecycleExecutor.ts). For these the+# RENDERED manifest — not just deploy/base — must keep replicas<=1 and+# strategy=Recreate with no rollingUpdate residue, or a rollout reopens the+# two-writer NetworkPolicy overlap closed in PR #205. Unlike DATABASE_DEPLOYS+# these mount no PVC, so they need their own list rather than the PVC heuristic.+SINGLE_WRITER_DEPLOYS=(+ "control-plane/host-context-controller"+)fail() {echo "ERROR: $*" >&2@@ -54,6 +63,30 @@ for overlay in "${OVERLAYS[@]}"; dofail "${overlay}: Deployment ${id} uses Recreate and must not render spec.strategy.rollingUpdate"fidone++ for id in "${SINGLE_WRITER_DEPLOYS[@]}"; do+ namespace="${id%%/*}"+ name="${id#*/}"+ deployment="$(+ jq -e --arg namespace "${namespace}" --arg name "${name}" \+ 'first(.[] | select(.kind == "Deployment" and .metadata.namespace == $namespace and .metadata.name == $name))' \+ <<<"${rendered_json}"+ )" || fail "${overlay}: missing Deployment ${id}"++ replicas="$(jq -r '.spec.replicas // 1' <<<"${deployment}")"+ if [ "${replicas}" -gt 1 ]; then+ fail "${overlay}: single-writer Deployment ${id} must keep replicas<=1 (no leader election), got ${replicas}"+ fi++ strategy="$(jq -r '.spec.strategy.type // "RollingUpdate"' <<<"${deployment}")"+ if [ "${strategy}" != "Recreate" ]; then+ fail "${overlay}: single-writer Deployment ${id} must use strategy.type=Recreate, got ${strategy}"+ fi++ if jq -e '.spec.strategy.rollingUpdate != null' >/dev/null <<<"${deployment}"; then+ fail "${overlay}: single-writer Deployment ${id} uses Recreate and must not render spec.strategy.rollingUpdate"+ fi+ donedone-echo "Postgres single-writer rollout strategy validation passed"+echo "Single-writer rollout strategy validation passed"diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex ef1b54a93..0479d26c3 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.200",+ "version": "0.1.201","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.200",+ "version": "0.1.201","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 b75f317f1..190306bd0 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.200",+ "version": "0.1.201","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.tsindex 655fd4a11..f4e25360b 100644--- a/host-context-controller/src/deploymentStrategy.test.ts+++ b/host-context-controller/src/deploymentStrategy.test.ts@@ -42,4 +42,11 @@ describe('host-context-controller Deployment strategy', () => {const strategy = deployment?.spec?.strategy as { type?: string } | undefinedexpect(strategy?.type).toBe('Recreate')})++ it('carries no rollingUpdate block under Recreate', () => {+ // A leftover spec.strategy.rollingUpdate is invalid under Recreate and, if a+ // future edit flipped only `type` back, would quietly reintroduce surge.+ const strategy = deployment?.spec?.strategy as { rollingUpdate?: unknown } | undefined+ expect(strategy?.rollingUpdate).toBeUndefined()+ })})