Skip to content

Commit 9ce7785

Browse files
committed
chore: remove global retention option
Remove the global retention fallback in favor of explicit per-topic retention settings. This makes the retention behavior clearer and easier for operators to reason about. Each retention setting now: - Enables retention when set to a non-zero duration - Disables retention (keep indefinitely) when set to 0
1 parent d5062e2 commit 9ce7785

File tree

11 files changed

+36
-121
lines changed

11 files changed

+36
-121
lines changed

cli/testdata/coder_server_--help.golden

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -709,21 +709,13 @@ that data type.
709709
deletion of expired keys.
710710

711711
--audit-logs-retention duration, $CODER_AUDIT_LOGS_RETENTION (default: 0)
712-
How long audit log entries are retained. Set to 0 to use the global
713-
retention value, or to disable if global is also 0. We advise keeping
714-
audit logs for at least a year, and in accordance with your compliance
715-
requirements.
712+
How long audit log entries are retained. Set to 0 to disable (keep
713+
indefinitely). We advise keeping audit logs for at least a year, and
714+
in accordance with your compliance requirements.
716715

717716
--connection-logs-retention duration, $CODER_CONNECTION_LOGS_RETENTION (default: 0)
718-
How long connection log entries are retained. Set to 0 to use the
719-
global retention value, or to disable if global is also 0.
720-
721-
--global-retention duration, $CODER_GLOBAL_RETENTION (default: 0)
722-
Default retention policy for audit logs, connection logs, and API
723-
keys. Individual retention settings override this value when set to a
724-
non-zero duration. Does not affect AI Bridge retention. Set to 0 to
725-
disable (data is kept indefinitely unless individual settings are
726-
configured).
717+
How long connection log entries are retained. Set to 0 to disable
718+
(keep indefinitely).
727719

728720
TELEMETRY OPTIONS:
729721
Telemetry is critical to our ability to improve Coder. We strip all personal

cli/testdata/server-config.yaml.golden

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -747,19 +747,13 @@ aibridge:
747747
# performance. Setting a retention duration to 0 disables automatic purging for
748748
# that data type.
749749
retention:
750-
# Default retention policy for audit logs, connection logs, and API keys.
751-
# Individual retention settings override this value when set to a non-zero
752-
# duration. Does not affect AI Bridge retention. Set to 0 to disable (data is kept
753-
# indefinitely unless individual settings are configured).
754-
# (default: 0, type: duration)
755-
global: 0s
756-
# How long audit log entries are retained. Set to 0 to use the global retention
757-
# value, or to disable if global is also 0. We advise keeping audit logs for at
758-
# least a year, and in accordance with your compliance requirements.
750+
# How long audit log entries are retained. Set to 0 to disable (keep
751+
# indefinitely). We advise keeping audit logs for at least a year, and in
752+
# accordance with your compliance requirements.
759753
# (default: 0, type: duration)
760754
audit_logs: 0s
761-
# How long connection log entries are retained. Set to 0 to use the global
762-
# retention value, or to disable if global is also 0.
755+
# How long connection log entries are retained. Set to 0 to disable (keep
756+
# indefinitely).
763757
# (default: 0, type: duration)
764758
connection_logs: 0s
765759
# How long expired API keys are retained before being deleted. Keeping expired

