Skip to content

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

TypeScript

fix(wrc): publish the NetworkPolicy ownership set when the eager host fails after applying

Alfredo Lopez23e9a4656641
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 8f1f49c72..acfb7cd02 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.381",
+ "version": "0.1.382",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.381",
+ "version": "0.1.382",
"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 f188c03ba..0b8cb9cd9 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.381",
+ "version": "0.1.382",
"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.ts
index 8308b6ee3..576ee1329 100644
--- a/workflow-recipes/src/reconciler/reconciler.test.ts
+++ b/workflow-recipes/src/reconciler/reconciler.test.ts
@@ -1543,7 +1543,6 @@ describe('WorkflowRecipeReconciler', () => {
const sdkOnly = stubSdkOnly({
phase: 'failed',
message: 'Plugin Workload SDK promptBridge has no resolvable agent',
- networkPolicies: { conflicts: [], retryPending: false },
})
const result = await reconciler.reconcile(sdkOnlyRecipe([ownershipCondition]))
@@ -1554,6 +1553,51 @@ describe('WorkflowRecipeReconciler', () => {
expect(result).not.toHaveProperty('networkPolicyOwnershipConditions')
})
+ // The mcp-host pod failed after the apply, so the summary is a real
+ // evaluation: a conflict is published and an empty set clears the condition.
+ it('publishes the evaluated set when the eager host fails after applying', async () => {
+ const conflicted = stubSdkOnly({
+ phase: 'failed',
+ message: 'Plugin Workload SDK mcp-host could not start',
+ networkPolicies: {
+ conflicts: [
+ {
+ policy: 'test-recipe-workload-to-mcp-host-sdk-ingress',
+ reason: 'owner-reference-mismatch',
+ },
+ ],
+ retryPending: false,
+ },
+ })
+
+ const failedWithConflict = await reconciler.reconcile(sdkOnlyRecipe())
+
+ expect(conflicted).toHaveBeenCalledTimes(1)
+ expect(failedWithConflict.phase).toBe('failed')
+ expect(failedWithConflict.networkPolicyOwnershipConditions).toEqual([
+ expect.objectContaining({
+ type: 'WorkflowNetworkPolicyOwnership',
+ status: 'False',
+ reason: 'OwnershipConflict',
+ message: expect.stringContaining(
+ 'test-recipe-workload-to-mcp-host-sdk-ingress (owner-reference-mismatch)'
+ ),
+ }),
+ ])
+
+ const converged = stubSdkOnly({
+ phase: 'failed',
+ message: 'Plugin Workload SDK mcp-host could not start',
+ networkPolicies: { conflicts: [], retryPending: false },
+ })
+
+ const failedConverged = await reconciler.reconcile(sdkOnlyRecipe([ownershipCondition]))
+
+ expect(converged).toHaveBeenCalledTimes(1)
+ expect(failedConverged.phase).toBe('failed')
+ expect(failedConverged.networkPolicyOwnershipConditions).toEqual([])
+ })
+
// A policy being deleted is retried on the transient path. The twin with
// retryPending false shows that no other input of the requeue expression is
// set, so the first requeue can only come from the pending retry.
diff --git a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts b/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
index 2740d830c..65af838c4 100644
--- a/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
+++ b/workflow-recipes/src/reconciler/workflowRecipeReconciler.ts
@@ -2897,8 +2897,18 @@ export class WorkflowRecipeReconciler {
secretOwnershipConditions: secretOwnership.conditions,
workloadConditions,
transportNetworkConditions: [],
- // `failed` can return before the policy apply, so the ownership
- // field stays undefined and patchStatus keeps what was published.
+ // Without a summary the host returned before the policy apply, so
+ // the field stays undefined and patchStatus keeps what was published.
+ // A pod that failed after the apply publishes what the apply found.
+ ...(sdkOnlyRuntime.networkPolicies !== undefined
+ ? {
+ networkPolicyOwnershipConditions: buildNetworkPolicyOwnershipConditions(
+ sdkOnlyRuntime.networkPolicies,
+ new Date().toISOString(),
+ recipe.status?.conditions
+ ),
+ }
+ : {}),
}
}
@@ -2953,14 +2963,17 @@ export class WorkflowRecipeReconciler {
workloadConditions,
transportNetworkConditions: [],
// Without an SDK runtime this lane manages no policies, so a condition
- // published by an earlier pass is stale and `[]` removes it.
- networkPolicyOwnershipConditions: sdkOnlyRuntime
- ? buildNetworkPolicyOwnershipConditions(
- sdkOnlyRuntime.networkPolicies,
- new Date().toISOString(),
- recipe.status?.conditions
- )
- : [],
+ // published by an earlier pass is stale and `[]` removes it. A runtime
+ // without a summary did not evaluate the policies, so undefined keeps it.
+ networkPolicyOwnershipConditions: !sdkOnlyRuntime
+ ? []
+ : sdkOnlyRuntime.networkPolicies === undefined
+ ? undefined
+ : buildNetworkPolicyOwnershipConditions(
+ sdkOnlyRuntime.networkPolicies,
+ new Date().toISOString(),
+ recipe.status?.conditions
+ ),
pluginWorkloadSdkProviderUnavailable: sdkOnlyProviderUnavailable,
pluginWorkloadSdkPolicyPending: sdkOnlyPolicyPending,
pluginWorkloadSdkBootstrapProof: sdkOnlyRuntime?.pluginWorkloadSdkBootstrapProof,
@@ -2975,7 +2988,7 @@ export class WorkflowRecipeReconciler {
sdkOnlyRuntime?.phase === 'provider_unavailable' ||
sdkOnlyPolicyPending ||
sdkOnlyBootstrapPending ||
- sdkOnlyRuntime?.networkPolicies.retryPending
+ sdkOnlyRuntime?.networkPolicies?.retryPending
? TRANSIENT_REQUEUE_BASE_MS
: undefined,
// Policy-pending waits for an operator grant (event or the 30s refresh
@@ -3067,13 +3080,13 @@ export class WorkflowRecipeReconciler {
phase: 'active' | 'awaiting_policy' | 'deploying' | 'failed' | 'provider_unavailable'
message: string
pluginWorkloadSdkBootstrapProof?: EagerSdkBootstrapProof
- networkPolicies: WorkflowNetworkPolicyApplySummary
+ /** Undefined when the pass returned before applying the policies. */
+ networkPolicies?: WorkflowNetworkPolicyApplySummary
}> {
if (!this.workflowReconciler) {
return {
phase: 'failed',
message: 'Plugin Workload SDK subsystem not initialized — missing clerum-wrc-signing-key',
- networkPolicies: { conflicts: [], retryPending: false },
}
}
const runtimeScopeRecipeName = await this.workflowRuntimeScopeRecipeName(recipe)
diff --git a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.imageDrift.test.ts b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.imageDrift.test.ts
index 9014aca3d..d6612e5fc 100644
--- a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.imageDrift.test.ts
+++ b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.imageDrift.test.ts
@@ -822,7 +822,9 @@ describe('ensureEagerSdkMcpHost NetworkPolicy summary', () => {
}
}
- it('returns an empty summary without applying policies when promptBridge has no agent', async () => {
+ // No summary at all, not an empty one: an empty summary reads as "every
+ // policy converged" and would clear a published ownership conflict.
+ it('returns no summary without applying policies when promptBridge has no agent', async () => {
const logs = captureProvisionerLogs()
try {
const { provisioner, applyWorkflowNetworkPolicies } = makeProvisioner(DESIRED_IMAGE)
@@ -846,10 +848,7 @@ describe('ensureEagerSdkMcpHost NetworkPolicy summary', () => {
String(entry.msg).includes('promptBridge declared but no agent is resolvable')
)
).toBe(true)
- expect(result).toEqual({
- status: 'failed',
- networkPolicies: { conflicts: [], retryPending: false },
- })
+ expect(result).toEqual({ status: 'failed' })
expect(applyWorkflowNetworkPolicies).toHaveBeenCalledTimes(0)
} finally {
logs.restore()
diff --git a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts
index e4956d81a..3bc48d97f 100644
--- a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts
+++ b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.ts
@@ -60,8 +60,11 @@ export type WorkflowNetworkPolicyApplySummary = {
export type EagerSdkMcpHostResult = {
status: EagerSdkMcpHostStatus
- /** Empty when the pass returned before applying the policies. */
- networkPolicies: WorkflowNetworkPolicyApplySummary
+ /**
+ * Undefined when the pass returned before applying the policies. An empty
+ * summary would claim every policy converged and clear a published conflict.
+ */
+ networkPolicies?: WorkflowNetworkPolicyApplySummary
}
/** Why the mcp-host runtime JWT Secret was reminted. */
@@ -254,7 +257,7 @@ export class PluginWorkloadSdkProvisioner {
'Plugin Workload SDK promptBridge declared but no agent is resolvable; ' +
'declare spec.agent with provider+model to bind the eager mcp-host'
)
- return { status: 'failed', networkPolicies: { conflicts: [], retryPending: false } }
+ return { status: 'failed' }
}
const tokenRefresh = await this.deps.ensureMcpHostSecrets(
diff --git a/workflow-recipes/src/workflow/workflowReconciler.test.ts b/workflow-recipes/src/workflow/workflowReconciler.test.ts
index a9832e89b..7a2abed97 100644
--- a/workflow-recipes/src/workflow/workflowReconciler.test.ts
+++ b/workflow-recipes/src/workflow/workflowReconciler.test.ts
@@ -1759,7 +1759,6 @@ describe('WorkflowReconciler — Plugin Workload SDK eager mcp-host', () => {
).pluginWorkloadSdkProvisioner
const ensure = vi.spyOn(provisioner, 'ensureEagerSdkMcpHost').mockResolvedValue({
status: 'failed',
- networkPolicies: { conflicts: [], retryPending: false },
})
const existing = {
type: 'WorkflowNetworkPolicyOwnership',
@@ -1785,6 +1784,47 @@ describe('WorkflowReconciler — Plugin Workload SDK eager mcp-host', () => {
expect(result).not.toHaveProperty('networkPolicyOwnershipConditions')
expect(ownershipCondition(result.workflowConditions)).toBeUndefined()
})
+
+ // The pod failed after the policies were applied, so the summary is a real
+ // evaluation and the conflict it found is published with the failure.
+ it('workflow lane publishes the evaluated set when the eager host fails after applying', async () => {
+ const reconciler = new WorkflowReconciler(makeDeps())
+ const provisioner = (
+ reconciler as unknown as {
+ pluginWorkloadSdkProvisioner: { ensureEagerSdkMcpHost: (...args: unknown[]) => unknown }
+ }
+ ).pluginWorkloadSdkProvisioner
+ const foreignName = 'sdk-recipe-mcp-host-to-gfs'
+ const ensure = vi.spyOn(provisioner, 'ensureEagerSdkMcpHost').mockResolvedValue({
+ status: 'failed',
+ networkPolicies: {
+ conflicts: [{ policy: foreignName, reason: 'owner-reference-mismatch' }],
+ retryPending: false,
+ },
+ })
+
+ const result = await reconciler.reconcile(
+ 'sdk-recipe',
+ 'uid-sdk',
+ sandboxNamespace,
+ sdkSpec(),
+ { workflowExecution: { phase: 'initializing' } },
+ undefined,
+ 'sdk-recipe',
+ undefined
+ )
+
+ expect(ensure).toHaveBeenCalledTimes(1)
+ expect(result.phase).toBe('failed')
+ expect(result.networkPolicyOwnershipConditions).toEqual([
+ expect.objectContaining({
+ type: 'WorkflowNetworkPolicyOwnership',
+ status: 'False',
+ reason: 'OwnershipConflict',
+ message: expect.stringContaining(`${foreignName} (owner-reference-mismatch)`),
+ }),
+ ])
+ })
})
it('creates a provider-free eager mcp-host for clientNotifications-only without an agent', async () => {
diff --git a/workflow-recipes/src/workflow/workflowReconciler.ts b/workflow-recipes/src/workflow/workflowReconciler.ts
index eee85caa7..5d3f141d5 100644
--- a/workflow-recipes/src/workflow/workflowReconciler.ts
+++ b/workflow-recipes/src/workflow/workflowReconciler.ts
@@ -1260,7 +1260,8 @@ export class WorkflowReconciler {
phase: 'active' | 'awaiting_policy' | 'deploying' | 'failed' | 'provider_unavailable'
message: string
pluginWorkloadSdkBootstrapProof?: EagerSdkBootstrapProof
- networkPolicies: WorkflowNetworkPolicyApplySummary
+ /** Undefined when the eager host returned before applying the policies. */
+ networkPolicies?: WorkflowNetworkPolicyApplySummary
}> {
if (!this.deps.config.pluginWorkloadSdkEnabled || !spec.pluginWorkloadSdk) {
return {
@@ -1803,9 +1804,10 @@ export class WorkflowReconciler {
)
const eagerBootstrapProof =
this.pluginWorkloadSdkProvisioner.getBootstrapProof(recipeName)
- // `failed` can return before the apply with an empty summary, which
- // must not read as "every policy converged".
- if (eagerStatus !== 'failed') {
+ // No summary means the host returned before the apply, so the pass
+ // cannot say whether a conflict is gone. A `failed` pod after the
+ // apply still carries a real summary and publishes it.
+ if (eagerNetworkPolicies !== undefined) {
networkPolicyOwnershipConditions = buildNetworkPolicyOwnershipConditions(
eagerNetworkPolicies,
new Date().toISOString(),