From 8eaa8f8bed521ca84bfcc86186fdb984ca69b108 Mon Sep 17 00:00:00 2001 From: Piotr Konopka <piotr.jan.konopka@cern.ch> Date: Fri, 13 Dec 2024 08:53:09 +0100 Subject: [PATCH] [core] protect from accessing nil t.Task --- core/workflow/taskrole.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/workflow/taskrole.go b/core/workflow/taskrole.go index fabfde9d..3b294b2a 100644 --- a/core/workflow/taskrole.go +++ b/core/workflow/taskrole.go @@ -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) } }