Disregard healing disks in crawling (#10349)

When crawling never use a disk we know is healing.

Most of the change involves keeping track of the original endpoint on xlStorage
and this also fixes DiskInfo.Endpoint never being populated.

Heal master will print `data-crawl: Disk "http://localhost:9001/data/mindev/data2/xl1" is 
Healing, skipping` once on a cycle (no more often than every 5m).
This commit is contained in:
Klaus Post
2020-08-25 10:55:15 -07:00
committed by GitHub
parent 7d50a0cfea
commit 17a1eda702
8 changed files with 65 additions and 25 deletions

View File

@@ -26,6 +26,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
slashpath "path"
"path/filepath"
@@ -91,6 +92,7 @@ type xlStorage struct {
diskPath string
hostname string
endpoint string
pool sync.Pool
@@ -233,7 +235,18 @@ func isDirEmpty(dirname string) bool {
}
// Initialize a new storage disk.
func newXLStorage(path string, hostname string) (*xlStorage, error) {
func newLocalXLStorage(path string) (*xlStorage, error) {
u := url.URL{Path: path}
return newXLStorage(Endpoint{
URL: &u,
IsLocal: true,
})
}
// Initialize a new storage disk.
func newXLStorage(ep Endpoint) (*xlStorage, error) {
path := ep.Path
hostname := ep.Host
var err error
if path, err = getValidPath(path, true); err != nil {
return nil, err
@@ -247,6 +260,7 @@ func newXLStorage(path string, hostname string) (*xlStorage, error) {
p := &xlStorage{
diskPath: path,
hostname: hostname,
endpoint: ep.String(),
pool: sync.Pool{
New: func() interface{} {
b := disk.AlignedBlock(readBlockSize)
@@ -422,6 +436,7 @@ func (s *xlStorage) DiskInfo() (info DiskInfo, err error) {
Used: di.Total - di.Free,
RootDisk: s.rootDisk,
MountPath: s.diskPath,
Endpoint: s.endpoint,
}
diskID, err := s.GetDiskID()