mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 12:10:24 +03:00
objectLayer: Check for format.json in a wrapped disk. (#3311)
This is needed to validate if the `format.json` indeed exists when a fresh node is brought online. This wrapped implementation also connects to the remote node by attempting a re-login. Subsequently after a successful connect `format.json` is validated as well. Fixes #3207
This commit is contained in:
@@ -28,7 +28,7 @@ import (
|
||||
// Programmed errors are stored in errors field.
|
||||
type naughtyDisk struct {
|
||||
// The real disk
|
||||
disk *posix
|
||||
disk *retryStorage
|
||||
// Programmed errors: API call number => error to return
|
||||
errors map[int]error
|
||||
// The error to return when no error value is programmed
|
||||
@@ -39,7 +39,7 @@ type naughtyDisk struct {
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func newNaughtyDisk(d *posix, errs map[int]error, defaultErr error) *naughtyDisk {
|
||||
func newNaughtyDisk(d *retryStorage, errs map[int]error, defaultErr error) *naughtyDisk {
|
||||
return &naughtyDisk{disk: d, errors: errs, defaultErr: defaultErr}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,20 @@ func (d *naughtyDisk) String() string {
|
||||
return d.disk.String()
|
||||
}
|
||||
|
||||
func (d *naughtyDisk) Init() (err error) {
|
||||
if err = d.calcError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return d.disk.Init()
|
||||
}
|
||||
|
||||
func (d *naughtyDisk) Close() (err error) {
|
||||
if err = d.calcError(); err != nil {
|
||||
return err
|
||||
}
|
||||
return d.disk.Close()
|
||||
}
|
||||
|
||||
func (d *naughtyDisk) calcError() (err error) {
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user