fix(controller): set workflow failed condition on validation failure - #3877
Conversation
When a workflow validation fails or workflow is not found, the controller previously only set the WorkflowCompleted condition to true. This caused the UI to continue showing the workflow in a pending state. This commit explicitly sets WorkflowFailed to true and WorkflowRunning to false in these error cases to properly surface the failure. Closes openchoreo#2948 Signed-off-by: kavix <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughChanged Files & Breakdown
API/CRD Surface Changes
What Changed (controller condition semantics)Workflow not found (cluster lookup failure)In
Component validation failureIn
Tests (updated)Integration tests
Unit tests
Risk Hotspots
WalkthroughTwo condition-setter functions in the ChangesWorkflowRun failure condition completeness
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsStopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/controller/workflowrun/controller_conditions.go`:
- Around line 173-186: The code in controller_conditions.go at lines 173-186
sets three conditions (ConditionWorkflowRunning=False,
ConditionWorkflowFailed=True, and ConditionWorkflowCompleted=True), but the
tests do not fully validate all three. Update
TestSetComponentValidationFailedCondition to expect and verify all three
conditions with their correct status values instead of just one condition.
Update the integration test at controller_integration_test.go lines 549-563 to
add assertions that ConditionWorkflowFailed is True and ConditionWorkflowRunning
is False in addition to the existing ConditionWorkflowCompleted assertion.
Update the integration test at controller_integration_test.go lines 199-213
(workflow-not-found test) with the same additional assertions for
ConditionWorkflowFailed=True and ConditionWorkflowRunning=False alongside the
ConditionWorkflowCompleted check.
- Around line 173-179: In the meta.SetStatusCondition call that sets
ConditionWorkflowRunning to False (line 176), change the Reason field from
string(ReasonComponentValidationFailed) to string(ReasonWorkflowRunning) to
match the established pattern used in setWorkflowSucceededCondition,
setWorkflowFailedCondition, and setWorkflowNotFoundCondition. The specific
failure reason ReasonComponentValidationFailed should only be applied to the
ConditionWorkflowFailed and ConditionWorkflowCompleted conditions where it is
already correctly set on lines 183 and 190, not to ConditionWorkflowRunning.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7fac3e81-6222-4521-b571-6a39b44f7567
📒 Files selected for processing (1)
internal/controller/workflowrun/controller_conditions.go
…coverage Signed-off-by: kavix <[email protected]>
d106efb to
195fccc
Compare
| Type: string(ConditionWorkflowFailed), | ||
| Status: metav1.ConditionTrue, | ||
| Reason: string(ReasonWorkflowFailed), | ||
| Message: "Workflow has been deleted from the cluster", |
There was a problem hiding this comment.
Correct me if I'm wrong, but the main use case here is when a workflow isn't found, right? If so, it's better to mention that in the message. Something like workflow not found would suffice.
There was a problem hiding this comment.
You're absolutely right, the main use case is when a workflow isn't found. I've updated the messages for ConditionWorkflowFailed and ConditionWorkflowCompleted in setWorkflowNotFoundCondition to 'Workflow is not found in the cluster' (to keep it consistent with the existing ConditionWorkflowRunning message in that function).
|
Hi @kavix , Thanks for your interest in contributing to OpenChoreo. Can you please fix the failing test cases. |
I also updated and fixed the corresponding unit tests, and they are now passing. |
…x test Signed-off-by: kavix <[email protected]>
1b2f8ac to
44b0e4d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Thanks for the fix, @kavix! |
When a workflow validation fails or workflow is not found, the controller previously only set the WorkflowCompleted condition to true. This caused the UI to continue showing the workflow in a pending state.
This PR explicitly sets WorkflowFailed to true and WorkflowRunning to false in these error cases to properly surface the failure.
Closes #2948