Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: fix terminate suspending steps #160

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions controllers/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,7 @@ var _ = Describe("Test Workflow", func() {
Expect(wrObj.Status.Phase).Should(BeEquivalentTo(v1alpha1.WorkflowStateSuspending))

// terminate the workflow
wrObj.Status.Terminated = true
wrObj.Status.Suspend = false
wrObj.Status.Steps[0].Phase = v1alpha1.WorkflowStepPhaseFailed
wrObj.Status.Steps[0].Reason = wfTypes.StatusReasonTerminate
Expect(k8sClient.Status().Patch(ctx, wrObj, client.Merge)).Should(BeNil())
Expect(utils.TerminateWorkflow(ctx, k8sClient, wrObj)).Should(BeNil())

tryReconcile(reconciler, wr.Name, wr.Namespace)

Expand Down Expand Up @@ -1743,7 +1739,7 @@ var _ = Describe("Test Workflow", func() {
// terminate manually
checkRun := &v1alpha1.WorkflowRun{}
Expect(k8sClient.Get(ctx, wrKey, checkRun)).Should(BeNil())
terminateWorkflowRun(ctx, checkRun, 0)
Expect(utils.TerminateWorkflow(ctx, k8sClient, checkRun)).Should(BeNil())

tryReconcile(reconciler, wr.Name, wr.Namespace)

Expand Down Expand Up @@ -1955,11 +1951,3 @@ func setupTestDefinitions(ctx context.Context, defs []string, namespace string)
})).Should(SatisfyAny(BeNil(), &utils.AlreadyExistMatcher{}))
}
}

func terminateWorkflowRun(ctx context.Context, run *v1alpha1.WorkflowRun, index int) {
run.Status.Suspend = false
run.Status.Terminated = true
run.Status.Steps[index].Phase = v1alpha1.WorkflowStepPhaseFailed
run.Status.Steps[index].Reason = wfTypes.StatusReasonTerminate
Expect(k8sClient.Status().Update(ctx, run)).Should(BeNil())
}
4 changes: 2 additions & 2 deletions pkg/utils/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func TerminateWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.Wor
if step.Reason != wfTypes.StatusReasonFailedAfterRetries && step.Reason != wfTypes.StatusReasonTimeout {
steps[i].Reason = wfTypes.StatusReasonTerminate
}
case v1alpha1.WorkflowStepPhaseRunning:
case v1alpha1.WorkflowStepPhaseRunning, v1alpha1.WorkflowStepPhaseSuspending:
steps[i].Phase = v1alpha1.WorkflowStepPhaseFailed
steps[i].Reason = wfTypes.StatusReasonTerminate
default:
Expand All @@ -324,7 +324,7 @@ func TerminateWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.Wor
if sub.Reason != wfTypes.StatusReasonFailedAfterRetries && sub.Reason != wfTypes.StatusReasonTimeout {
steps[i].SubStepsStatus[j].Reason = wfTypes.StatusReasonTerminate
}
case v1alpha1.WorkflowStepPhaseRunning:
case v1alpha1.WorkflowStepPhaseRunning, v1alpha1.WorkflowStepPhaseSuspending:
steps[i].SubStepsStatus[j].Phase = v1alpha1.WorkflowStepPhaseFailed
steps[i].SubStepsStatus[j].Reason = wfTypes.StatusReasonTerminate
default:
Expand Down