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