Skip to content

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

TypeScript

fix(wrc): give a 404 on the run-lane NetworkPolicy replace its own reason

Alfredo Lopez590538c5f86d
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 704755935..6cf314817 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.393",
+ "version": "0.1.394",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.393",
+ "version": "0.1.394",
"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 e12985001..70f004902 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.393",
+ "version": "0.1.394",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/src/workflow/workflowReconciler.ts b/workflow-recipes/src/workflow/workflowReconciler.ts
index 9f1ec95c6..59486ccb3 100644
--- a/workflow-recipes/src/workflow/workflowReconciler.ts
+++ b/workflow-recipes/src/workflow/workflowReconciler.ts
@@ -217,7 +217,11 @@ type RunLaneNetworkPolicyApplyResult =
| {
policy: string
action: 'retry'
- reason: 'terminating' | 'absent-after-write-conflict' | 'replace-conflicted-twice'
+ reason:
+ | 'terminating'
+ | 'absent-after-write-conflict'
+ | 'deleted-before-replace'
+ | 'replace-conflicted-twice'
}
| { policy: string; action: 'conflict'; reason: NetworkPolicyConflictReason }
const MCP_HOST_READINESS_WAIT_TIMEOUT_MS = 4 * 60_000
@@ -4885,8 +4889,9 @@ export class WorkflowReconciler {
return { policy: name, action: 'replaced' }
} catch (error: unknown) {
const code = getErrorCode(error)
- // Deleted between the read and the PUT: the next pass recreates it.
- if (code === 404) return this.networkPolicyAbsentAfterConflict(name, namespace)
+ // Deleted between the read and the PUT: no conflict happened, so
+ // this is its own retry reason.
+ if (code === 404) return this.networkPolicyDeletedBeforeReplace(name, namespace)
// A stale resourceVersion gets one re-read and re-decision.
if (code !== 409) throw error
if (attempt === 1) {
@@ -4917,16 +4922,31 @@ export class WorkflowReconciler {
throw new Error(`NetworkPolicy "${name}" apply loop exited without a result`)
}
+ // Both retries below leave the policy absent. The recipe reconciler's
+ // in-progress and active short-circuits return before this apply, so the
+ // message names the first pass that reaches it, not the next pass.
private networkPolicyAbsentAfterConflict(
name: string,
namespace: string
): RunLaneNetworkPolicyApplyResult {
- this.log.warn(`NetworkPolicy "${name}" vanished after a write conflict; retrying later`, {
- namespace,
- })
+ this.log.warn(
+ `NetworkPolicy "${name}" vanished after a write conflict; a later pass that reaches the apply recreates it`,
+ { namespace, reason: 'absent-after-write-conflict' }
+ )
return { policy: name, action: 'retry', reason: 'absent-after-write-conflict' }
}
+ private networkPolicyDeletedBeforeReplace(
+ name: string,
+ namespace: string
+ ): RunLaneNetworkPolicyApplyResult {
+ this.log.warn(
+ `NetworkPolicy "${name}" was deleted before the replace; a later pass that reaches the apply recreates it`,
+ { namespace, reason: 'deleted-before-replace' }
+ )
+ return { policy: name, action: 'retry', reason: 'deleted-before-replace' }
+ }
+
private async safeDelete(deleteFn: () => Promise<unknown>): Promise<void> {
try {
await deleteFn()
diff --git a/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts b/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts
index cca0e406d..c879f60d4 100644
--- a/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts
+++ b/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts
@@ -3850,14 +3850,17 @@ describe('WorkflowReconciler — reconcile loop', () => {
expect(second.phase).not.toBe('failed')
expect(second.workflowPhase).not.toBe('failed')
expect(second.networkPolicyRetryPending).toBe(true)
+ // No write conflict happened: the PUT itself answered 404.
expect(
- logs.entries.some(
- entry =>
- entry.level === 'warn' &&
- String(entry.msg).includes('test-wf-coord-to-wrc') &&
- String(entry.msg).includes('vanished')
+ logs.entries.filter(
+ entry => entry.level === 'warn' && String(entry.msg).includes('test-wf-coord-to-wrc')
)
- ).toBe(true)
+ ).toEqual([
+ expect.objectContaining({
+ reason: 'deleted-before-replace',
+ msg: 'NetworkPolicy "test-wf-coord-to-wrc" was deleted before the replace; a later pass that reaches the apply recreates it',
+ }),
+ ])
} finally {
logs.restore()
}
@@ -3896,13 +3899,15 @@ describe('WorkflowReconciler — reconcile loop', () => {
expect(second.workflowPhase).not.toBe('failed')
expect(second.networkPolicyRetryPending).toBe(true)
expect(
- logs.entries.some(
- entry =>
- entry.level === 'warn' &&
- String(entry.msg).includes('test-wf-coord-to-wrc') &&
- String(entry.msg).includes('vanished')
+ logs.entries.filter(
+ entry => entry.level === 'warn' && String(entry.msg).includes('test-wf-coord-to-wrc')
)
- ).toBe(true)
+ ).toEqual([
+ expect.objectContaining({
+ reason: 'absent-after-write-conflict',
+ msg: 'NetworkPolicy "test-wf-coord-to-wrc" vanished after a write conflict; a later pass that reaches the apply recreates it',
+ }),
+ ])
} finally {
logs.restore()
}