Skip to content

Commit 09ec975

Browse files
Michal Tichákknopers8
authored andcommitted
amend! creating copy of ExecutorInfo for each mesos offer so there is not race condition
creating copy of ExecutorInfo for each mesos offer so there is not race condition
1 parent 8989162 commit 09ec975

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

core/task/scheduler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ func makeTaskForMesosResources(
15261526

15271527
newTaskId := taskPtr.GetTaskId()
15281528

1529-
executor := state.CopyExecutor()
1529+
executor := state.CopyExecutorInfo()
15301530
executor.ExecutorID.Value = taskPtr.GetExecutorId()
15311531
envIdS := envId.String()
15321532

core/task/schedulerstate.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/AliceO2Group/Control/common/logger/infologger"
3737
"github.com/AliceO2Group/Control/core/controlcommands"
3838
"github.com/AliceO2Group/Control/core/task/schedutil"
39+
"github.com/gogo/protobuf/proto"
3940
"github.com/looplab/fsm"
4041
mesos "github.com/mesos/mesos-go/api/v1/lib"
4142
"github.com/mesos/mesos-go/api/v1/lib/backoff"
@@ -214,17 +215,6 @@ func (state *schedulerState) Start(ctx context.Context) {
214215
}()
215216
}
216217

217-
func (state *schedulerState) CopyExecutor() *mesos.ExecutorInfo {
218-
executorInfoCopy := &mesos.ExecutorInfo{}
219-
220-
marshaled, err := state.executor.Marshal()
221-
if err != nil {
222-
return nil
223-
}
224-
225-
err = executorInfoCopy.Unmarshal(marshaled)
226-
if err != nil {
227-
return nil
228-
}
229-
return executorInfoCopy
218+
func (state *schedulerState) CopyExecutorInfo() *mesos.ExecutorInfo {
219+
return proto.Clone(state.executor).(*mesos.ExecutorInfo)
230220
}

0 commit comments

Comments
 (0)