Skip to content

Commit

Permalink
Merge 85618b4 into bd1c1c0
Browse files Browse the repository at this point in the history
  • Loading branch information
micahhausler authored Jun 15, 2022
2 parents bd1c1c0 + 85618b4 commit 290fda8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 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
1 change: 1 addition & 0 deletions server/kubernetes_api_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ cont:
return &t
}()
case pb.State_STATE_FAILED:
fallthrough
case 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)])
Expand Down

0 comments on commit 290fda8

Please sign in to comment.