coderd/apidoc/docs.go

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codersdk/deployment.go

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -819,16 +819,11 @@ type HealthcheckConfig struct {
819819
// before being automatically purged. Setting a value to 0 disables retention for that
820820
// data type (data is kept indefinitely).
821821
type RetentionConfig struct {
822-
// Global is the default retention policy for audit logs, connection logs,
823-
// and API keys. Individual retention settings override this value when set
824-
// to a non-zero duration. Does not affect AI Bridge retention which has its
825-
// own setting.
826-
Global serpent.Duration `json:"global" typescript:",notnull"`
827822
// AuditLogs controls how long audit log entries are retained.
828-
// Set to 0 to use the global retention value.
823+
// Set to 0 to disable (keep indefinitely).
829824
AuditLogs serpent.Duration `json:"audit_logs" typescript:",notnull"`
830825
// ConnectionLogs controls how long connection log entries are retained.
831-
// Set to 0 to use the global retention value.
826+
// Set to 0 to disable (keep indefinitely).
832827
ConnectionLogs serpent.Duration `json:"connection_logs" typescript:",notnull"`
833828
// APIKeys controls how long expired API keys are retained before being deleted.
834829
// Keys are only deleted if they have been expired for at least this duration.
@@ -3392,20 +3387,9 @@ Write out the current server config as YAML to stdout.`,
33923387
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
33933388
},
33943389
// Retention settings
3395-
{
3396-
Name: "Global Retention",
3397-
Description: "Default retention policy for audit logs, connection logs, and API keys. Individual retention settings override this value when set to a non-zero duration. Does not affect AI Bridge retention. Set to 0 to disable (data is kept indefinitely unless individual settings are configured).",
3398-
Flag: "global-retention",
3399-
Env: "CODER_GLOBAL_RETENTION",
3400-
Value: &c.Retention.Global,
3401-
Default: "0",
3402-
Group: &deploymentGroupRetention,
3403-
YAML: "global",
3404-
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
3405-
},
34063390
{
34073391
Name: "Audit Logs Retention",
3408-
Description: "How long audit log entries are retained. Set to 0 to use the global retention value, or to disable if global is also 0. We advise keeping audit logs for at least a year, and in accordance with your compliance requirements.",
3392+
Description: "How long audit log entries are retained. Set to 0 to disable (keep indefinitely). We advise keeping audit logs for at least a year, and in accordance with your compliance requirements.",
34093393
Flag: "audit-logs-retention",
34103394
Env: "CODER_AUDIT_LOGS_RETENTION",
34113395
Value: &c.Retention.AuditLogs,
@@ -3416,7 +3400,7 @@ Write out the current server config as YAML to stdout.`,
34163400
},
34173401
{
34183402
Name: "Connection Logs Retention",
3419-
Description: "How long connection log entries are retained. Set to 0 to use the global retention value, or to disable if global is also 0.",
3403+
Description: "How long connection log entries are retained. Set to 0 to disable (keep indefinitely).",
34203404
Flag: "connection-logs-retention",
34213405
Env: "CODER_CONNECTION_LOGS_RETENTION",
34223406
Value: &c.Retention.ConnectionLogs,

codersdk/deployment_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -710,50 +710,35 @@ func TestRetentionConfigParsing(t *testing.T) {
710710
tests := []struct {
711711
name string
712712
environment []serpent.EnvVar
713-
expectedGlobal time.Duration
714713
expectedAuditLogs time.Duration
715714
expectedConnectionLogs time.Duration
716715
expectedAPIKeys time.Duration
717716
}{
718717
{
719718
name: "Defaults",
720719
environment: []serpent.EnvVar{},
721-
expectedGlobal: 0,
722720
expectedAuditLogs: 0,
723721
expectedConnectionLogs: 0,
724722
expectedAPIKeys: 7 * 24 * time.Hour, // 7 days default
725723
},
726-
{
727-
name: "GlobalRetentionSet",
728-
environment: []serpent.EnvVar{
729-
{Name: "CODER_GLOBAL_RETENTION", Value: "90d"},
730-
},
731-
expectedGlobal: 90 * 24 * time.Hour,
732-
expectedAuditLogs: 0,
733-
expectedConnectionLogs: 0,
734-
expectedAPIKeys: 7 * 24 * time.Hour,
735-
},
736724
{
737725
name: "IndividualRetentionSet",
738726
environment: []serpent.EnvVar{
739727
{Name: "CODER_AUDIT_LOGS_RETENTION", Value: "30d"},
740728
{Name: "CODER_CONNECTION_LOGS_RETENTION", Value: "60d"},
741729
{Name: "CODER_API_KEYS_RETENTION", Value: "14d"},
742730
},
743-
expectedGlobal: 0,
744731
expectedAuditLogs: 30 * 24 * time.Hour,
745732
expectedConnectionLogs: 60 * 24 * time.Hour,
746733
expectedAPIKeys: 14 * 24 * time.Hour,
747734
},
748735
{
749736
name: "AllRetentionSet",
750737
environment: []serpent.EnvVar{
751-
{Name: "CODER_GLOBAL_RETENTION", Value: "90d"},
752738
{Name: "CODER_AUDIT_LOGS_RETENTION", Value: "365d"},
753739
{Name: "CODER_CONNECTION_LOGS_RETENTION", Value: "30d"},
754740
{Name: "CODER_API_KEYS_RETENTION", Value: "0"},
755741
},
756-
expectedGlobal: 90 * 24 * time.Hour,
757742
expectedAuditLogs: 365 * 24 * time.Hour,
758743
expectedConnectionLogs: 30 * 24 * time.Hour,
759744
expectedAPIKeys: 0, // Explicitly disabled
@@ -774,7 +759,6 @@ func TestRetentionConfigParsing(t *testing.T) {
774759
err = opts.ParseEnv(tt.environment)
775760
require.NoError(t, err)
776761

777-
assert.Equal(t, tt.expectedGlobal, dv.Retention.Global.Value(), "global retention mismatch")
778762
assert.Equal(t, tt.expectedAuditLogs, dv.Retention.AuditLogs.Value(), "audit logs retention mismatch")
779763
assert.Equal(t, tt.expectedConnectionLogs, dv.Retention.ConnectionLogs.Value(), "connection logs retention mismatch")
780764
assert.Equal(t, tt.expectedAPIKeys, dv.Retention.APIKeys.Value(), "api keys retention mismatch")

docs/reference/api/general.md

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/schemas.md

Lines changed: 8 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/cli/server.md

Lines changed: 2 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/cli/testdata/coder_server_--help.golden

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -710,21 +710,13 @@ that data type.
710710
deletion of expired keys.
711711

712712
--audit-logs-retention duration, $CODER_AUDIT_LOGS_RETENTION (default: 0)
713-
How long audit log entries are retained. Set to 0 to use the global
714-
retention value, or to disable if global is also 0. We advise keeping
715-
audit logs for at least a year, and in accordance with your compliance
716-
requirements.
713+
How long audit log entries are retained. Set to 0 to disable (keep
714+
indefinitely). We advise keeping audit logs for at least a year, and
715+
in accordance with your compliance requirements.
717716

718717
--connection-logs-retention duration, $CODER_CONNECTION_LOGS_RETENTION (default: 0)
719-
How long connection log entries are retained. Set to 0 to use the
720-
global retention value, or to disable if global is also 0.
721-
722-
--global-retention duration, $CODER_GLOBAL_RETENTION (default: 0)
723-
Default retention policy for audit logs, connection logs, and API
724-
keys. Individual retention settings override this value when set to a
725-
non-zero duration. Does not affect AI Bridge retention. Set to 0 to
726-
disable (data is kept indefinitely unless individual settings are
727-
configured).
718+
How long connection log entries are retained. Set to 0 to disable
719+
(keep indefinitely).
728720

729721
TELEMETRY OPTIONS:
730722
Telemetry is critical to our ability to improve Coder. We strip all personal

0 commit comments

Comments
 (0)