1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
10 "git.arvados.org/arvados.git/lib/controller/dblock"
11 "git.arvados.org/arvados.git/sdk/go/auth"
12 "git.arvados.org/arvados.git/sdk/go/ctxlog"
15 func (h *Handler) trashSweepWorker() {
16 sleep := h.Cluster.Collections.TrashSweepInterval.Duration()
17 logger := ctxlog.FromContext(h.BackgroundContext).WithField("worker", "trash sweep")
18 ctx := ctxlog.Context(h.BackgroundContext, logger)
20 logger.Debugf("Collections.TrashSweepInterval is %v, not running worker", sleep)
23 dblock.TrashSweep.Lock(ctx, h.db)
24 defer dblock.TrashSweep.Unlock()
25 for time.Sleep(sleep); ctx.Err() == nil; time.Sleep(sleep) {
26 dblock.TrashSweep.Check()
27 ctx := auth.NewContext(ctx, &auth.Credentials{Tokens: []string{h.Cluster.SystemRootToken}})
28 _, err := h.federation.SysTrashSweep(ctx, struct{}{})
30 logger.WithError(err).Info("trash sweep failed")