From 18359fa739eb224985b1ba203b06f4a965461092 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Fri, 2 Oct 2020 15:43:57 +0200 Subject: [PATCH] [core] Use short UID for task ID and executor ID --- core/scheduler.go | 6 ++++-- core/task/manager.go | 6 ++---- core/task/task.go | 2 +- core/workflow/template/stack.go | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/scheduler.go b/core/scheduler.go index aee91cdbb..9c643b2f3 100644 --- a/core/scheduler.go +++ b/core/scheduler.go @@ -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" @@ -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 } diff --git a/core/task/manager.go b/core/task/manager.go index 6262ebd32..eb563f204 100644 --- a/core/task/manager.go +++ b/core/task/manager.go @@ -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" @@ -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, diff --git a/core/task/task.go b/core/task/task.go index 3f4aca4a2..08eab6525 100644 --- a/core/task/task.go +++ b/core/task/task.go @@ -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__:: key is created + // For each run of ToPtree, a temporary __ptree__:: 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__:: with the plain payload. diff --git a/core/workflow/template/stack.go b/core/workflow/template/stack.go index 59c024feb..eac76e28f 100644 --- a/core/workflow/template/stack.go +++ b/core/workflow/template/stack.go @@ -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" ) @@ -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 }