Skip to content

Commit

Permalink
Merge pull request #451 from zmberg/1.16.x
Browse files Browse the repository at this point in the history
fix: etcd存储下save taskgroup偶尔会失败 #436
  • Loading branch information
DeveloperJim authored May 8, 2020
2 parents 18e6b62 + a399034 commit c2ad4d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 18 additions & 6 deletions bcs-mesos/bcs-scheduler/src/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c2ad4d0

Please sign in to comment.