Skip to content

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

TypeScript

test(wrc): pin the DNS-failure prune against a terminating NetworkPolicy

Alfredo Lopez809fc95b7524
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index f2f146703..c79609199 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.376",
+ "version": "0.1.377",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.376",
+ "version": "0.1.377",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
diff --git a/workflow-recipes/package.json b/workflow-recipes/package.json
index 8ebe94a41..0bdd0ec91 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.376",
+ "version": "0.1.377",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts b/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts
index 67e55daa3..51eaf3500 100644
--- a/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts
+++ b/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts
@@ -2296,6 +2296,81 @@ describe('WorkflowReconciler — reconcile loop', () => {
})
})
+ it('leaves a terminating policy unwritten on the DNS-failure prune and still rejects with the DNS error', async () => {
+ const logs = captureRunLaneNetworkPolicyLogs()
+ try {
+ const networkingApi = makeNetworkingApi() as ReturnType<typeof makeNetworkingApi>
+ const activePreviousExpiresAt = new Date(Date.now() + 5 * 60 * 1000).toISOString()
+ networkingApi.readNamespacedNetworkPolicy.mockResolvedValue({
+ metadata: {
+ resourceVersion: 'rv-1',
+ deletionTimestamp: new Date('2026-09-23T10:00:00.000Z'),
+ annotations: {
+ 'clerum.io/runtime-http-egress-current-cidrs': '93.184.216.36/32',
+ 'clerum.io/runtime-http-egress-previous-cidrs': '93.184.216.34/32,93.184.216.35/32',
+ 'clerum.io/runtime-http-egress-previous-expires-at': activePreviousExpiresAt,
+ 'clerum.io/runtime-http-egress-previous-cidr-expiries': JSON.stringify({
+ '93.184.216.34/32': '2000-01-01T00:00:00.000Z',
+ '93.184.216.35/32': activePreviousExpiresAt,
+ }),
+ },
+ },
+ })
+ const reconciler = new WorkflowReconciler(
+ makeDeps({
+ networkingApi: networkingApi as never,
+ resolveRuntimeHttpEgressCidrs: vi.fn().mockRejectedValue(new Error('ENOTFOUND')),
+ config: { ...makeConfig(), enableSnippetRuntime: true } as never,
+ })
+ )
+ const spec = makeSpec({
+ agent: undefined,
+ runtimeEgress: { http: { allowedHosts: ['api.example.com'] } },
+ steps: [
+ {
+ id: 'snippet',
+ run: {
+ type: 'snippet',
+ language: 'typescript',
+ code: 'return await sdk.http.fetchJson("https://api.example.com/data")',
+ capabilities: {
+ http: { allowedHosts: ['api.example.com'] },
+ },
+ },
+ },
+ ],
+ })
+
+ await expect(
+ reconciler.refreshRuntimeHttpEgressNetworkPolicies(
+ 'sandbox-recipes',
+ 'test-wf',
+ 'uid-123',
+ spec
+ )
+ ).rejects.toThrow('ENOTFOUND')
+
+ expect(
+ networkingApi.readNamespacedNetworkPolicy.mock.calls.filter(
+ ([arg]) => (arg as { name: string }).name === 'test-wf-snippet-runner-egress'
+ ).length
+ ).toBeGreaterThanOrEqual(2)
+ expect(
+ logs.entries.some(
+ entry =>
+ entry.level === 'warn' &&
+ String(entry.msg).includes(
+ 'NetworkPolicy "test-wf-snippet-runner-egress" is terminating'
+ )
+ )
+ ).toBe(true)
+ expect(networkingApi.replaceNamespacedNetworkPolicy).toHaveBeenCalledTimes(0)
+ expect(networkingApi.createNamespacedNetworkPolicy).toHaveBeenCalledTimes(0)
+ } finally {
+ logs.restore()
+ }
+ })
+
it('creates runtime HTTP egress policies without previous overlap on first refresh', async () => {
const networkingApi = makeNetworkingApi() as ReturnType<typeof makeNetworkingApi>
networkingApi.readNamespacedNetworkPolicy.mockRejectedValue({ code: 404 })