[#1902] tree: Allow synchronize all the container trees

Add `SynchronizeAllTrees` method of the Tree service. It allows fetching
tree IDs and sync all of them. Share common logic b/w the new method and
the `SynchronizeTree`.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-10-18 17:15:24 +03:00 committed by Pavel Karpy
parent 1805c6606d
commit 1766ca2039
3 changed files with 103 additions and 7 deletions

View file

@ -80,13 +80,13 @@ func syncTrees(ctx context.Context, treeSvc *tree.Service, cnrCli *containerClie
wellKnownTrees := [...]string{"version", "system"}
for _, id := range ids {
for _, tID := range wellKnownTrees {
err = treeSvc.Synchronize(ctx, id, tID)
for i := range wellKnownTrees {
err = treeSvc.SynchronizeTree(ctx, id, wellKnownTrees[i])
if err != nil && !errors.Is(err, tree.ErrNotInContainer) {
log.Warn(
"tree synchronization failed",
zap.Stringer("cid", id),
zap.String("tree_id", tID),
zap.String("tree_id", wellKnownTrees[i]),
zap.Error(err),
)
}