aboutsummaryrefslogtreecommitdiff
path: root/weed/pb/volume_info.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-02-02 15:37:23 -0800
committerChris Lu <chris.lu@gmail.com>2020-02-02 15:37:23 -0800
commit40ae533fa34ae6e40fa31d6007e533a23391a5d8 (patch)
tree7fe6ab2c8b30e7cc4df9cd42a67493198aa53ae5 /weed/pb/volume_info.go
parentfb19263a719b07d14f59cf8906c03a2a7d7ca3b8 (diff)
downloadseaweedfs-40ae533fa34ae6e40fa31d6007e533a23391a5d8.tar.xz
seaweedfs-40ae533fa34ae6e40fa31d6007e533a23391a5d8.zip
shell: add volume.configure.replication to change replication for a volume
fix https://github.com/chrislusf/seaweedfs/issues/1192
Diffstat (limited to 'weed/pb/volume_info.go')
-rw-r--r--weed/pb/volume_info.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/weed/pb/volume_info.go b/weed/pb/volume_info.go
index b2edf9c5e..c4f733f5c 100644
--- a/weed/pb/volume_info.go
+++ b/weed/pb/volume_info.go
@@ -15,39 +15,40 @@ import (
)
// MaybeLoadVolumeInfo load the file data as *volume_server_pb.VolumeInfo, the returned volumeInfo will not be nil
-func MaybeLoadVolumeInfo(fileName string) (*volume_server_pb.VolumeInfo, bool) {
+func MaybeLoadVolumeInfo(fileName string) (*volume_server_pb.VolumeInfo, bool, error) {
volumeInfo := &volume_server_pb.VolumeInfo{}
glog.V(1).Infof("maybeLoadVolumeInfo checks %s", fileName)
if exists, canRead, _, _, _ := util.CheckFile(fileName); !exists || !canRead {
if !exists {
- return volumeInfo, false
+ return volumeInfo, false, nil
}
if !canRead {
glog.Warningf("can not read %s", fileName)
+ return volumeInfo, false, fmt.Errorf("can not read %s", fileName)
}
- return volumeInfo, false
+ return volumeInfo, false, nil
}
glog.V(1).Infof("maybeLoadVolumeInfo reads %s", fileName)
tierData, readErr := ioutil.ReadFile(fileName)
if readErr != nil {
glog.Warningf("fail to read %s : %v", fileName, readErr)
- return volumeInfo, false
+ return volumeInfo, false, fmt.Errorf("fail to read %s : %v", fileName, readErr)
}
glog.V(1).Infof("maybeLoadVolumeInfo Unmarshal volume info %v", fileName)
if err := jsonpb.Unmarshal(bytes.NewReader(tierData), volumeInfo); err != nil {
glog.Warningf("unmarshal error: %v", err)
- return volumeInfo, false
+ return volumeInfo, false, fmt.Errorf("unmarshal error: %v", err)
}
if len(volumeInfo.GetFiles()) == 0 {
- return volumeInfo, false
+ return volumeInfo, false, nil
}
- return volumeInfo, true
+ return volumeInfo, true, nil
}
func SaveVolumeInfo(fileName string, volumeInfo *volume_server_pb.VolumeInfo) error {