Skip to content

Commit

Permalink
[core] Use short UID for task ID and executor ID
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed Oct 2, 2020
1 parent 17928aa commit 18359fa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions core/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ import (

"github.com/AliceO2Group/Control/common/controlmode"
"github.com/AliceO2Group/Control/common/utils"
"github.com/AliceO2Group/Control/common/utils/uid"
"github.com/AliceO2Group/Control/core/task/channel"
"github.com/AliceO2Group/Control/core/workflow"
"github.com/rs/xid"
"github.com/spf13/viper"

"github.com/AliceO2Group/Control/common/event"
Expand Down Expand Up @@ -557,8 +557,10 @@ func resourceOffers(state *internalState, fidStore store.Singleton) events.Handl
targetExecutorId = mesos.ExecutorID{}
)

// If there are no executors provided by the offer,
// we start a new one by generating a new ID
if len(offer.ExecutorIDs) == 0 {
targetExecutorId.Value = xid.New().String()
targetExecutorId.Value = uid.New().String()
} else {
targetExecutorId.Value = offer.ExecutorIDs[0].Value
}
Expand Down
6 changes: 2 additions & 4 deletions core/task/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ import (
"sync"

"github.com/AliceO2Group/Control/common/gera"
"github.com/AliceO2Group/Control/common/utils/uid"
"github.com/rs/xid"

"github.com/AliceO2Group/Control/common/utils"
"github.com/AliceO2Group/Control/common/utils/uid"
"github.com/AliceO2Group/Control/core/repos"
"github.com/AliceO2Group/Control/core/the"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -96,7 +94,7 @@ func (m *Manager) NewTaskForMesosOffer(
descriptor *Descriptor,
localBindMap channel.BindMap,
executorId mesos.ExecutorID) (t *Task) {
newId := xid.New().String()
newId := uid.New().String()
t = &Task{
name: fmt.Sprintf("%s#%s", descriptor.TaskClassName, newId),
parent: descriptor.TaskRole,
Expand Down
2 changes: 1 addition & 1 deletion core/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (t *Task) BuildPropertyMap(bindMap channel.BindMap) (propMap controlcommand
// Post-processing for the ToPtree mechanism.
// The ToPtree function has no access to the keys of propMap, so we need
// to do a second pass here.
// For each run of ToPtree, a temporary __ptree__:<syntax>:<xid> key is created
// For each run of ToPtree, a temporary __ptree__:<syntax>:<uid> key is created
// and the value of the key that pointed to ToPtree is set to this key.
// We need to clear both of these keys, and create a new one like
// __ptree__:<syntax>:<key> with the plain payload.
Expand Down
4 changes: 2 additions & 2 deletions core/workflow/template/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (
texttemplate "text/template"

"github.com/AliceO2Group/Control/common/utils"
"github.com/AliceO2Group/Control/common/utils/uid"
"github.com/AliceO2Group/Control/core/the"
"github.com/rs/xid"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -74,7 +74,7 @@ func MakeToPtreeFunc(varStack map[string]string, propMap map[string]string) ToPt
syntaxLC = "json"
}

ptreeId := fmt.Sprintf("__ptree__:%s:%s", syntaxLC, xid.New().String())
ptreeId := fmt.Sprintf("__ptree__:%s:%s", syntaxLC, uid.New().String())
propMap[ptreeId] = localPayload
return ptreeId
}
Expand Down

0 comments on commit 18359fa

Please sign in to comment.