Skip to content

Commit 8eaa8f8

Browse files
knopers8justonedev1
authored andcommitted
[core] protect from accessing nil t.Task
1 parent 6a2250b commit 8eaa8f8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/workflow/taskrole.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,18 @@ func (t *taskRole) updateState(s sm.State) {
257257
EnvironmentId: t.GetEnvironmentId().String(),
258258
})
259259
if t.state.get() == sm.ERROR {
260+
host := "unknown"
261+
if t.Task != nil {
262+
host = t.Task.GetHostname()
263+
}
260264
if t.Critical {
261265
log.WithField("partition", t.GetEnvironmentId().String()).
262266
WithField("level", infologger.IL_Ops).
263-
Errorf("critical task '%s' on host '%s' went into ERROR, the environment will stop or tear down", t.Name, t.Task.GetHostname())
267+
Errorf("critical task '%s' on host '%s' went into ERROR, the environment will stop or tear down", t.Name, host)
264268
} else {
265269
log.WithField("partition", t.GetEnvironmentId().String()).
266270
WithField("level", infologger.IL_Ops).
267-
Errorf("non-critical task '%s' on host '%s' went into ERROR, but the environment might continue", t.Name, t.Task.GetHostname())
271+
Errorf("non-critical task '%s' on host '%s' went into ERROR, but the environment might continue", t.Name, host)
268272
}
269273

270274
}

0 commit comments

Comments
 (0)