Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions 19 core/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,15 @@ func (env *Environment) QueryRoles(pathSpec string) (rs []workflow.Role) {
return
}

func (env *Environment) GetId() uid.ID {
if env == nil {
return ""
}
env.Mu.RLock()
justonedev1 marked this conversation as resolved.
Show resolved Hide resolved
defer env.Mu.RUnlock()
return env.id
}

func (env *Environment) GetPath() string {
return ""
}
Expand Down Expand Up @@ -1222,7 +1231,12 @@ func (env *Environment) subscribeToWfState(taskman *task.Manager) {
log.WithField("partition", env.id).
WithField("level", infologger.IL_Ops).
Error("one of the critical tasks went into ERROR state, transitioning the environment into ERROR")

the.EventWriterWithTopic(topic.Environment).WriteEvent(
NewEnvGoErrorEvent(env, newCriticalTasksErrorMessage(env)),
)
err := env.TryTransition(NewGoErrorTransition(taskman))

if err != nil {
if env.Sm.Current() == "ERROR" {
log.WithField("partition", env.id).
Expand Down Expand Up @@ -1471,6 +1485,11 @@ func (env *Environment) scheduleAutoStopTransition() (scheduled bool, expected t
log.WithField("partition", env.id).
WithField("run", env.currentRunNumber).
Errorf("Scheduled auto stop transition failed: %s, Transitioning into ERROR", err.Error())

the.EventWriterWithTopic(topic.Environment).WriteEvent(
NewEnvGoErrorEvent(env, fmt.Sprintf("scheduled auto stop transition failed: %s", err.Error())),
)

err = env.TryTransition(NewGoErrorTransition(ManagerInstance().taskman))
if err != nil {
log.WithField("partition", env.id).
Expand Down
12 changes: 12 additions & 0 deletions 12 core/environment/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ func (envs *Manager) CreateEnvironment(workflowPath string, userVars map[string]
WithError(err).
Warnf("auto-transitioning environment failed %s, cleanup in progress", op)

the.EventWriterWithTopic(topic.Environment).WriteEvent(
NewEnvGoErrorEvent(env, fmt.Sprintf("%s failed: %v", op, err)),
)
err := env.TryTransition(NewGoErrorTransition(
envs.taskman),
)
Expand Down Expand Up @@ -592,6 +595,9 @@ func (envs *Manager) CreateEnvironment(workflowPath string, userVars map[string]
WithField("level", infologger.IL_Devel).
Error("environment deployment and configuration error, cleanup in progress")

the.EventWriterWithTopic(topic.Environment).WriteEvent(
NewEnvGoErrorEvent(env, fmt.Sprintf("deployment or configuration failed: %v", err)),
)
errTxErr := env.TryTransition(NewGoErrorTransition(
envs.taskman),
)
Expand Down Expand Up @@ -1052,6 +1058,9 @@ func (envs *Manager) handleIntegratedServiceEvent(evt event.IntegratedServiceEve
}

if env.CurrentState() != "ERROR" {
the.EventWriterWithTopic(topic.Environment).WriteEvent(
NewEnvGoErrorEvent(env, "ODC partition went to ERROR during RUNNING"),
)
err = env.TryTransition(NewGoErrorTransition(envs.taskman))
if err != nil {
log.WithPrefix("scheduler").
Expand Down Expand Up @@ -1376,6 +1385,9 @@ func (envs *Manager) CreateAutoEnvironment(workflowPath string, userVars map[str
WithError(err).
Warnf("auto-transitioning environment failed %s, cleanup in progress", op)

the.EventWriterWithTopic(topic.Environment).WriteEvent(
NewEnvGoErrorEvent(env, fmt.Sprintf("%s failed: %v", op, err)),
)
err := env.TryTransition(NewGoErrorTransition(
envs.taskman),
)
Expand Down
38 changes: 38 additions & 0 deletions 38 core/environment/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import (
"encoding/json"
"fmt"
"github.com/AliceO2Group/Control/common/logger/infologger"
pb "github.com/AliceO2Group/Control/common/protos"
"github.com/AliceO2Group/Control/core/task"
"github.com/AliceO2Group/Control/core/task/sm"
"github.com/AliceO2Group/Control/core/workflow"
"os"
"sort"

Expand Down Expand Up @@ -101,3 +105,37 @@ func sortMapToString(m map[string]string) string {
}
return b.String()
}

func NewEnvGoErrorEvent(env *Environment, err string) *pb.Ev_EnvironmentEvent {
return &pb.Ev_EnvironmentEvent{
EnvironmentId: env.GetId().String(),
State: env.Sm.Current(),
RunNumber: env.GetCurrentRunNumber(),
Error: err,
Message: "a critical error occurred, GO_ERROR transition imminent",
LastRequestUser: env.GetLastRequestUser(),
WorkflowTemplateInfo: env.GetWorkflowInfo(),
}
}

func newCriticalTasksErrorMessage(env *Environment) string {
criticalTasksInError := env.workflow.GetTasks().Filtered(func(t *task.Task) bool {
return t.GetTraits().Critical && t.GetState() == sm.ERROR
})

if len(criticalTasksInError) == 0 {
return "no critical tasks in ERROR"
} else if len(criticalTasksInError) == 1 {
justonedev1 marked this conversation as resolved.
Show resolved Hide resolved
t := criticalTasksInError[0]
name := t.GetName()

// if available, we prefer role name, because it does not have a long hash for JIT-generated DPL tasks
role, ok := t.GetParentRole().(workflow.Role)
if ok {
name = role.GetName()
}
return fmt.Sprintf("critical task '%s' on host '%s' transitioned to ERROR", name, t.GetHostname())
} else {
return fmt.Sprintf("%d critical tasks transitioned to ERROR, could not determine the first one to fail", len(criticalTasksInError))
}
}
4 changes: 4 additions & 0 deletions 4 core/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ package core

import (
"encoding/json"
"fmt"
"maps"
"runtime"
"sort"
Expand Down Expand Up @@ -646,6 +647,9 @@ func (m *RpcServer) ControlEnvironment(cxt context.Context, req *pb.ControlEnvir
WithField("level", infologger.IL_Ops).
WithError(err).
Errorf("transition '%s' failed, transitioning into ERROR.", req.GetType().String())
the.EventWriterWithTopic(topic.Environment).WriteEvent(
environment.NewEnvGoErrorEvent(env, fmt.Sprintf("transition %s failed: %v", req.GetType().String(), err)),
)
err = env.TryTransition(environment.NewGoErrorTransition(m.state.taskman))
if err != nil {
log.WithField("partition", env.Id()).Warnf("could not complete requested GO_ERROR transition, forcing move to ERROR: %s", err.Error())
Expand Down
7 changes: 7 additions & 0 deletions 7 core/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ func (t *Task) SetSafeToStop(done bool) {
t.safeToStop = done
}

func (t *Task) GetState() sm.State {
t.mu.Lock()
defer t.mu.Unlock()

return t.state
}

func (t *Task) GetParentRole() interface{} {
t.mu.RLock()
defer t.mu.RUnlock()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.