Skip to content

Commit 1a11c4f

Browse files
claireguyotteo
authored andcommitted
[OCTRL-649] The workflow state is updated correctly when a non-critical is in ERROR.
1 parent 02df889 commit 1a11c4f

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

core/task/manager.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,9 @@ func (m *Manager) configureTasks(envId uid.ID, tasks Tasks) error {
681681
taskDescription = fmt.Sprintf("unknown task (id %s) failed with error: %s", k.TaskId.Value, v.Error())
682682
}
683683
if task.GetTraits().Critical == true || task.parent.GetTaskTraits().Critical == true {
684-
taskCriticalErrors[i] = taskDescription
684+
taskCriticalErrors = append(taskCriticalErrors, taskDescription)
685685
} else {
686-
taskNonCriticalErrors[i] = taskDescription
686+
taskNonCriticalErrors = append(taskNonCriticalErrors, taskDescription)
687687
}
688688
i++
689689
}
@@ -759,9 +759,9 @@ func (m *Manager) transitionTasks(envId uid.ID, tasks Tasks, src string, event s
759759
taskDescription = fmt.Sprintf("unknown task (id %s) failed with error: %s", k.TaskId.Value, v.Error())
760760
}
761761
if task.GetTraits().Critical == true || task.parent.GetTaskTraits().Critical == true {
762-
taskCriticalErrors[i] = taskDescription
762+
taskCriticalErrors = append(taskCriticalErrors, taskDescription)
763763
} else {
764-
taskNonCriticalErrors[i] = taskDescription
764+
taskNonCriticalErrors = append(taskNonCriticalErrors, taskDescription)
765765
}
766766
i++
767767
}

core/workflow/safestate.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,25 @@ type SafeState struct {
3434
state task.State
3535
}
3636

37-
func aggregateState(roles []Role) (state task.State) {
37+
func aggregateState(roles []Role, s task.State) (state task.State) {
3838
if len(roles) == 0 {
3939
state = task.INVARIANT
4040
return
4141
}
42-
state = roles[0].GetState()
42+
state = s
4343
if len(roles) > 1 {
4444
for _, c := range roles[1:] {
45+
taskR, isTaskRole := c.(*taskRole)
46+
callR, isCallRole := c.(*callRole)
47+
if isTaskRole {
48+
if !taskR.Critical {
49+
continue
50+
}
51+
} else if isCallRole {
52+
if !callR.Critical {
53+
continue
54+
}
55+
}
4556
if state == task.MIXED {
4657
return
4758
}
@@ -63,7 +74,7 @@ func (t *SafeState) merge(s task.State, r Role) {
6374

6475
_, isTaskRole := r.(*taskRole)
6576
_, isCallRole := r.(*callRole)
66-
if isTaskRole || isCallRole { // no aggregation, we just update
77+
if isTaskRole || isCallRole {
6778
t.state = s
6879
return
6980
}
@@ -77,7 +88,7 @@ func (t *SafeState) merge(s task.State, r Role) {
7788
return
7889
default:
7990
allRoles := r.GetRoles()
80-
t.state = aggregateState(allRoles)
91+
t.state = aggregateState(allRoles, s)
8192
}
8293
}
8394

0 commit comments

Comments
 (0)