Skip to content

Commit 757ef14

Browse files
committed
[executor] Make debug output more useful
1 parent e572c4d commit 757ef14

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

executor/executable/controllabletask.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,28 @@ func (t *ControllableTask) Launch() error {
103103
elapsed := 0 * time.Second
104104
for {
105105
log.WithFields(logrus.Fields{
106-
"id": t.ti.TaskID.Value,
107-
"task": t.ti.Name,
108-
"elapsed": elapsed.String(),
109-
}).
106+
"id": t.ti.TaskID.Value,
107+
"task": t.ti.Name,
108+
"command": t.tci.Value,
109+
"elapsed": elapsed.String(),
110+
}).
110111
Debug("polling task for IDLE state reached")
111112

112113
response, err := t.rpc.GetState(context.TODO(), &pb.GetStateRequest{}, grpc.EmptyCallOption{})
113114
if err != nil {
114115
log.WithError(err).
115-
WithField("task", t.ti.Name).
116+
WithFields(logrus.Fields{
117+
"state": response.GetState(),
118+
"task": t.ti.Name,
119+
"command": t.tci.Value,
120+
}).
116121
Info("cannot query task status")
117122
} else {
118-
log.WithField("state", response.GetState()).
119-
WithField("task", t.ti.Name).
123+
log.WithFields(logrus.Fields{
124+
"state": response.GetState(),
125+
"task": t.ti.Name,
126+
"command": t.tci.Value,
127+
}).
120128
Debug("task status queried")
121129
}
122130
// NOTE: we acquire the transitioner-dependent STANDBY equivalent state
@@ -125,6 +133,7 @@ func (t *ControllableTask) Launch() error {
125133
if reachedState == "STANDBY" && err == nil {
126134
log.WithField("id", t.ti.TaskID.Value).
127135
WithField("task", t.ti.Name).
136+
WithField("command", t.tci.Value).
128137
Debug("task running and ready for control input")
129138
break
130139
} else if reachedState == "DONE" || reachedState == "ERROR" {
@@ -143,6 +152,7 @@ func (t *ControllableTask) Launch() error {
143152
return
144153
} else {
145154
log.WithField("task", t.ti.Name).
155+
WithField("command", t.tci.Value).
146156
Debugf("task not ready yet, waiting %s", startupPollingInterval.String())
147157
time.Sleep(startupPollingInterval)
148158
elapsed += startupPollingInterval
@@ -201,12 +211,18 @@ func (t *ControllableTask) Launch() error {
201211

202212
err = taskCmd.Wait()
203213
// ^ when this unblocks, the task is done
214+
log.WithFields(logrus.Fields{
215+
"id": t.ti.TaskID.Value,
216+
"task": t.ti.Name,
217+
"command": t.tci.Value,
218+
}).Debug("task done, preparing final update")
204219

205220
pendingState := mesos.TASK_FINISHED
206221
if err != nil {
207222
log.WithFields(logrus.Fields{
208223
"id": t.ti.TaskID.Value,
209224
"task": t.ti.Name,
225+
"command": t.tci.Value,
210226
"error": err.Error(),
211227
}).
212228
Error("process terminated with error")
@@ -232,6 +248,7 @@ func (t *ControllableTask) Launch() error {
232248
"errStdout": errStdout,
233249
"id": t.ti.TaskID.Value,
234250
"task": t.ti.Name,
251+
"command": t.tci.Value,
235252
}).
236253
Warning("failed to capture stdout or stderr of task")
237254
}
@@ -273,7 +290,7 @@ func (t *ControllableTask) Kill() error {
273290
if err != nil {
274291
log.WithError(err).WithField("taskId", t.ti.GetTaskID()).Error("cannot query task status")
275292
} else {
276-
log.WithField("state", response.GetState()).WithField("taskId", t.ti.GetTaskID()).Debug("task status queried")
293+
log.WithField("nativeState", response.GetState()).WithField("taskId", t.ti.GetTaskID()).Debug("task status queried for upcoming soft kill")
277294
}
278295

279296
// NOTE: we acquire the transitioner-dependent STANDBY equivalent state

0 commit comments

Comments
 (0)