Browse Source
feat(plugin): DC/rack/node filtering for volume balance (#8621)
feat(plugin): DC/rack/node filtering for volume balance (#8621)
* feat(plugin): add DC/rack/node filtering for volume balance detection Add scoping filters so balance detection can be limited to specific data centers, racks, or nodes. Filters are applied both at the metrics level (in the handler) and at the topology seeding level (in detection) to ensure only the targeted infrastructure participates in balancing. * address PR review: use set lookups, deduplicate test helpers, add target checks * address review: assert non-empty tasks in filter tests Prevent vacuous test passes by requiring len(tasks) > 0 before checking source/target exclusions. * address review: enforce filter scope in fallback, clarify DC filter - Thread allowedServers into createBalanceTask so the fallback planner cannot produce out-of-scope targets when DC/rack/node filters are active - Update data_center_filter description to clarify single-DC usage * address review: centralize parseCSVSet, fix filter scope leak, iterate all targets - Extract ParseCSVSet to shared weed/worker/tasks/util package, remove duplicates from detection.go and volume_balance_handler.go - Fix metric accumulation re-introducing filtered-out servers by only counting metrics for servers that passed DC/rack/node filters - Trim DataCenterFilter before matching to handle trailing spaces - Iterate all task.TypedParams.Targets in filter tests, not just [0] * remove useless descriptor string testpull/8626/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 283 additions and 2 deletions
-
71weed/plugin/worker/volume_balance_handler.go
-
39weed/plugin/worker/volume_balance_handler_test.go
-
3weed/worker/tasks/balance/config.go
-
42weed/worker/tasks/balance/detection.go
-
110weed/worker/tasks/balance/detection_test.go
-
20weed/worker/tasks/util/csv.go
@ -0,0 +1,20 @@ |
|||
package util |
|||
|
|||
import "strings" |
|||
|
|||
// ParseCSVSet splits a comma-separated string into a set of trimmed,
|
|||
// non-empty values. Returns nil if the input is empty.
|
|||
func ParseCSVSet(csv string) map[string]bool { |
|||
csv = strings.TrimSpace(csv) |
|||
if csv == "" { |
|||
return nil |
|||
} |
|||
set := make(map[string]bool) |
|||
for _, item := range strings.Split(csv, ",") { |
|||
trimmed := strings.TrimSpace(item) |
|||
if trimmed != "" { |
|||
set[trimmed] = true |
|||
} |
|||
} |
|||
return set |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue