From a399034531476c75b69e72a2ef463fcecf3219f7 Mon Sep 17 00:00:00 2001 From: bergzhao <13611129507@163.com> Date: Fri, 24 Apr 2020 11:53:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20etcd=E5=AD=98=E5=82=A8=E4=B8=8Bsave=20ta?= =?UTF-8?q?skgroup=E5=81=B6=E5=B0=94=E4=BC=9A=E5=A4=B1=E8=B4=A5=20#436?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/sched/scheduler/trans_command.go | 8 +++++++ .../bcs-scheduler/src/types/application.go | 24 ++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/trans_command.go b/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/trans_command.go index f338c75c6c..0ddace91aa 100644 --- a/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/trans_command.go +++ b/bcs-mesos/bcs-scheduler/src/manager/sched/scheduler/trans_command.go @@ -22,8 +22,16 @@ import ( ) func (s *Scheduler) RunCommand(command *commtypes.BcsCommandInfo) { + if len(command.Status.Taskgroups)==0 { + return + } + //lock command s.store.LockCommand(command.Id) defer s.store.UnLockCommand(command.Id) + //lock application + runAs, appId := types.GetRunAsAndAppIDbyTaskGroupID(command.Status.Taskgroups[0].TaskgroupId) + s.store.LockApplication(runAs + "." + appId) + defer s.store.UnLockApplication(runAs + "." + appId) blog.Info("begin send command(%s)", command.Id) for _, taskGroup := range command.Status.Taskgroups { diff --git a/bcs-mesos/bcs-scheduler/src/types/application.go b/bcs-mesos/bcs-scheduler/src/types/application.go index 75abe02050..6dc305f8b6 100644 --- a/bcs-mesos/bcs-scheduler/src/types/application.go +++ b/bcs-mesos/bcs-scheduler/src/types/application.go @@ -725,9 +725,15 @@ func (in *TaskGroup) DeepCopyInto(out *TaskGroup) { if in.Attributes != nil { in, out := &in.Attributes, &out.Attributes *out = make([]*mesos.Attribute, len(*in)) - err := deepcopy.DeepCopy(*out, *in) - if err != nil { - fmt.Println("DeepCopy TaskGroup.Attributes", "failed", err.Error()) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(mesos.Attribute) + err := deepcopy.DeepCopy(out, in) + if err != nil { + fmt.Println("DeepCopy TaskGroup.Attributes", "failed", err.Error()) + } + } } } if in.BcsEventMsg != nil { @@ -1038,9 +1044,15 @@ func (in *DataClass) DeepCopyInto(out *DataClass) { if in.Msgs != nil { in, out := &in.Msgs, &out.Msgs *out = make([]*BcsMessage, len(*in)) - err := deepcopy.DeepCopy(*out, *in) - if err != nil { - fmt.Println("DeepCopy DataClass.Msgs", "failed", err.Error()) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(BcsMessage) + err := deepcopy.DeepCopy(out, in) + if err != nil { + fmt.Println("DeepCopy DataClass.BcsMessage", "failed", err.Error()) + } + } } } return