mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 20:52:50 +08:00
weed/shell: Cluster check other disk types (#5245)
* week/shell: Cluster check other disk types The `cluster.check` command only took the empty (`""`) and `hdd` disk types into consideration, but a cluster with only `ssd` or `nvme` disk types would be equally valid. This commit simply checks that _any_ disk type is defined, and that some volumes are available for it. Signed-off-by: Benoît Knecht <bknecht@protonmail.ch> * weed/shell: Replace loop that copies slice Use the following construct instead of a `for` loop: ```golang x = append(x, y...) ``` See https://staticcheck.dev/docs/checks#S1011. Signed-off-by: Benoît Knecht <bknecht@protonmail.ch> * weed/shell: Check disk types when filer is in use Filer stores its metadata logs in generic (i.e. `""`) or HDD disk type volumes, so make sure those disk types exist and have volumes associated with them when Filer is deployed in the cluster. Signed-off-by: Benoît Knecht <bknecht@protonmail.ch> --------- Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
This commit is contained in:
parent
0775d05a23
commit
56287bd07d
@ -46,13 +46,13 @@ func (c *commandClusterCheck) Do(args []string, commandEnv *CommandEnv, writer i
|
||||
}
|
||||
fmt.Fprintf(writer, "Topology volumeSizeLimit:%d MB%s\n", volumeSizeLimitMb, diskInfosToString(topologyInfo.DiskInfos))
|
||||
|
||||
emptyDiskTypeDiskInfo, emptyDiskTypeFound := topologyInfo.DiskInfos[""]
|
||||
hddDiskTypeDiskInfo, hddDiskTypeFound := topologyInfo.DiskInfos["hdd"]
|
||||
if !emptyDiskTypeFound && !hddDiskTypeFound {
|
||||
return fmt.Errorf("Need to a hdd disk type!")
|
||||
if len(topologyInfo.DiskInfos) == 0 {
|
||||
return fmt.Errorf("no disk type defined")
|
||||
}
|
||||
if emptyDiskTypeFound && emptyDiskTypeDiskInfo.MaxVolumeCount == 0 || hddDiskTypeFound && hddDiskTypeDiskInfo.MaxVolumeCount == 0 {
|
||||
return fmt.Errorf("Need to a hdd disk type!")
|
||||
for diskType, diskInfo := range topologyInfo.DiskInfos {
|
||||
if diskInfo.MaxVolumeCount == 0 {
|
||||
return fmt.Errorf("no volume available for \"%s\" disk type", diskType)
|
||||
}
|
||||
}
|
||||
|
||||
// collect filers
|
||||
@ -73,6 +73,19 @@ func (c *commandClusterCheck) Do(args []string, commandEnv *CommandEnv, writer i
|
||||
}
|
||||
fmt.Fprintf(writer, "the cluster has %d filers: %+v\n", len(filers), filers)
|
||||
|
||||
if len(filers) > 0 {
|
||||
genericDiskInfo, genericDiskInfoOk := topologyInfo.DiskInfos[""]
|
||||
hddDiskInfo, hddDiskInfoOk := topologyInfo.DiskInfos["hdd"]
|
||||
|
||||
if !genericDiskInfoOk && !hddDiskInfoOk {
|
||||
return fmt.Errorf("filer metadata logs need generic or hdd disk type to be defined")
|
||||
}
|
||||
|
||||
if (genericDiskInfoOk && genericDiskInfo.MaxVolumeCount == 0) || (hddDiskInfoOk && hddDiskInfo.MaxVolumeCount == 0) {
|
||||
return fmt.Errorf("filer metadata logs need generic or hdd volumes to be available")
|
||||
}
|
||||
}
|
||||
|
||||
// collect volume servers
|
||||
var volumeServers []pb.ServerAddress
|
||||
t, _, err := collectTopologyInfo(commandEnv, 0)
|
||||
@ -90,9 +103,7 @@ func (c *commandClusterCheck) Do(args []string, commandEnv *CommandEnv, writer i
|
||||
|
||||
// collect all masters
|
||||
var masters []pb.ServerAddress
|
||||
for _, master := range commandEnv.MasterClient.GetMasters() {
|
||||
masters = append(masters, master)
|
||||
}
|
||||
masters = append(masters, commandEnv.MasterClient.GetMasters()...)
|
||||
|
||||
// check from master to volume servers
|
||||
for _, master := range masters {
|
||||
|
Loading…
Reference in New Issue
Block a user