Skip to content

Commit a5bd2ac

Browse files
committed
[executor] Carry environment ID in DeviceEvents and output
1 parent eefb2da commit a5bd2ac

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

executor/eventloop.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ func eventLoop(state *internalState, decoder encoding.Decoder, h events.Handler)
7777
// Any error coming through here should immediately destroy the event loop and return
7878
// control to the Mesos subscription handling.
7979
case status := <-state.statusCh:
80-
handleStatusUpdate(state, status)
80+
performStatusUpdate(state, status)
8181
case message := <-state.messageCh:
82-
handleOutgoingMessage(state, message)
82+
sendOutgoingMessage(state, message)
8383
}
8484
}
8585
return err

executor/executable/basictaskcommon.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func (t *basicTaskBase) startBasicTask() (err error) {
208208
btt.FinalMesosState = pendingState
209209
btt.Stderr = stderrBuf.String()
210210
btt.Stdout = stdoutBuf.String()
211+
btt.SetLabels(map[string]string{"environmentId": t.knownEnvironmentId.String()})
211212
t.sendDeviceEvent(t.knownEnvironmentId, btt)
212213
}
213214
}()

executor/executable/controllabletask.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ func (t *ControllableTask) Launch() error {
446446
Debug("nil DeviceEvent received (NULL_DEVICE_EVENT) - closing stream")
447447
break
448448
}
449+
deviceEvent.SetLabels(map[string]string{"environmentId": t.knownEnvironmentId.String()})
449450

450451
t.sendDeviceEvent(t.knownEnvironmentId, deviceEvent)
451452
}

executor/executorutil/executorutil.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ type Labeler interface {
4141
func GetEnvironmentIdFromLabelerType(labeler Labeler) uid.ID {
4242
envId := uid.NilID()
4343
var err error
44-
if labeler.GetLabels() != nil && len(labeler.GetLabels().Labels) > 0 {
45-
for _, label := range labeler.GetLabels().Labels {
46-
if label.Key == "environmentId" && label.Value != nil {
47-
envId, err = uid.FromString(*label.Value)
44+
labels := labeler.GetLabels()
45+
46+
if labels != nil && len(labels.GetLabels()) > 0 {
47+
for _, label := range labels.GetLabels() {
48+
if label.GetKey() == "environmentId" && label.GetValue() != "" {
49+
envId, err = uid.FromString(label.GetValue())
4850
if err != nil {
4951
envId = uid.NilID()
5052
}

0 commit comments

Comments
 (0)