Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(wrc): log the resolved egress set so the WRC lane has a history (#299)
Alfredo Lopeza360f52bd3c1
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex 8f868668f..f6ecaecef 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.319",+ "version": "0.1.320","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.319",+ "version": "0.1.320","license": "SEE LICENSE IN LICENSE","dependencies": {"@aws-sdk/client-s3": "^3.1009.0",diff --git a/workflow-recipes/package.json b/workflow-recipes/package.jsonindex bf6ead106..1170ed03a 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.319",+ "version": "0.1.320","description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface","main": "dist/main.js","engines": {diff --git a/workflow-recipes/src/reconciler/reconciler.test.ts b/workflow-recipes/src/reconciler/reconciler.test.tsindex f17cc671f..d0ee242f5 100644--- a/workflow-recipes/src/reconciler/reconciler.test.ts+++ b/workflow-recipes/src/reconciler/reconciler.test.ts@@ -3856,6 +3856,90 @@ describe('WorkflowRecipeReconciler', () => {expect(npCall.body.spec.egress).toHaveLength(2) // internal + external})+ // issue #299 — the WRC lane must leave a resolution history in the log.+ //+ // HCC has emitted `[NetPol] Resolved <fqdn> → [ips]` since its initial commit,+ // so its lane can be reconstructed from Cloud Logging: which addresses a host+ // used over weeks, whether its universe is closed, whether it drifts. WRC had+ // no equivalent, so `wl-egress-*` and `ui-egress-*` were observable only in+ // the present through the live annotation — and that is exactly the lane where+ // the currently-exposed hosts sit. These tests pin both the emission and its+ // change-gating, since the value of the line is the history it accumulates.+ it('logs the resolved egress set for the ui lane on first render', async () => {+ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})+ const kc = new k8s.KubeConfig()+ const rec = new WorkflowRecipeReconciler(kc, undefined, {+ fqdnLookup: async () => ({+ kind: 'ok',+ ipv4: ['93.184.216.10', '93.184.216.11'],+ ipv6: [],+ ttlSeconds: 300,+ }),+ })+ const recipe = makeRecipe({+ spec: {+ workloads: [{ id: 'frontend', type: 'deployment', image: 'fe:1', port: 8080 }],+ ui: {+ workloadRef: 'frontend',+ port: 8080,+ egress: { external: [{ fqdn: 'api.stripe.com', port: 443 }] },+ },+ },+ })++ await rec.reconcile(recipe)++ // Both IPs, sorted, on one line — the shape Cloud Logging can be parsed back+ // into a per-host time series.+ expect(logSpy).toHaveBeenCalledWith(+ expect.stringContaining('Resolved egress set for ui-egress-test-recipe')+ )+ const line = logSpy.mock.calls+ .map(c => String(c[0]))+ .find(s => s.includes('Resolved egress set for'))+ expect(line).toContain('93.184.216.10')+ expect(line).toContain('93.184.216.11')+ })++ it('does NOT re-log when the resolved set is unchanged', async () => {+ // The line is gated on acc.changed — the same predicate the H4 no-op gate+ // uses — so a logged line and a written policy stay in step. Without the+ // gate this would emit on every poll: HCC's ungated equivalent accounts for+ // 176 of 1510 log lines in a 3-minute sample, which is volume without+ // information.+ const kc = new k8s.KubeConfig()+ const rec = new WorkflowRecipeReconciler(kc, undefined, {+ fqdnLookup: async () => ({ kind: 'ok', ipv4: ['93.184.216.10'], ipv6: [], ttlSeconds: 300 }),+ })+ const recipe = makeRecipe({+ spec: {+ workloads: [{ id: 'frontend', type: 'deployment', image: 'fe:1', port: 8080 }],+ ui: {+ workloadRef: 'frontend',+ port: 8080,+ egress: { external: [{ fqdn: 'api.stripe.com', port: 443 }] },+ },+ },+ })++ await rec.reconcile(recipe)+ // Feed the first render back as the live policy, exactly as the H-E test+ // below does — no hand-built fixture.+ const created = mockNetworkingApi.createNamespacedNetworkPolicy.mock.calls+ .map(c => (c[0] as { body: k8s.V1NetworkPolicy }).body)+ .find(b => b.metadata?.name === 'ui-egress-test-recipe')+ expect(created).toBeDefined()+ mockNetworkingApi.readNamespacedNetworkPolicy.mockResolvedValue(created!)++ const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})+ await rec.reconcile(recipe)++ const relogged = logSpy.mock.calls+ .map(c => String(c[0]))+ .filter(s => s.includes('Resolved egress set for ui-egress-test-recipe'))+ expect(relogged).toHaveLength(0)+ })+// H-E (audit): a rename of the external FQDN onto the SAME resolved IP/port// renders identical spec.egress, so the egress-signature gate alone would no-op// and discard the re-attributed state annotation. acc.changed must force thediff --git a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts b/workflow-recipes/src/reconciler/workflowRecipeReconciler.tsindex 32682cfe8..7a78d66f0 100644--- a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts+++ b/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts@@ -4749,6 +4749,34 @@ export class WorkflowRecipeReconciler {* alarm cap and least-recently-observed entries were dropped (H3).*/private warnEgressAccumulator(policyName: string, acc: AccumulateOutput): void {+ // issue #299 — the resolved set, so the WRC lane leaves a history.+ //+ // WHY THIS EXISTS. HCC has emitted `[NetPol] Resolved <fqdn> → [ips]` since+ // its initial commit (networkPolicyReconciler.ts), so its lane has a+ // reconstructable 28-day record in Cloud Logging: which addresses a host+ // used, whether the set is closed, whether it drifts. WRC gained its own+ // resolution path later and never got the equivalent line, so `wl-egress-*`+ // and `ui-egress-*` were observable only in the present, through the live+ // annotation. That is the lane where the currently-exposed hosts live, so+ // the half of the fleet that needs history is the half that had none.+ //+ // WHY ONLY ON CHANGE. HCC logs every resolution: 176 of 1510 log lines in a+ // 3-minute sample. Copying that verbatim would add the same volume here for+ // no extra information — the useful event is the set CHANGING, not the poll+ // that confirmed it did not. `acc.changed` is exactly that predicate+ // ((fqdn,ip,port,protocol), timestamp-only refreshes excluded), which is+ // also what the H4 no-op gate keys on, so a logged line and a written policy+ // stay in step.+ //+ // Called from BOTH lanes (ui and workload) on purpose: one emitter, not a+ // copy per path.+ if (acc.changed && acc.entries.length > 0) {+ const ips = acc.entries+ .map(e => e.ip)+ .filter((ip, i, all) => all.indexOf(ip) === i)+ .sort()+ console.log(`[WR-Reconciler] Resolved egress set for ${policyName} → [${ips.join(', ')}]`)+ }if (acc.frozenFqdns.length > 0) {console.warn(`[WR-Reconciler] ${policyName}: egress set FROZEN (fail-static) for ${acc.frozenFqdns.join(