[#2165] services/tree: Always synchronize all containers

In case of split-brain we must synchronize everything.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2022-12-14 10:02:41 +03:00 committed by Anton Nikiforov
parent d3054e577a
commit de9957e076

View file

@ -266,16 +266,9 @@ func (s *Service) syncLoop(ctx context.Context) {
continue
}
_, ok := s.cnrMap[cnr]
if ok {
// known container; already in sync.
delete(s.cnrMap, cnr)
newMap[cnr] = struct{}{}
} else {
// unknown container; need to sync.
cnrsToSync = append(cnrsToSync, cnr)
}
}
// sync new containers
for _, cnr := range cnrsToSync {
@ -287,14 +280,15 @@ func (s *Service) syncLoop(ctx context.Context) {
continue
}
// mark as synced
newMap[cnr] = struct{}{}
s.log.Debug("container trees have been synced", zap.Stringer("cid", cnr))
}
// remove stored redundant trees
for cnr := range s.cnrMap {
if _, ok := newMap[cnr]; ok {
continue
}
s.log.Debug("removing redundant trees...", zap.Stringer("cid", cnr))
err = s.DropTree(ctx, cnr, "")