Files
seaweedfs/weed/topology/configuration.go
T
Chris LuandClaude Opus 5.5 b6237dd8b1 master, admin, shell: warn about volume servers left in the default data center or rack (#13066)
* master: warn when a volume server registers in the default data center or rack

A volume server started without -dataCenter or -rack lands in
DefaultDataCenter/DefaultRack. Next to servers with explicit placement it
becomes its own failure domain for placement and balancing. Log a warning
when such a server registers while other servers name their data center,
or other racks of the same data center are named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: warn about volume servers left in the default data center or rack

The Volume Servers page lists the servers that fell back to
DefaultDataCenter or DefaultRack while other servers name theirs, with
their volume and EC shard counts, so the stray failure domain shows up
before placement and balancing act on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* shell: cluster.check warns about volume servers in the default data center or rack

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* shell: cluster.check prints placement warnings before the capacity checks

A disk type with no free slots made cluster.check return before the
default data center/rack warnings were printed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: list each data center's rack once in the default placement check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 15:16:25 -08:00

68 lines
1.4 KiB
Go

package topology
import (
"encoding/xml"
)
const (
DefaultDataCenter = "DefaultDataCenter"
DefaultRack = "DefaultRack"
)
type rack struct {
Name string `xml:"name,attr"`
Ips []string `xml:"Ip"`
}
type dataCenter struct {
Name string `xml:"name,attr"`
Racks []rack `xml:"Rack"`
}
type topology struct {
DataCenters []dataCenter `xml:"DataCenter"`
}
type Configuration struct {
XMLName xml.Name `xml:"Configuration"`
Topo topology `xml:"Topology"`
}
func (c *Configuration) String() string {
if b, e := xml.MarshalIndent(c, " ", " "); e == nil {
return string(b)
}
return ""
}
func (c *Configuration) Locate(ip string, dcName string, rackName string) (dc string, rack string) {
if dcName == "" {
dcName = DefaultDataCenter
}
if rackName == "" {
rackName = DefaultRack
}
return dcName, rackName
}
// DefaultPlacementStandsOut reports whether a node in dcName/rackName fell back
// to the default data center or rack while other nodes name theirs: the default
// data center next to named ones, or the default rack next to named racks of
// the same data center.
func DefaultPlacementStandsOut(dcName, rackName string, dcRacks map[string][]string) bool {
if dcName == DefaultDataCenter {
for dc := range dcRacks {
if dc != DefaultDataCenter {
return true
}
}
}
if rackName == DefaultRack {
for _, r := range dcRacks[dcName] {
if r != DefaultRack {
return true
}
}
}
return false
}