Skip to content

Commit 407f80a

Browse files
authored
fix(dbpurge): use dbauthz.AsSystemRestricted (#7017)
1 parent a361673 commit 407f80a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

coderd/database/dbpurge/dbpurge.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import (
1010

1111
"cdr.dev/slog"
1212
"github.com/coder/coder/coderd/database"
13+
"github.com/coder/coder/coderd/database/dbauthz"
14+
)
15+
16+
const (
17+
delay = 24 * time.Hour
1318
)
1419

1520
// New creates a new periodically purging database instance.
@@ -19,9 +24,12 @@ import (
1924
func New(ctx context.Context, logger slog.Logger, db database.Store) io.Closer {
2025
closed := make(chan struct{})
2126
ctx, cancelFunc := context.WithCancel(ctx)
27+
//nolint:gocritic // The system purges old db records without user input.
28+
ctx = dbauthz.AsSystemRestricted(ctx)
2229
go func() {
2330
defer close(closed)
24-
ticker := time.NewTicker(24 * time.Hour)
31+
32+
ticker := time.NewTicker(delay)
2533
defer ticker.Stop()
2634
for {
2735
select {
@@ -44,6 +52,8 @@ func New(ctx context.Context, logger slog.Logger, db database.Store) io.Closer {
4452
}
4553
logger.Error(ctx, "failed to purge old database entries", slog.Error(err))
4654
}
55+
56+
ticker.Reset(delay)
4757
}
4858
}()
4959
return &instance{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy