Skip to content

Commit 46f07e1

Browse files
committed
chore: remove global retention fallback for API keys
API keys retention is now explicit - it's enabled when --api-keys-retention is set to a non-zero duration (default 7d), and disabled when set to 0. No fallback to global retention.
1 parent e74e489 commit 46f07e1

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

coderd/database/dbpurge/dbpurge.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ func New(ctx context.Context, logger slog.Logger, db database.Store, vals *coder
8686

8787
var expiredAPIKeys int64
8888
apiKeysRetention := vals.Retention.APIKeys.Value()
89-
if apiKeysRetention == 0 {
90-
apiKeysRetention = vals.Retention.Global.Value()
91-
}
9289
if apiKeysRetention > 0 {
9390
// Delete keys that have been expired for at least the retention period.
9491
// A higher retention period allows the backend to return a more helpful

coderd/database/dbpurge/dbpurge_test.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,18 +1282,7 @@ func TestDeleteExpiredAPIKeys(t *testing.T) {
12821282
expectOldExpiredDeleted: false,
12831283
expectedKeysRemaining: 1, // old expired is kept
12841284
},
1285-
{
1286-
name: "GlobalRetentionFallback",
1287-
retentionConfig: codersdk.RetentionConfig{
1288-
Global: serpent.Duration(14 * 24 * time.Hour), // 14 days global
1289-
APIKeys: serpent.Duration(0), // Not set, should fall back to global
1290-
},
1291-
oldExpiredTime: now.Add(-15 * 24 * time.Hour), // Expired 15 days ago
1292-
recentExpiredTime: ptr(now.Add(-13 * 24 * time.Hour)), // Expired 13 days ago
1293-
activeTime: nil,
1294-
expectOldExpiredDeleted: true,
1295-
expectedKeysRemaining: 1, // only recent expired remains
1296-
},
1285+
12971286
{
12981287
name: "CustomRetention30Days",
12991288
retentionConfig: codersdk.RetentionConfig{

0 commit comments

Comments
 (0)