From b2dd93eac8d73197fd4642dd92c93118f64067cd Mon Sep 17 00:00:00 2001 From: MorezMartin Date: Sun, 15 Nov 2026 22:46:14 +0100 Subject: [PATCH] admin: support [maintenance.s3_lifecycle] in admin.toml (#12661) * admin: support [maintenance.s3_lifecycle] in admin.toml The admin.toml overlay covers vacuum, volume_balance and erasure_coding but not s3_lifecycle, so the bucket lifecycle job's settings can only be changed from the web UI and are lost whenever the admin data directory does not persist. That is the worst combination for this job type: its meta_log_retention_days knob decides whether bucket rules ever apply to objects written before the job was enabled, and silently reverting it to the default makes the rules no-op without any error. Wire the four admin-side knobs into the existing overlay: meta_log_retention_days retention window the meta-log replay can reach walker_interval_minutes minimum gap between full bucket walks cluster_deletes_per_second cluster-wide delete budget cluster_deletes_burst token-bucket burst for that budget All four are admin config values, not worker values: the engine partition is computed on the admin side and the delete budget is divided across execute-capable workers at dispatch time. enabled/retry_limit/ retry_backoff_seconds come for free from the shared section handling. Tested with TestApplyPluginConfigFromTomlS3Lifecycle, which also pins the retention=0 case: 0 means unbounded and must survive as an explicit 0 rather than being treated as unset. * admin: fix meta_log_retention_days guidance in admin.toml scaffold Both reviewers caught a real error. `0` is not "unbounded": runShard does retentionWindow := cfg.RetentionWindow if retentionWindow <= 0 { retentionWindow = maxTTL } so zero falls back to the longest rule TTL, which keeps every replay rule in replay and promotes nothing to the walk set. Recommending 0 to force full scans was wrong, and so was the claim that pre-existing objects are only reachable through the walk set -- the cold-start recovery walk covers them regardless of the retention value. Describe zero as "no retention info supplied" and tell operators to set the window the filer meta-log actually retains. The code change is unaffected: it only wires the four keys into the existing overlay. * admin: tie s3_lifecycle walk-set scans to walker_interval_minutes in admin.toml Co-Authored-By: Claude Opus 5.5 * admin: show the s3_lifecycle retry defaults in admin.toml The s3_lifecycle descriptor sets no retry limit or backoff, so a failed run is not retried and the scheduler's 5 s backoff applies; the scaffold listed the vacuum values instead. Co-Authored-By: Claude Opus 5.5 * admin: shorten the s3_lifecycle toml section comment The retention and walker knobs are read by the worker from the admin values, not computed on the admin side. Co-Authored-By: Claude Opus 5.5 * admin: cover cluster_deletes_burst in the s3_lifecycle toml test Co-Authored-By: Claude Opus 5.5 * admin: check the s3_lifecycle retention zero is a stored int64 Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Chris Lu Co-authored-by: Claude Opus 5.5 --- weed/admin/dash/config_toml.go | 11 ++++++ weed/admin/dash/config_toml_test.go | 53 +++++++++++++++++++++++++++++ weed/command/scaffold/admin.toml | 23 +++++++++++++ 3 files changed, 87 insertions(+) diff --git a/weed/admin/dash/config_toml.go b/weed/admin/dash/config_toml.go index a47c777617..857e7b0968 100644 --- a/weed/admin/dash/config_toml.go +++ b/weed/admin/dash/config_toml.go @@ -256,6 +256,17 @@ var pluginConfigSections = []pluginConfigSection{ "collection_filter": stringValue, }, }, + { + // s3_lifecycle has no worker config form; its knobs are admin values + jobType: "s3_lifecycle", + prefix: "maintenance.s3_lifecycle", + adminKeys: map[string]func(v TomlConfig, key string) *plugin_pb.ConfigValue{ + "meta_log_retention_days": int64Value, + "walker_interval_minutes": int64Value, + "cluster_deletes_per_second": int64Value, + "cluster_deletes_burst": int64Value, + }, + }, } func doubleValue(v TomlConfig, key string) *plugin_pb.ConfigValue { diff --git a/weed/admin/dash/config_toml_test.go b/weed/admin/dash/config_toml_test.go index e3ff08f9eb..51ac0ca3f1 100644 --- a/weed/admin/dash/config_toml_test.go +++ b/weed/admin/dash/config_toml_test.go @@ -401,3 +401,56 @@ max_shard_transfers = 0 t.Fatalf("max_shard_transfers = %d, want 0", got.GetInt64Value()) } } + +func TestApplyPluginConfigFromTomlS3Lifecycle(t *testing.T) { + s := newPluginServer(t) + seed := &plugin_pb.PersistedJobTypeConfig{ + JobType: "s3_lifecycle", + AdminRuntime: &plugin_pb.AdminRuntimeConfig{Enabled: true, RetryLimit: 1}, + AdminConfigValues: map[string]*plugin_pb.ConfigValue{ + "meta_log_retention_days": {Kind: &plugin_pb.ConfigValue_Int64Value{Int64Value: 7}}, + }, + } + if err := s.GetPlugin().SaveJobTypeConfig(seed); err != nil { + t.Fatalf("seed: %v", err) + } + + v := tomlConfig(t, ` +[maintenance.s3_lifecycle] +meta_log_retention_days = 0 +walker_interval_minutes = 30 +cluster_deletes_per_second = 50 +cluster_deletes_burst = 200 +retry_limit = 3 +`) + if err := s.ApplyPluginConfigFromToml(v); err != nil { + t.Fatalf("apply: %v", err) + } + + cfg, err := s.GetPlugin().LoadJobTypeConfig("s3_lifecycle") + if err != nil || cfg == nil { + t.Fatalf("load: %v %v", cfg, err) + } + // an explicit 0 must replace the saved value, not read as unset + if got, ok := cfg.AdminConfigValues["meta_log_retention_days"].GetKind().(*plugin_pb.ConfigValue_Int64Value); !ok || got.Int64Value != 0 { + t.Errorf("meta_log_retention_days = %v, want int64 0", cfg.AdminConfigValues["meta_log_retention_days"]) + } + if got := cfg.AdminConfigValues["walker_interval_minutes"].GetInt64Value(); got != 30 { + t.Errorf("walker_interval_minutes = %d, want 30", got) + } + if got := cfg.AdminConfigValues["cluster_deletes_per_second"].GetInt64Value(); got != 50 { + t.Errorf("cluster_deletes_per_second = %d, want 50", got) + } + if got := cfg.AdminConfigValues["cluster_deletes_burst"].GetInt64Value(); got != 200 { + t.Errorf("cluster_deletes_burst = %d, want 200", got) + } + if cfg.AdminRuntime.RetryLimit != 3 { + t.Errorf("retry_limit = %d, want 3", cfg.AdminRuntime.RetryLimit) + } + if !cfg.AdminRuntime.Enabled { + t.Errorf("enabled flipped off by unrelated toml keys") + } + if cfg.UpdatedBy != "admin.toml" { + t.Errorf("updated_by = %q, want admin.toml", cfg.UpdatedBy) + } +} diff --git a/weed/command/scaffold/admin.toml b/weed/command/scaffold/admin.toml index 3f43b4b439..29e074544e 100644 --- a/weed/command/scaffold/admin.toml +++ b/weed/command/scaffold/admin.toml @@ -76,3 +76,26 @@ # retry_limit = 1 # seconds to wait between retry attempts # retry_backoff_seconds = 30 + +[maintenance.s3_lifecycle] +# enabled = true +# How far back the filer meta-log subscription can reliably reach, in days. +# Rules whose TTL exceeds this window cannot be serviced by replay alone and +# are partitioned into the walk set, which steady-state walks scan in full, +# subject to walker_interval_minutes. +# 0 means "no retention info supplied": the run then falls back to the longest +# rule TTL, which keeps every replay rule in replay and promotes nothing. +# Set this to the window the filer meta-log actually retains. +# meta_log_retention_days = 0 +# Minimum minutes between steady-state bucket walks per shard. Cold-start and +# recovery walks ignore it. 0 walks on every run. +# walker_interval_minutes = 0 +# Cluster-wide delete budget in delete RPCs per second, divided across +# execute-capable workers at dispatch time. 0 means unlimited. +# cluster_deletes_per_second = 0 +# Token-bucket burst for the delete budget. 0 means 2 x per-second. +# cluster_deletes_burst = 0 +# max retry attempts for a failed lifecycle run +# retry_limit = 0 +# seconds to wait between retry attempts +# retry_backoff_seconds = 5