Skip to content

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

TypeScript

test(wrc): prove the run-lane apply tolerates apiserver default-fill

Alfredo Lopez2a2431ab3556
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 79bb6a1c6..5de778a86 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.385",
+ "version": "0.1.386",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.385",
+ "version": "0.1.386",
"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 daaa3e2a9..8b46b3b89 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.385",
+ "version": "0.1.386",
"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 73d3accc6..39e6513cb 100644
--- a/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts
+++ b/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts
@@ -2991,6 +2991,58 @@ describe('WorkflowReconciler — reconcile loop', () => {
}
})
+ // The factory always sends policyTypes and port protocols, so the reconcile
+ // tests above never depend on the apiserver default tolerance. This drives the
+ // run-lane apply directly with a policy that omits both.
+ it('leaves a policy unchanged when the apiserver filled the defaults the desired omits', async () => {
+ const logs = captureRunLaneNetworkPolicyLogs()
+ try {
+ const { api, live, key } = makeApiserverNetworkingApi()
+ const reconciler = new WorkflowReconciler(makeDeps({ networkingApi: api as never }))
+ const applyNetworkPolicy = (
+ reconciler as unknown as {
+ applyNetworkPolicy(policy: k8s.V1NetworkPolicy): Promise<unknown>
+ }
+ ).applyNetworkPolicy.bind(reconciler)
+ const name = 'test-wf-defaults-omitted'
+ const desired = (): k8s.V1NetworkPolicy => ({
+ apiVersion: 'networking.k8s.io/v1',
+ kind: 'NetworkPolicy',
+ metadata: {
+ name,
+ namespace: 'sandbox-recipes',
+ labels: { 'clerum.io/managed-by': 'wrc', 'clerum.io/recipe': 'test-wf' },
+ },
+ spec: {
+ podSelector: { matchLabels: { app: 'test-wf-coordinator' } },
+ egress: [{ ports: [{ port: 443 }] }],
+ },
+ })
+
+ expect(await applyNetworkPolicy(desired())).toEqual({ policy: name, action: 'created' })
+ const stored = live.get(key('sandbox-recipes', name))
+ expect(stored?.spec?.policyTypes).toEqual(['Ingress', 'Egress'])
+ expect(stored?.spec?.egress?.[0]?.ports?.[0]?.protocol).toBe('TCP')
+
+ api.createNamespacedNetworkPolicy.mockClear()
+ api.readNamespacedNetworkPolicy.mockClear()
+ api.replaceNamespacedNetworkPolicy.mockClear()
+ logs.entries.length = 0
+
+ expect(await applyNetworkPolicy(desired())).toEqual({ policy: name, action: 'unchanged' })
+ expect(readPolicyNames(api)).toEqual([name])
+ expect(api.createNamespacedNetworkPolicy).toHaveBeenCalledTimes(0)
+ expect(api.replaceNamespacedNetworkPolicy).toHaveBeenCalledTimes(0)
+ expect(
+ logs.entries.filter(entry =>
+ String(entry.msg).includes(`Unchanged NetworkPolicy "${name}"`)
+ )
+ ).toHaveLength(1)
+ } finally {
+ logs.restore()
+ }
+ })
+
it('replaces exactly the drifted policy with its live resourceVersion', async () => {
const { api, live, key } = makeApiserverNetworkingApi()
const reconciler = new WorkflowReconciler(makeDeps({ networkingApi: api as never }))