| 475 | } |
| 476 | |
| 477 | func (s *Topom) SyncRemoveAction(addr string) error { |
| 478 | s.mu.Lock() |
| 479 | defer s.mu.Unlock() |
| 480 | ctx, err := s.newContext() |
| 481 | if err != nil { |
| 482 | return err |
| 483 | } |
| 484 | |
| 485 | g, index, err := ctx.getGroupByServer(addr) |
| 486 | if err != nil { |
| 487 | return err |
| 488 | } |
| 489 | if g.Promoting.State != models.ActionNothing { |
| 490 | return errors.Errorf("group-[%d] is promoting", g.Id) |
| 491 | } |
| 492 | |
| 493 | if g.Servers[index].Action.State == models.ActionNothing { |
| 494 | return errors.Errorf("server-[%s] action doesn't exist", addr) |
| 495 | } |
| 496 | defer s.dirtyGroupCache(g.Id) |
| 497 | |
| 498 | g.Servers[index].Action.Index = 0 |
| 499 | g.Servers[index].Action.State = models.ActionNothing |
| 500 | return s.storeUpdateGroup(g) |
| 501 | } |
| 502 | |
| 503 | func (s *Topom) SyncActionPrepare() (string, error) { |
| 504 | s.mu.Lock() |