Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(workflow-recipes): give each marker fact combination its own reason (R4-L5)
Alfredo Lopez156ed60d06cb
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex c59904993..0218a61f4 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.437",+ "version": "0.1.438","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.437",+ "version": "0.1.438","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 1aedf9965..672287fdb 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.437",+ "version": "0.1.438","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 492fbdc5d..57b39f032 100644--- a/workflow-recipes/src/workflow/workflowReconciler.ts+++ b/workflow-recipes/src/workflow/workflowReconciler.ts@@ -287,25 +287,51 @@ export const NETWORK_POLICY_OWNERSHIP_CONDITION_TYPE = 'WorkflowNetworkPolicyOwn* later `reconcile()` prune that lands, or the finalizer, clears it; every* other path carries it over.*- * Both facts together are one `RetryPending` marker with its own message.+ * Both facts together are one `RetryAndPrunePending` marker. Each combination+ * has its own reason and the facts are read back from the reason alone.*/export const NETWORK_POLICIES_CONVERGED_CONDITION_TYPE = 'WorkflowNetworkPoliciesConverged'-const NETWORK_POLICY_RETRY_PENDING_REASON = 'RetryPending'-const NETWORK_POLICY_PRUNE_PENDING_REASON = 'PrunePending'-const NETWORK_POLICY_RETRY_PENDING_MESSAGE =- 'One or more run-lane NetworkPolicies are pending a retry (terminating or contended)'-const NETWORK_POLICY_PRUNE_PENDING_MESSAGE =- 'One or more run-lane NetworkPolicies the spec no longer wants are pending a delete; the next reconcile() pass or the finalizer removes them'-const NETWORK_POLICY_RETRY_AND_PRUNE_PENDING_MESSAGE =- 'One or more run-lane NetworkPolicies are pending a retry (terminating or contended), and one or more the spec no longer wants are pending a delete'-/** The two facts the WorkflowNetworkPoliciesConverged marker carries. */export interface NetworkPolicyMarkerFacts {applyPending: booleanprunePending: boolean}+/**+ * One reason per combination of facts. The facts are read back from the+ * reason alone; `message` is prose for operators and is never compared.+ */+const NETWORK_POLICY_MARKER_REASONS = {+ RetryPending: {+ facts: { applyPending: true, prunePending: false },+ message: 'One or more run-lane NetworkPolicies are pending a retry (terminating or contended)',+ },+ PrunePending: {+ facts: { applyPending: false, prunePending: true },+ message:+ 'One or more run-lane NetworkPolicies the spec no longer wants are pending a delete; the next reconcile() pass or the finalizer removes them',+ },+ RetryAndPrunePending: {+ facts: { applyPending: true, prunePending: true },+ message:+ 'One or more run-lane NetworkPolicies are pending a retry (terminating or contended), and one or more the spec no longer wants are pending a delete',+ },+} as const satisfies Record<string, { facts: NetworkPolicyMarkerFacts; message: string }>++type NetworkPolicyMarkerReason = keyof typeof NETWORK_POLICY_MARKER_REASONS++function isNetworkPolicyMarkerReason(+ reason: string | undefined+): reason is NetworkPolicyMarkerReason {+ return reason !== undefined && Object.hasOwn(NETWORK_POLICY_MARKER_REASONS, reason)+}++function networkPolicyMarkerReason(facts: NetworkPolicyMarkerFacts): NetworkPolicyMarkerReason {+ if (facts.applyPending) return facts.prunePending ? 'RetryAndPrunePending' : 'RetryPending'+ return 'PrunePending'+}+/*** Merged by its own group in `patchStatus`, apart from the workflow-output* group: a pass that never reached the policy apply leaves the field@@ -358,16 +384,10 @@ export function networkPolicyMarkerFacts(const marker = (conditions ?? []).find(c => c.type === NETWORK_POLICIES_CONVERGED_CONDITION_TYPE && c.status === 'False')- if (marker?.reason === NETWORK_POLICY_PRUNE_PENDING_REASON) {- return { applyPending: false, prunePending: true }- }- if (marker?.reason === NETWORK_POLICY_RETRY_PENDING_REASON) {- return {- applyPending: true,- prunePending: marker.message === NETWORK_POLICY_RETRY_AND_PRUNE_PENDING_MESSAGE,- }+ if (!isNetworkPolicyMarkerReason(marker?.reason)) {+ return { applyPending: false, prunePending: false }}- return { applyPending: false, prunePending: false }+ return { ...NETWORK_POLICY_MARKER_REASONS[marker.reason].facts }}/**@@ -384,17 +404,12 @@ export function buildNetworkPolicyConvergedCondition(const existing = existingConditions?.find(c => c.type === NETWORK_POLICIES_CONVERGED_CONDITION_TYPE && c.status === 'False')+ const reason = networkPolicyMarkerReason(facts)return {type: NETWORK_POLICIES_CONVERGED_CONDITION_TYPE,status: 'False',- reason: facts.applyPending- ? NETWORK_POLICY_RETRY_PENDING_REASON- : NETWORK_POLICY_PRUNE_PENDING_REASON,- message: facts.applyPending- ? facts.prunePending- ? NETWORK_POLICY_RETRY_AND_PRUNE_PENDING_MESSAGE- : NETWORK_POLICY_RETRY_PENDING_MESSAGE- : NETWORK_POLICY_PRUNE_PENDING_MESSAGE,+ reason,+ message: NETWORK_POLICY_MARKER_REASONS[reason].message,lastTransitionTime: existing?.lastTransitionTime ?? now,}}