config + store: remove dead knobs and stale schema
Three drift items surfaced in review, each dead on arrival and each worth trusting a little more at v0.1.0. config: drop MetricsPollInterval. The field was parsed from TOML (metrics_poll_interval), stored on DaemonConfig, and ignored by every consumer — only StatsPollInterval drives the background poll loop. Users setting it in config.toml saw zero effect. Removed from the TOML surface, the model constant, and the config test. daemon: delete ensureDefaultImage. No callers, body was `_ = ctx; return nil`. Dead since whatever flow used to call it got removed. store: drop packages_path from the images table. The column was carried by the baseline migration but never referenced by UpsertImage (no INSERT / UPDATE mention) or any Go model field — a ghost from a build pipeline that no longer exists. Added migration id=2 (drop_dead_image_columns) with an idempotent dropColumnIfExists helper: fresh installs run baseline (creates the column) + 2 (drops it); legacy DBs where the column was never added get a no-op. Updated the direct-INSERT SQL in TestGetImageRejectsMalformedTimestamp to drop the column reference, and added a migration test covering both install paths (fresh + legacy). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2a7f55f028
commit
129475be20
7 changed files with 159 additions and 56 deletions
|
|
@ -26,7 +26,6 @@ type fileConfig struct {
|
|||
DefaultImageName string `toml:"default_image_name"`
|
||||
AutoStopStaleAfter string `toml:"auto_stop_stale_after"`
|
||||
StatsPollInterval string `toml:"stats_poll_interval"`
|
||||
MetricsPoll string `toml:"metrics_poll_interval"`
|
||||
BridgeName string `toml:"bridge_name"`
|
||||
BridgeIP string `toml:"bridge_ip"`
|
||||
CIDR string `toml:"cidr"`
|
||||
|
|
@ -54,16 +53,15 @@ type vmDefaultsFile struct {
|
|||
|
||||
func Load(layout paths.Layout) (model.DaemonConfig, error) {
|
||||
cfg := model.DaemonConfig{
|
||||
LogLevel: "info",
|
||||
AutoStopStaleAfter: 0,
|
||||
StatsPollInterval: model.DefaultStatsPollInterval,
|
||||
MetricsPollInterval: model.DefaultMetricsPollInterval,
|
||||
BridgeName: model.DefaultBridgeName,
|
||||
BridgeIP: model.DefaultBridgeIP,
|
||||
CIDR: model.DefaultCIDR,
|
||||
TapPoolSize: 4,
|
||||
DefaultDNS: model.DefaultDNS,
|
||||
DefaultImageName: "debian-bookworm",
|
||||
LogLevel: "info",
|
||||
AutoStopStaleAfter: 0,
|
||||
StatsPollInterval: model.DefaultStatsPollInterval,
|
||||
BridgeName: model.DefaultBridgeName,
|
||||
BridgeIP: model.DefaultBridgeIP,
|
||||
CIDR: model.DefaultCIDR,
|
||||
TapPoolSize: 4,
|
||||
DefaultDNS: model.DefaultDNS,
|
||||
DefaultImageName: "debian-bookworm",
|
||||
}
|
||||
|
||||
var file fileConfig
|
||||
|
|
@ -120,13 +118,6 @@ func Load(layout paths.Layout) (model.DaemonConfig, error) {
|
|||
}
|
||||
cfg.StatsPollInterval = duration
|
||||
}
|
||||
if value := strings.TrimSpace(file.MetricsPoll); value != "" {
|
||||
duration, err := time.ParseDuration(value)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
cfg.MetricsPollInterval = duration
|
||||
}
|
||||
if value := strings.TrimSpace(os.Getenv("BANGER_LOG_LEVEL")); value != "" {
|
||||
cfg.LogLevel = value
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ ssh_key_path = "/tmp/custom-key"
|
|||
default_image_name = "void"
|
||||
auto_stop_stale_after = "1h"
|
||||
stats_poll_interval = "15s"
|
||||
metrics_poll_interval = "30s"
|
||||
bridge_name = "br-test"
|
||||
bridge_ip = "10.0.0.1"
|
||||
cidr = "25"
|
||||
|
|
@ -84,9 +83,6 @@ default_dns = "9.9.9.9"
|
|||
if cfg.StatsPollInterval != 15*time.Second {
|
||||
t.Fatalf("StatsPollInterval = %s", cfg.StatsPollInterval)
|
||||
}
|
||||
if cfg.MetricsPollInterval != 30*time.Second {
|
||||
t.Fatalf("MetricsPollInterval = %s", cfg.MetricsPollInterval)
|
||||
}
|
||||
if cfg.BridgeName != "br-test" || cfg.BridgeIP != "10.0.0.1" || cfg.CIDR != "25" {
|
||||
t.Fatalf("bridge config = %+v", cfg)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue