X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/139200027a3192260b5ea7c2d0c93a8eb5f8eb7e..1767cc94ddd427c6610c82e1b27f6a9f6793b39a:/services/keep-balance/collection.go diff --git a/services/keep-balance/collection.go b/services/keep-balance/collection.go index e6a1f08cf1..f12522fb6c 100644 --- a/services/keep-balance/collection.go +++ b/services/keep-balance/collection.go @@ -22,21 +22,31 @@ func countCollections(c *arvados.Client, params arvados.ResourceListParams) (int // The progress function is called periodically with done (number of // times f has been called) and total (number of times f is expected // to be called). -func EachCollection(c *arvados.Client, f func(arvados.Collection) error, progress func(done, total int)) error { +// +// If pageSize > 0 it is used as the maximum page size in each API +// call; otherwise the maximum allowed page size is requested. +func EachCollection(c *arvados.Client, pageSize int, f func(arvados.Collection) error, progress func(done, total int)) error { if progress == nil { progress = func(_, _ int) {} } - expectCount, err := countCollections(c, arvados.ResourceListParams{}) + expectCount, err := countCollections(c, arvados.ResourceListParams{ + IncludeTrash: true, + }) if err != nil { return err } - limit := 1000 + limit := pageSize + if limit <= 0 { + // Use the maximum page size the server allows + limit = 1<<31 - 1 + } params := arvados.ResourceListParams{ - Limit: &limit, - Order: "modified_at, uuid", - Select: []string{"uuid", "manifest_text", "modified_at", "portable_data_hash", "replication_desired"}, + Limit: &limit, + Order: "modified_at, uuid", + Select: []string{"uuid", "manifest_text", "modified_at", "portable_data_hash", "replication_desired"}, + IncludeTrash: true, } var last arvados.Collection var filterTime time.Time @@ -82,10 +92,13 @@ func EachCollection(c *arvados.Client, f func(arvados.Collection) error, progres } progress(callCount, expectCount) - if checkCount, err := countCollections(c, arvados.ResourceListParams{Filters: []arvados.Filter{{ - Attr: "modified_at", - Operator: "<=", - Operand: filterTime}}}); err != nil { + if checkCount, err := countCollections(c, arvados.ResourceListParams{ + Filters: []arvados.Filter{{ + Attr: "modified_at", + Operator: "<=", + Operand: filterTime}}, + IncludeTrash: true, + }); err != nil { return err } else if callCount < checkCount { return fmt.Errorf("Retrieved %d collections with modtime <= T=%q, but server now reports there are %d collections with modtime <= T", callCount, filterTime, checkCount)