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
4 changes: 2 additions & 2 deletions 4 core/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ func (env *Environment) subscribeToWfState(taskman *task.Manager) {
)
err := env.TryTransition(NewGoErrorTransition(taskman))
if err != nil {
handleFailedGoError(err, env)
HandleFailedGoError(err, env)
}
})
break WORKFLOW_STATE_LOOP
Expand Down Expand Up @@ -1461,7 +1461,7 @@ func (env *Environment) scheduleAutoStopTransition() (scheduled bool, expected t

err = env.TryTransition(NewGoErrorTransition(ManagerInstance().taskman))
if err != nil {
handleFailedGoError(err, env)
HandleFailedGoError(err, env)
}
return
}
Expand Down
10 changes: 5 additions & 5 deletions 10 core/environment/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func (envs *Manager) CreateEnvironment(workflowPath string, userVars map[string]
envs.taskman),
)
if err != nil {
handleFailedGoError(err, env)
HandleFailedGoError(err, env)
}

envTasks := env.Workflow().GetTasks()
Expand Down Expand Up @@ -600,7 +600,7 @@ func (envs *Manager) CreateEnvironment(workflowPath string, userVars map[string]
envs.taskman),
)
if errTxErr != nil {
handleFailedGoError(errTxErr, env)
HandleFailedGoError(errTxErr, env)
}
envTasks := env.Workflow().GetTasks()
// TeardownEnvironment manages the envs.mu internally
Expand Down Expand Up @@ -1058,7 +1058,7 @@ func (envs *Manager) handleIntegratedServiceEvent(evt event.IntegratedServiceEve
)
err = env.TryTransition(NewGoErrorTransition(envs.taskman))
if err != nil {
handleFailedGoError(err, env)
HandleFailedGoError(err, env)
}
}
}()
Expand Down Expand Up @@ -1114,7 +1114,7 @@ func (envs *Manager) handleLhcEvents(evt event.IntegratedServiceEvent) {
if env.CurrentState() != "ERROR" {
err = env.TryTransition(NewGoErrorTransition(envs.taskman))
if err != nil {
handleFailedGoError(err, env)
HandleFailedGoError(err, env)
}
}
}
Expand Down Expand Up @@ -1468,7 +1468,7 @@ func (envs *Manager) CreateAutoEnvironment(workflowPath string, userVars map[str
envs.taskman),
)
if err != nil {
handleFailedGoError(err, env)
HandleFailedGoError(err, env)
env.sendEnvironmentEvent(&event.EnvironmentEvent{Message: "transition ERROR failed, forcing", EnvironmentID: env.Id().String(), Error: err})
}

Expand Down
2 changes: 1 addition & 1 deletion 2 core/environment/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func newCriticalTasksErrorMessage(env *Environment) string {
}
}

func handleFailedGoError(err error, env *Environment) {
func HandleFailedGoError(err error, env *Environment) {
var invalidEventErr fsm.InvalidEventError
if errors.As(err, &invalidEventErr) {
// this case can occur if the environment is in either:
Expand Down
6 changes: 3 additions & 3 deletions 6 core/environment/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ import (
. "github.com/onsi/gomega"
)

var _ = Describe("handleFailedGoError", func() {
var _ = Describe("HandleFailedGoError", func() {
It("does not overwrite state for InvalidEventError", func() {
env := &Environment{}
env.Sm = fsm.NewFSM("DONE", fsm.Events{}, fsm.Callbacks{})
Expect(env.Sm.Current()).To(Equal("DONE"))

handleFailedGoError(fsm.InvalidEventError{Event: "GO_ERROR", State: "DONE"}, env)
HandleFailedGoError(fsm.InvalidEventError{Event: "GO_ERROR", State: "DONE"}, env)
Expect(env.Sm.Current()).To(Equal("DONE"))
})

It("overwrites state to ERROR for other errors", func() {
env := &Environment{}
env.Sm = fsm.NewFSM("CONFIGURED", fsm.Events{}, fsm.Callbacks{})

handleFailedGoError(fsm.UnknownEventError{Event: "BOOM"}, env)
HandleFailedGoError(fsm.UnknownEventError{Event: "BOOM"}, env)
Expect(env.Sm.Current()).To(Equal("ERROR"))
})
})
28 changes: 22 additions & 6 deletions 28 core/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,18 @@ func (m *RpcServer) DestroyEnvironment(cxt context.Context, req *pb.DestroyEnvir
}

if req.AllowInRunningState && env.CurrentState() == "RUNNING" {
err = env.TryTransition(environment.MakeTransition(m.state.taskman, pb.ControlEnvironmentRequest_STOP_ACTIVITY))
err = env.TryTransition(environment.NewStopActivityTransition(m.state.taskman))
if err != nil {
log.WithField("partition", env.Id().String()).
Warn("could not perform STOP transition for environment teardown, forcing")
log.WithError(err).
WithField("partition", env.Id().String()).
Warn("could not perform STOP transition for environment teardown, going to ERROR, then forcing")
the.EventWriterWithTopic(topic.Environment).WriteEvent(
environment.NewEnvGoErrorEvent(env, "STOP_ACTIVITY during environment destruction failed"),
)
err = env.TryTransition(environment.NewGoErrorTransition(m.state.taskman))
if err != nil {
environment.HandleFailedGoError(err, env)
}
reply, err = m.doTeardownAndCleanup(env, true /*force*/, false /*keepTasks*/)
return
}
Expand All @@ -746,10 +754,18 @@ func (m *RpcServer) DestroyEnvironment(cxt context.Context, req *pb.DestroyEnvir

// This might transition to STANDBY if needed, or do nothing if we're already there
if env.CurrentState() == "CONFIGURED" {
err = env.TryTransition(environment.MakeTransition(m.state.taskman, pb.ControlEnvironmentRequest_RESET))
err = env.TryTransition(environment.NewResetTransition(m.state.taskman))
if err != nil {
log.WithField("partition", env.Id().String()).
Warnf("cannot teardown environment in state %s, forcing", env.CurrentState())
log.WithError(err).
WithField("partition", env.Id().String()).
Warnf("cannot teardown environment in state %s, going to ERROR, then forcing", env.CurrentState())
the.EventWriterWithTopic(topic.Environment).WriteEvent(
environment.NewEnvGoErrorEvent(env, "RESET during environment destruction failed"),
)
err = env.TryTransition(environment.NewGoErrorTransition(m.state.taskman))
if err != nil {
environment.HandleFailedGoError(err, env)
}
reply, err = m.doTeardownAndCleanup(env, true /*force*/, false /*keepTasks*/)
return
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.