(baseParams api.BaseParams, ctx *Ctx, timeout time.Time, smap *cluster.Smap, prevVersion int64, idsToIgnore cos.StringSet)
| 736 | } |
| 737 | |
| 738 | func _waitMapVersionSync(baseParams api.BaseParams, ctx *Ctx, timeout time.Time, smap *cluster.Smap, prevVersion int64, |
| 739 | idsToIgnore cos.StringSet) error { |
| 740 | var ( |
| 741 | prevSid string |
| 742 | orig = idsToIgnore.Clone() |
| 743 | ) |
| 744 | for { |
| 745 | sid, _, exists := _nextNode(smap, idsToIgnore) |
| 746 | if !exists { |
| 747 | break |
| 748 | } |
| 749 | if sid == prevSid { |
| 750 | time.Sleep(time.Second) |
| 751 | } |
| 752 | daemonSmap, err := api.GetNodeClusterMap(baseParams, sid) |
| 753 | if err != nil && !cos.IsRetriableConnErr(err) && |
| 754 | !cmn.IsStatusServiceUnavailable(err) && !cmn.IsStatusBadGateway(err) /* retry as well */ { |
| 755 | return err |
| 756 | } |
| 757 | if err == nil && daemonSmap.Version > prevVersion { |
| 758 | idsToIgnore.Add(sid) |
| 759 | if daemonSmap.Version > smap.Version { |
| 760 | *smap = *daemonSmap |
| 761 | } |
| 762 | if daemonSmap.Version > prevVersion+1 { |
| 763 | // update Smap to a newer version and restart waiting |
| 764 | if prevVersion < 0 { |
| 765 | ctx.Log("%s (from node %s)\n", daemonSmap.StringEx(), sid) |
| 766 | } else { |
| 767 | ctx.Log("Updating Smap v%d to %s (from node %s)\n", prevVersion, daemonSmap.StringEx(), sid) |
| 768 | } |
| 769 | *smap = *daemonSmap |
| 770 | prevVersion = smap.Version - 1 |
| 771 | idsToIgnore = orig.Clone() |
| 772 | idsToIgnore.Add(sid) |
| 773 | } |
| 774 | continue |
| 775 | } |
| 776 | if time.Now().After(timeout) { |
| 777 | return fmt.Errorf("timed out waiting for node %s to sync Smap > v%d", sid, prevVersion) |
| 778 | } |
| 779 | if daemonSmap != nil { |
| 780 | if snode := daemonSmap.GetNode(sid); snode != nil { |
| 781 | ctx.Log("Waiting for %s(%s) to sync Smap > v%d\n", snode.StringEx(), daemonSmap, prevVersion) |
| 782 | } else { |
| 783 | ctx.Log("Waiting for node %s(%s) to sync Smap > v%d\n", sid, daemonSmap, prevVersion) |
| 784 | } |
| 785 | } |
| 786 | prevSid = sid |
| 787 | } |
| 788 | return nil |
| 789 | } |
| 790 | |
| 791 | // Quick remove node from SMap |
| 792 | func _removeNodeFromSmap(ctx *Ctx, proxyURL, sid string, timeout time.Duration) error { |
no test coverage detected