Skip to content

Commit

Permalink
[core] protect from accessing nil t.Task
Browse files Browse the repository at this point in the history
  • Loading branch information
knopers8 authored and justonedev1 committed Dec 13, 2024
1 parent 6a2250b commit 8eaa8f8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/workflow/taskrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,18 @@ func (t *taskRole) updateState(s sm.State) {
EnvironmentId: t.GetEnvironmentId().String(),
})
if t.state.get() == sm.ERROR {
host := "unknown"
if t.Task != nil {
host = t.Task.GetHostname()
}
if t.Critical {
log.WithField("partition", t.GetEnvironmentId().String()).
WithField("level", infologger.IL_Ops).
Errorf("critical task '%s' on host '%s' went into ERROR, the environment will stop or tear down", t.Name, t.Task.GetHostname())
Errorf("critical task '%s' on host '%s' went into ERROR, the environment will stop or tear down", t.Name, host)
} else {
log.WithField("partition", t.GetEnvironmentId().String()).
WithField("level", infologger.IL_Ops).
Errorf("non-critical task '%s' on host '%s' went into ERROR, but the environment might continue", t.Name, t.Task.GetHostname())
Errorf("non-critical task '%s' on host '%s' went into ERROR, but the environment might continue", t.Name, host)
}

}
Expand Down

0 comments on commit 8eaa8f8

Please sign in to comment.