server: save and compare multiple disks are used (#1474)

When server is run with multiple disks which uses xl interface where
order and count of disks are important, this patch saves such disks
configuration and compares in next run if there is a mismatch.

Fixes #1458
This commit is contained in:
Bala FA
2016-05-05 00:48:20 +05:30
committed by Harshavardhana
parent e4d89d8156
commit da3a53376c
4 changed files with 163 additions and 6 deletions

View File

@@ -17,7 +17,9 @@
package main
import (
"fmt"
"net/http"
"reflect"
router "github.com/gorilla/mux"
)
@@ -36,6 +38,26 @@ func newObjectLayer(exportPaths ...string) (ObjectLayer, error) {
// configureServer handler returns final handler for the http server.
func configureServerHandler(srvCmdConfig serverCmdConfig) http.Handler {
// FIXME: currently we don't check single exportPath which uses FS layer.
if len(srvCmdConfig.exportPaths) > 1 {
if isFormatConfigFileExists() {
format, err := getFormatXL()
if err != nil {
fatalIf(err, "Failed to read format.json", nil)
}
if !reflect.DeepEqual(format.Disks, srvCmdConfig.exportPaths) {
err = fmt.Errorf("Number of export paths from command-line did not match the backend configuration. Backend is configured with [%s] exports.", format.Disks)
fatalIf(err, "", nil)
}
} else {
// First run: save disk configuration
if err := saveFormatXL(xlFormat{Version: "1", Disks: srvCmdConfig.exportPaths}); err != nil {
fatalIf(err, "Unable to save 'format.json'", nil)
}
}
}
objAPI, err := newObjectLayer(srvCmdConfig.exportPaths...)
fatalIf(err, "Initializing object layer failed.", nil)