admin: configure maintenance tasks via admin.toml (#9926)

* admin: configure maintenance tasks via admin.toml

Maintenance task settings could only be edited in the admin UI and live
under <dataDir>/conf, so they silently reverted to defaults whenever the
data directory was recreated. An optional admin.toml now declares vacuum,
balance, and erasure coding settings; keys set there are written through
to the persisted task configs at every startup, overriding UI edits, so
the configuration stays declarative. Generate an example with
"weed scaffold -config=admin".

* vacuum: round min volume age up to whole hours

MinVolumeAgeSeconds was truncated by integer division when converted to
the hour-granular protobuf field, so a sub-hour setting silently became
0 and disabled the age guard.

* admin: split and normalize preferred_tags from admin.toml

A comma-separated string, as set via environment variable, came through
viper as a single slice element. Split on commas and reuse
util.NormalizeTagList, matching the plugin config path.

* scaffold: clarify admin.toml wording
This commit is contained in:
Chris Lu authored and GitHub committed 2026-06-11 11:04:52 -07:00
1 parent 42030381ae
commit 37962e2445
9 files changed
+312 -6

No files matched your search

+19 -1
View File
@@ -171,8 +171,17 @@ var cmdAdmin = &Command{
- Metrics are disabled when -metricsPort is 0 (the default)
- Example: weed admin -metricsPort=9327 -master="localhost:9333"
Maintenance Configuration:
- An optional admin.toml declares maintenance task settings
([maintenance.vacuum], [maintenance.balance], [maintenance.erasure_coding])
- Settings in admin.toml are applied at every startup, overriding values
saved from the admin UI, so they can be managed declaratively
- Requires -dataDir; values can also be set via WEED_* environment
variables, e.g. WEED_MAINTENANCE_VACUUM_GARBAGE_THRESHOLD=0.3
- Generate example admin.toml: weed scaffold -config=admin
Configuration File:
- The security.toml file is read from ".", "$HOME/.seaweedfs/",
- The security.toml and admin.toml files are read from ".", "$HOME/.seaweedfs/",
"/usr/local/etc/seaweedfs/", or "/etc/seaweedfs/", in that order
- Generate example security.toml: weed scaffold -config=security
@@ -191,6 +200,9 @@ func runAdmin(cmd *Command, args []string) bool {
// Load security configuration
util.LoadSecurityConfiguration()
// Optional admin.toml with maintenance task settings
util.LoadConfiguration("admin", false)
// Apply security.toml / env var fallbacks for credential flags.
// CLI flags take precedence over security.toml / WEED_* env vars.
applyViperFallback(cmd, a.adminUser, "adminUser", "admin.user")
@@ -337,6 +349,12 @@ func startAdminServer(ctx context.Context, options AdminOptions, enableUI bool,
glog.Infof("Data directory created/verified: %s", dataDir)
}
// Write maintenance task settings from admin.toml into the persisted
// task configs before the server loads them
if err := dash.NewConfigPersistence(dataDir).ApplyMaintenanceConfigFromToml(util.GetViper()); err != nil {
return fmt.Errorf("apply admin.toml: %w", err)
}
// Detect TLS configuration to set Secure cookie flag
cookieSecure := viper.GetString("https.admin.key") != ""