mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
* admin/maintenance: report whether the running manager queues a task type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: list the EC balancers that are active at the same time The plugin ec_balance job, the legacy maintenance manager's ec_balance task and an admin_script job that runs ec.balance -apply each plan shard moves from the same topology without knowing about the others. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: log a warning while more than one EC balancer is active The check runs on the maintenance metrics tick and logs again only when the set of active balancers changes. The legacy maintenance entry names the admin.toml switch that turns it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: warn on the plugin pages when more than one EC balancer is active The scheduler status API returns the active EC balancers, and the scheduler banner on the plugin and lane pages lists them when there are two or more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/maintenance: count a task type only when a registered worker can run it Only legacy maintenance workers pull tasks from the legacy queue. With plugin workers alone, the queued ec_balance tasks never run, so they do not compete with the plugin ec_balance job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: parse ec.balance apply flags like the flag package A value counts only when strconv.ParseBool reads it as true, and a # token ends the arguments, as it does for the shell command's flag parser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin/maintenance: skip legacy workers past their heartbeat timeout A disconnected worker keeps its queue record until the cleanup loop removes it, so the capability check also requires a heartbeat within the worker timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: count ec.balance only when its flags parse the way the command parses them An invalid boolean in -apply or -force fails the whole command, the last value of a flag wins, -force overrides -apply, and parsing stops at the first non-flag argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: share ec.balance's flag set and report whether its arguments apply the plan Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: count an admin_script ec.balance only when ec.balance accepts its flags Unknown flags and invalid values of any flag fail the command before it can move shards, so they no longer count as an active balancer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell, plugin/worker: move admin_script command tokenizing into the shell package Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: split admin_script ec.balance arguments with the executor's tokenizer A quoted value with spaces is one argument to ec.balance, so flags after it are still seen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: report through one lookup whether a command's arguments change the cluster ec.balance now also rejects an invalid -volumeIds, as its Do does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: report whether volume.balance arguments apply its plan Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: report whether ec.encode accepts its arguments ec.encode has no dry run, so any accepted invocation changes the cluster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: report whether volume.vacuum accepts its arguments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: report overlap for every maintenance work that more than one scheduler runs The plugin scheduler, the legacy maintenance manager, and an admin_script can each run volume balance, EC balance, EC encoding, and vacuum. Check all four from one table and report each work with two or more active runners, in the log and in the scheduler-status API as maintenance_overlaps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin: show each maintenance overlap on the plugin pages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
4.6 KiB
Go
109 lines
4.6 KiB
Go
package dash
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/types"
|
|
)
|
|
|
|
func TestScriptAppliedCommands(t *testing.T) {
|
|
cases := []struct {
|
|
script string
|
|
want bool
|
|
}{
|
|
{"", false},
|
|
{"fs.log.purge -daysAgo=7\nvolume.fix.replication -apply", false},
|
|
{"ec.balance", false},
|
|
{"ec.balance -collection=x", false},
|
|
{"ec.balance -apply", true},
|
|
{"ec.balance -force", true},
|
|
{"ec.balance --apply", true},
|
|
{"ec.balance -apply=true", true},
|
|
{"ec.balance -apply=false", false},
|
|
{"ec.balance -apply=FALSE", false},
|
|
{"ec.balance -apply=T", true},
|
|
{"ec.balance -apply=maybe", false},
|
|
{"ec.balance -collection=a # add -apply later", false},
|
|
{"ec.balance -apply=false # use -apply for writes", false},
|
|
{"# ec.balance -apply", false},
|
|
{"volume.list; ec.balance -collection=a -apply", true},
|
|
{"ec.rebuild -apply\r\nec.balance -apply\r\n", true},
|
|
{"ec.balancer -apply", false},
|
|
{"ec.balance -apply=maybe -force", false},
|
|
{"ec.balance -apply -force=maybe", false},
|
|
{"ec.balance -apply -force=false", false},
|
|
{"ec.balance -force=false -apply", false},
|
|
{"ec.balance -apply -apply=false", false},
|
|
{"ec.balance -collection x -apply", true},
|
|
{"ec.balance -collection -apply", false},
|
|
{"ec.balance x -apply", false},
|
|
{"ec.balance -collection \"a b\" -apply", true},
|
|
{"ec.balance -collection 'a b' -force", true},
|
|
{"ec.balance -collection #x -apply", true},
|
|
{"ec.balance -bogus -apply", false},
|
|
{"ec.balance -maxParallelization=x -apply", false},
|
|
{"ec.balance -maxParallelization 4 -apply", true},
|
|
{"ec.balance -volumeIds=x -apply", false},
|
|
}
|
|
for _, c := range cases {
|
|
if got := scriptAppliedCommands(c.script)["ec.balance"]; got != c.want {
|
|
t.Errorf("scriptAppliedCommands(%q) has ec.balance = %v, want %v", c.script, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestScriptAppliedCommandsAcrossWork(t *testing.T) {
|
|
got := scriptAppliedCommands("volume.balance -apply\nec.encode -collection=a\nvolume.vacuum -garbageThreshold=0.2\nvolume.fix.replication -apply\nvolume.list")
|
|
want := map[string]bool{"volume.balance": true, "ec.encode": true, "volume.vacuum": true}
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Errorf("scriptAppliedCommands = %v, want %v", got, want)
|
|
}
|
|
if got := scriptAppliedCommands("volume.balance\nec.encode -quietFor=soon"); len(got) != 0 {
|
|
t.Errorf("dry-run and rejected commands counted: %v", got)
|
|
}
|
|
}
|
|
|
|
func TestMaintenanceOverlaps(t *testing.T) {
|
|
legacyEC := "legacy maintenance ec_balance task (turn off with enabled = false under [maintenance] in admin.toml)"
|
|
cases := []struct {
|
|
name string
|
|
state maintenanceRunnerState
|
|
want []MaintenanceOverlap
|
|
}{
|
|
{"none", maintenanceRunnerState{}, nil},
|
|
{"plugin only", maintenanceRunnerState{PluginEnabled: map[string]bool{"ec_balance": true, "vacuum": true}}, nil},
|
|
{"disabled script ignored", maintenanceRunnerState{
|
|
PluginEnabled: map[string]bool{"ec_balance": true},
|
|
AdminScript: "ec.balance -apply",
|
|
}, nil},
|
|
{"plugin and legacy on different work", maintenanceRunnerState{
|
|
PluginEnabled: map[string]bool{"vacuum": true},
|
|
LegacyEnabled: map[types.TaskType]bool{types.TaskTypeECBalance: true},
|
|
}, nil},
|
|
{"all three on EC balance", maintenanceRunnerState{
|
|
PluginEnabled: map[string]bool{"ec_balance": true, "admin_script": true},
|
|
LegacyEnabled: map[types.TaskType]bool{types.TaskTypeECBalance: true},
|
|
AdminScriptEnabled: true,
|
|
AdminScript: "ec.balance -apply",
|
|
}, []MaintenanceOverlap{{Work: "EC balance", Runners: []string{"plugin ec_balance job", legacyEC, "admin_script job running ec.balance"}}}},
|
|
{"script overlaps two plugin jobs", maintenanceRunnerState{
|
|
PluginEnabled: map[string]bool{"volume_balance": true, "vacuum": true, "erasure_coding": true, "admin_script": true},
|
|
AdminScriptEnabled: true,
|
|
AdminScript: "volume.balance -force\nvolume.vacuum",
|
|
}, []MaintenanceOverlap{
|
|
{Work: "volume balance", Runners: []string{"plugin volume_balance job", "admin_script job running volume.balance"}},
|
|
{Work: "vacuum", Runners: []string{"plugin vacuum job", "admin_script job running volume.vacuum"}},
|
|
}},
|
|
{"legacy and plugin encoding", maintenanceRunnerState{
|
|
PluginEnabled: map[string]bool{"erasure_coding": true},
|
|
LegacyEnabled: map[types.TaskType]bool{types.TaskTypeErasureCoding: true},
|
|
}, []MaintenanceOverlap{{Work: "EC encoding", Runners: []string{"plugin erasure_coding job", "legacy maintenance erasure_coding task (turn off with enabled = false under [maintenance] in admin.toml)"}}}},
|
|
}
|
|
for _, c := range cases {
|
|
if got := maintenanceOverlaps(c.state); !reflect.DeepEqual(got, c.want) {
|
|
t.Errorf("%s: maintenanceOverlaps = %v, want %v", c.name, got, c.want)
|
|
}
|
|
}
|
|
}
|