admin: honor a persisted or admin.toml maintenance enabled=false (#10909)

* admin: honor a persisted or admin.toml maintenance enabled=false

The startup path discarded an operator's enabled=false twice over:
ApplyDefaultsToProtobuf treated the bool zero value as unset and applied
the schema default of true, and a force-enable migration block flipped
any survivor. With the legacy /maintenance UI routes gone, nothing could
write the config either, so the maintenance system ran unconditionally.

Keep the persisted enabled flag across schema-default application in
LoadMaintenanceConfig, drop the force-enable block, and add a top-level
[maintenance] enabled key to admin.toml as the config surface, persisted
through SaveMaintenanceConfig like the per-task settings. Absent config
still defaults to enabled.

* admin: track presence on the maintenance enabled flag

A plain proto3 bool cannot distinguish an operator's persisted false
from a legacy file that simply omits the field, so honoring false would
have silently switched maintenance off for configs written before the
toggle could be persisted. Make the field optional: files that predate
presence tracking keep the enabled default, while a file that explicitly
persists the toggle is honored either way.
This commit is contained in:
Chris Lu authored and GitHub committed 2026-08-24 00:01:48 -07:00
1 parent e931cccc7b
commit 68ec8ca655
11 files changed
+169 -39

No files matched your search

+3 -2
View File
@@ -177,8 +177,9 @@ var cmdAdmin = &Command{
- 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])
- An optional admin.toml declares maintenance settings ([maintenance]
to toggle the whole system, plus per-task [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