X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e2197875b3fa58b235268a86170fec582c1a7f59..d03f44d2d2c93841a50cbfca1a74600bc504b593:/services/datamanager/keep/keep.go diff --git a/services/datamanager/keep/keep.go b/services/datamanager/keep/keep.go index ea28ffa59d..206a9c43fd 100644 --- a/services/datamanager/keep/keep.go +++ b/services/datamanager/keep/keep.go @@ -466,13 +466,29 @@ type TrashRequest struct { type TrashList []TrashRequest // SendTrashLists to trash queue -func SendTrashLists(kc *keepclient.KeepClient, spl map[string]TrashList) (errs []error) { +func SendTrashLists(arvLogger *logger.Logger, kc *keepclient.KeepClient, spl map[string]TrashList, dryRun bool) (errs []error) { count := 0 barrier := make(chan error) client := kc.Client for url, v := range spl { + if arvLogger != nil { + // We need a local variable because Update doesn't call our mutator func until later, + // when our list variable might have been reused by the next loop iteration. + url := url + trashLen := len(v) + arvLogger.Update(func(p map[string]interface{}, e map[string]interface{}) { + trashListInfo := logger.GetOrCreateMap(p, "trash_list_len") + trashListInfo[url] = trashLen + }) + } + + if dryRun { + log.Printf("dry run, not sending trash list to service %s with %d blocks", url, len(v)) + continue + } + count++ log.Printf("Sending trash list to %v", url) @@ -512,7 +528,6 @@ func SendTrashLists(kc *keepclient.KeepClient, spl map[string]TrashList) (errs [ barrier <- nil } })(url, v) - } for i := 0; i < count; i++ {