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
32 changes: 24 additions & 8 deletions 32 executor/executable/controllabletask.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type ControllableTask struct {
taskBase
rpc *executorcmd.RpcClient
pendingFinalTaskStateCh chan mesos.TaskState
taskDoneCh chan error
knownPid int
}

Expand Down Expand Up @@ -159,6 +160,12 @@ func (t *ControllableTask) doLaunchTask(taskCmd *exec.Cmd, launchStartTime time.

t.initTaskStdLogging(stdoutIn, stderrIn)

// We start to Wait() for the result already, so we have access to ProcessState on an early failure
t.taskDoneCh = make(chan error, 1)
go func() {
t.taskDoneCh <- taskCmd.Wait()
}()

log.WithFields(defaultLogFields).
WithFields(logrus.Fields{
"controlPort": t.Tci.ControlPort,
Expand Down Expand Up @@ -186,12 +193,20 @@ func (t *ControllableTask) doLaunchTask(taskCmd *exec.Cmd, launchStartTime time.
WithFields(defaultLogFields),
)
if t.rpc == nil {
err = errors.New("rpc client is nil")
log.WithFields(defaultLogFields).
WithField("command", truncatedCmd).
WithError(err).
WithField(infologger.Level, infologger.IL_Devel).
Error("could not start gRPC client")
// Check if the task is still running by checking ProcessState
if taskCmd.ProcessState != nil {
err = errors.New("AliECS executor could not connect to task, likely crashed on startup")
} else {
err = errors.New("AliECS executor could not connect to task, likely took too long to start")
}

taskClassName, _ := utils.ExtractTaskClassName(t.ti.Name)
log.WithFields(logrus.Fields{
"task": utils.TrimJitPrefix(taskClassName),
"partition": t.knownEnvironmentId.String(),
"detector": t.knownDetector,
infologger.Level: infologger.IL_Ops,
}).Error(err.Error())

t.sendStatus(t.knownEnvironmentId, mesos.TASK_FAILED, err.Error())

Expand Down Expand Up @@ -262,7 +277,7 @@ func (t *ControllableTask) doLaunchTask(taskCmd *exec.Cmd, launchStartTime time.
t.processEventsFromTask(esc)
}()

err = taskCmd.Wait()
err = <-t.taskDoneCh
// ^ when this unblocks, the task is done
log.WithFields(defaultLogFields).
WithField("command", truncatedCmd).
Expand Down Expand Up @@ -330,7 +345,8 @@ func (t *ControllableTask) cleanupFailedTask(taskCmd *exec.Cmd) {

_ = t.doTermIntKill(-taskCmd.Process.Pid)

err := taskCmd.Wait()
// Wait for task to finish and report the error
err := <-t.taskDoneCh
if err != nil {
log.WithFields(defaultLogFields).
WithField(infologger.Level, infologger.IL_Support).
Expand Down
6 changes: 1 addition & 5 deletions 6 executor/executorcmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@ func NewClient(
log.WithField("error", err.Error()).
WithField("endpoint", endpoint).
WithField("transport", controlTransportS).
WithField("level", infologger.IL_Trace).
WithField("level", infologger.IL_Devel).
Error("gRPC client can't dial")
log.WithField("error", err.Error()).
WithField("endpoint", endpoint).
WithField("level", infologger.IL_Ops).
Error("AliECS executor could not connect to task, possible crash on startup")

cancel()
if conn != nil {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.