Skip to content

Commit

Permalink
Fixed handling of failed task
Browse files Browse the repository at this point in the history
Signed-off-by: Micah Hausler <[email protected]>
  • Loading branch information
micahhausler committed Jun 15, 2022
1 parent bd1c1c0 commit c8602de
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
67 changes: 67 additions & 0 deletions server/kubernetes_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,73 @@ func TestModifyWorkflowState(t *testing.T) {
},
wantErr: nil,
},
{
name: "failed task",
inputWf: &v1alpha1.Workflow{
Status: v1alpha1.WorkflowStatus{
State: "STATE_RUNNING",
GlobalTimeout: 600,
Tasks: []v1alpha1.Task{
{
Name: "provision",
WorkerAddr: "machine-mac-1",
Actions: []v1alpha1.Action{
{
Name: "stream",
Image: "quay.io/tinkerbell-actions/image2disk:v1.0.0",
Timeout: 300,
Status: "STATE_RUNNING",
StartedAt: TestTime.MetaV1Before(time.Second * 30),
},
{
Name: "kexec",
Image: "quay.io/tinkerbell-actions/kexec:v1.0.0",
Timeout: 5,
Status: "STATE_PENDING",
},
},
},
},
},
},
inputWfContext: &workflow.WorkflowContext{
CurrentWorker: "machine-mac-1",
CurrentTask: "provision",
CurrentAction: "stream",
CurrentActionIndex: 0,
CurrentActionState: workflow.State_STATE_FAILED,
TotalNumberOfActions: 2,
},
want: &v1alpha1.Workflow{
Status: v1alpha1.WorkflowStatus{
State: "STATE_FAILED",
GlobalTimeout: 600,
Tasks: []v1alpha1.Task{
{
Name: "provision",
WorkerAddr: "machine-mac-1",
Actions: []v1alpha1.Action{
{
Name: "stream",
Image: "quay.io/tinkerbell-actions/image2disk:v1.0.0",
Timeout: 300,
Status: "STATE_FAILED",
StartedAt: TestTime.MetaV1Before(time.Second * 30),
Seconds: 30,
},
{
Name: "kexec",
Image: "quay.io/tinkerbell-actions/kexec:v1.0.0",
Timeout: 5,
Status: "STATE_PENDING",
},
},
},
},
},
},
wantErr: nil,
},
{
name: "successful task",
inputWf: &v1alpha1.Workflow{
Expand Down
3 changes: 1 addition & 2 deletions server/kubernetes_api_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ cont:
t := metav1.NewTime(s.nowFunc())
return &t
}()
case pb.State_STATE_FAILED:
case pb.State_STATE_TIMEOUT:
case pb.State_STATE_FAILED, pb.State_STATE_TIMEOUT:
// Handle terminal statuses by updating the workflow state and time
wf.Status.State = v1alpha1.WorkflowState(pb.State_name[int32(wfContext.CurrentActionState)])
if wf.Status.Tasks[taskIndex].Actions[actionIndex].StartedAt != nil {
Expand Down

0 comments on commit c8602de

Please sign in to comment.