Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(wrc): requeue when the mcp-host Service replace conflicts twice
Alfredo Lopez496ad8eca7dc
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex 9ccb0173f..7617292a8 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.371",+ "version": "0.1.372","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.371",+ "version": "0.1.372","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 7c16112ed..bc2495ef8 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.371",+ "version": "0.1.372","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.tsindex 56f8eda77..cb813446c 100644--- a/workflow-recipes/src/workflow/workflowReconciler.ts+++ b/workflow-recipes/src/workflow/workflowReconciler.ts@@ -3883,7 +3883,16 @@ export class WorkflowReconciler {this.log.info(`Updated Headless Service "${name}"`)return} catch (error: unknown) {- if (getErrorCode(error) !== 409 || attempt === 1) throw error+ if (getErrorCode(error) !== 409) throw error+ if (attempt === 1) {+ // Contention, not a defect: another writer changed the Service again+ // between the re-read and the retry. Ask for a fresh pass instead of+ // failing the run, as the vanished-after-conflict path does.+ throw new RetryableReconcileError(+ `Headless Service "${name}" replace conflicted on both attempts; a fresh reconciliation is required`,+ { cause: error }+ )+ }const reread = await this.readServiceIfExists(name, namespace)if (!reread) {throw new RetryableReconcileError(diff --git a/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts b/workflow-recipes/tests/unit/workflow/workflowReconciler.test.tsindex c6a16fe5e..a5af041d9 100644--- a/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts+++ b/workflow-recipes/tests/unit/workflow/workflowReconciler.test.ts@@ -3120,15 +3120,23 @@ describe('WorkflowReconciler — reconcile loop', () => {)})- it('fails the pass when the replace conflicts on both attempts', async () => {+ it('asks for a fresh pass, without failing, when the replace conflicts on both attempts', async () => {serveMcpHostReads(driftedMcpHost('rv-7'), driftedMcpHost('rv-8'))conflictOnFirstReplaces(2)const result = await reconcileTriggeredRun()expect(serviceReadsOf(deps, mcpHostName)).toBe(2)- expect(replaceCalls()).toHaveLength(2)- expect(result.workflowPhase).toBe('failed')+ expect(replaceCalls().map(([arg]) => arg.body.metadata?.resourceVersion)).toEqual([+ 'rv-7',+ 'rv-8',+ ])+ expect(result.workflowPhase).not.toBe('failed')+ expect(result.phase).not.toBe('failed')+ expect(result.skipStatusPatch).toBe(true)+ expect(result.message).toContain(+ `Headless Service "${mcpHostName}" replace conflicted on both attempts`+ )})it('propagates a replace error other than a conflict without retrying', async () => {