Skip to content

Commit 039afdb

Browse files
committed
chore: remove global retention fallback for connection logs
Connection logs retention is now explicit - it's enabled when --connection-logs-retention is set to a non-zero duration, and disabled when set to 0. No fallback to global retention.
1 parent 61498b8 commit 039afdb

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

coderd/database/dbpurge/dbpurge.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const (
2121
delay = 10 * time.Minute
2222
maxAgentLogAge = 7 * 24 * time.Hour
2323
// Connection events are now inserted into the `connection_logs` table.
24-
// We'll slowly remove old connection events from the `audit_logs` table,
25-
// but we won't touch the `connection_logs` table.
24+
// We'll slowly remove old connection events from the `audit_logs` table.
25+
// The `connection_logs` table is purged based on the configured retention.
2626
maxAuditLogConnectionEventAge = 90 * 24 * time.Hour // 90 days
2727
auditLogConnectionEventBatchSize = 1000
2828
// Batch size for connection log deletion. Smaller batches prevent long-held
@@ -116,9 +116,6 @@ func New(ctx context.Context, logger slog.Logger, db database.Store, vals *coder
116116

117117
var purgedConnectionLogs int64
118118
connectionLogsRetention := vals.Retention.ConnectionLogs.Value()
119-
if connectionLogsRetention == 0 {
120-
connectionLogsRetention = vals.Retention.Global.Value()
121-
}
122119
if connectionLogsRetention > 0 {
123120
deleteConnectionLogsBefore := start.Add(-connectionLogsRetention)
124121
purgedConnectionLogs, err = tx.DeleteOldConnectionLogs(ctx, database.DeleteOldConnectionLogsParams{

coderd/database/dbpurge/dbpurge_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -795,17 +795,6 @@ func TestDeleteOldConnectionLogs(t *testing.T) {
795795
expectOldDeleted: false,
796796
expectedLogsRemaining: 1, // old log is kept
797797
},
798-
{
799-
name: "GlobalRetentionFallback",
800-
retentionConfig: codersdk.RetentionConfig{
801-
Global: serpent.Duration(retentionPeriod),
802-
ConnectionLogs: serpent.Duration(0), // Not set, should fall back to global
803-
},
804-
oldLogTime: afterThreshold,
805-
recentLogTime: &beforeThreshold,
806-
expectOldDeleted: true,
807-
expectedLogsRemaining: 1, // only recent log remains
808-
},
809798
}
810799

811800
for _, tc := range testCases {

0 commit comments

Comments
 (0)