Skip to content

Commit

Permalink
creating copy of ExecutorInfo for each mesos offer so there is not ra…
Browse files Browse the repository at this point in the history
…ce condition
  • Loading branch information
Michal Tichák authored and knopers8 committed Sep 19, 2024
1 parent a5b0ccf commit 8989162
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/task/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ func makeTaskForMesosResources(

newTaskId := taskPtr.GetTaskId()

executor := state.executor
executor := state.CopyExecutor()
executor.ExecutorID.Value = taskPtr.GetExecutorId()
envIdS := envId.String()

Expand Down
21 changes: 17 additions & 4 deletions core/task/schedulerstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func NewScheduler(taskman *Manager, fidStore store.Singleton, shutdown func()) (
viper.GetFloat64("executorMemory")),
viper.GetDuration("mesosJobRestartDelay"),
)

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -161,11 +160,10 @@ func NewScheduler(taskman *Manager, fidStore store.Singleton, shutdown func()) (
},
"leave_CONNECTED": func(_ context.Context, e *fsm.Event) {
log.Debug("leave_CONNECTED")

},
"before_NEW_ENVIRONMENT": func(_ context.Context, e *fsm.Event) {
log.Debug("before_NEW_ENVIRONMENT")
e.Async() //transition frozen until the corresponding fsm.Transition call
e.Async() // transition frozen until the corresponding fsm.Transition call
},
"enter_CONNECTED": func(_ context.Context, e *fsm.Event) {
log.Debug("enter_CONNECTED")
Expand Down Expand Up @@ -208,10 +206,25 @@ func (state *schedulerState) Start(ctx context.Context) {
if state.err != nil {
err = state.err
log.WithField("error", err.Error()).Debug("scheduler quit with error, main state machine GO_ERROR")
state.sm.Event(context.Background(), "GO_ERROR", err) //TODO: use error information in GO_ERROR
state.sm.Event(context.Background(), "GO_ERROR", err) // TODO: use error information in GO_ERROR
} else {
log.Debug("scheduler quit, no errors")
state.sm.Event(context.Background(), "EXIT")
}
}()
}

func (state *schedulerState) CopyExecutor() *mesos.ExecutorInfo {
executorInfoCopy := &mesos.ExecutorInfo{}

marshaled, err := state.executor.Marshal()
if err != nil {
return nil
}

err = executorInfoCopy.Unmarshal(marshaled)
if err != nil {
return nil
}
return executorInfoCopy
}

0 comments on commit 8989162

Please sign in to comment.