Plan: Simplify Checkpoint and Cleanup Configuration
Context
The metricstore checkpoint interval is always "12h" in practice and has no reason to be configurable. The cleanup interval for the "delete" mode already falls back to retention-in-memory when not set — this should be the fixed behavior for all modes. WAL is the preferred and more robust checkpoint format and should be the default instead of JSON.
These changes reduce unnecessary configuration surface, eliminate a required field from the schema, and make WAL the out-of-the-box format.
Changes
1. pkg/metricstore/config.go
Remove Interval string field from Checkpoints struct (with its json:"interval" tag)
Remove Interval string field from Cleanup struct (with its json:"interval" tag)
Change default FileFormat from "json" to "wal" in the Keys var
Update doc comments on both structs and the Keys hierarchy comment
2. pkg/metricstore/configSchema.go
Remove "interval" property from the checkpoints object properties
Remove "interval" from "required": ["interval"] in checkpoints (make required empty or remove it)
Remove "interval" property from the cleanup object properties
Remove "interval" from the conditional "then": { "required": ["interval", "directory"] } → only "directory" remains required for archive mode
Update the "file-format" description to say default is 'wal'
3. pkg/metricstore/checkpoint.go
Replace dynamic interval parsing with a hardcoded 12h constant:
go
// Before
d, err := time.ParseDuration(Keys.Checkpoints.Interval)
if err != nil { cclog.Fatalf(...) }
if d <= 0 { cclog.Warnf(...); return }
// After
const checkpointInterval = 12 * time.Hour
d := checkpointInterval
Remove the err variable and validation block. The and rest of the function stay unchanged.
Assistant
Now I'll implement all the changes in parallel where possible.
Assistant
Now update the hierarchy comment. Let me read the exact content:
Assistant
Now also update RetentionInMemory comment in the hierarchy:
Assistant
Now update checkpoint.go to use a hardcoded 12h interval:
Assistant
Now simplify archive.go:
Assistant
Those diagnostics appear to be pre-existing (related to WAL methods in another file). Let me verify they existed before my changes:
Assistant
These diagnostics are pre-existing (not caused by my changes). Now update the schema and config files:
Assistant
Now update the config files:
Assistant
Now verify the build compiles:
Assistant
Clean build. Let me run the metricstore tests:
Assistant
All tests pass. Here's a summary of what was changed:
pkg/metricstore/config.go
Removed Interval string from Checkpoints struct
Removed Interval string from Cleanup struct
Changed default FileFormat from "json" to "wal"
Updated doc comments on both structs and the hierarchy comment
pkg/metricstore/configSchema.go
Removed "interval" property from checkpoints and its required array
Removed "interval" property from cleanup and from the conditional "then": required
Updated "file-format" description to say default is 'wal'
pkg/metricstore/checkpoint.go
Replaced dynamic time.ParseDuration(Keys.Checkpoints.Interval) with const checkpointInterval = 12 * time.Hour
pkg/metricstore/archive.go
User
Verification
go build ./... — must compile without errors
go test ./pkg/metricstore/... — existing tests must pass
Verify JSON schema validation still accepts a config without "interval" in checkpoints/cleanup
Verify that a config with the old "interval" field is silently ignored (Go JSON unmarshal ignores unknown fields — but here the field is removed from the struct, so it will be ignored)
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/jan/.claude/projects/-Users-jan-prg-ClusterCockpit-cc-backend/e7e4183c-0858-4bcb-8163-764db66ef417.jsonl
User
Critical Files
pkg/metricstore/config.go — struct definitions and defaults
pkg/metricstore/configSchema.go — JSON schema for validation
go test ./pkg/metricstore/... — existing tests must pass
Verify JSON schema validation still accepts a config without "interval" in checkpoints/cleanup
Verify that a config with the old "interval" field is silently ignored (Go JSON unmarshal ignores unknown fields — but here the field is removed from the struct, so it will be ignored)
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/jan/.claude/projects/-Users-jan-prg-ClusterCockpit-cc-backend/e7e4183c-0858-4bcb-8163-764db66ef417.jsonl
Simplified CleanUp() to always pass Keys.RetentionInMemory as interval (both archive and delete modes)
configs/config.json — removed "interval": "12h" from checkpoints, "interval": "48h" from cleanup
configs/config-demo.json — removed "file-format": "wal" and "interval": "12h" from checkpoints (now both are defaults)
Remove Interval string field from Cleanup struct (with its json:"interval" tag)
Change default FileFormat from "json" to "wal" in the Keys var
Update doc comments on both structs and the Keys hierarchy comment
2. pkg/metricstore/configSchema.go
Remove "interval" property from the checkpoints object properties
Remove "interval" from "required": ["interval"] in checkpoints (make required empty or remove it)
Remove "interval" property from the cleanup object properties
Remove "interval" from the conditional "then": { "required": ["interval", "directory"] } → only "directory" remains required for archive mode
Update the "file-format" description to say default is 'wal'
3. pkg/metricstore/checkpoint.go
Replace dynamic interval parsing with a hardcoded 12h constant:
go
// Before
d, err := time.ParseDuration(Keys.Checkpoints.Interval)
if err != nil { cclog.Fatalf(...) }
if d <= 0 { cclog.Warnf(...); return }
// After
const checkpointInterval = 12 * time.Hour
d := checkpointInterval
Remove the err variable and validation block. The ticker and rest of the function stay unchanged.
4. pkg/metricstore/archive.go
Simplify CleanUp() to always use Keys.RetentionInMemory as the interval: