volume.tier.move: passing non-empty disk type

This commit is contained in:
Chris Lu
2021-02-22 01:59:03 -08:00
parent 5da63e045e
commit 30b30b8fe0
3 changed files with 11 additions and 4 deletions

View File

@@ -61,7 +61,7 @@ func (vs *VolumeServer) VolumeCopy(ctx context.Context, req *volume_server_pb.Vo
} }
location := vs.store.FindFreeLocation(types.ToDiskType(diskType)) location := vs.store.FindFreeLocation(types.ToDiskType(diskType))
if location == nil { if location == nil {
return fmt.Errorf("no space left") return fmt.Errorf("no space left for disk type %s", types.ToDiskType(diskType).ReadableString())
} }
dataBaseFileName = storage.VolumeFileName(location.Directory, volFileInfoResp.Collection, int(req.VolumeId)) dataBaseFileName = storage.VolumeFileName(location.Directory, volFileInfoResp.Collection, int(req.VolumeId))

View File

@@ -116,7 +116,7 @@ func doVolumeTierMove(commandEnv *CommandEnv, writer io.Writer, collection strin
if sourceVolumeServer == "" { if sourceVolumeServer == "" {
continue continue
} }
fmt.Fprintf(writer, "moving volume %d %s from %s to dataNode %s with disk type ...\n", vid, sourceVolumeServer, dst.dataNode.Id, toDiskType.String()) fmt.Fprintf(writer, "moving volume %d from %s to %s with disk type %s ...\n", vid, sourceVolumeServer, dst.dataNode.Id, toDiskType.ReadableString())
hasFoundTarget = true hasFoundTarget = true
if !applyChanges { if !applyChanges {
@@ -127,7 +127,7 @@ func doVolumeTierMove(commandEnv *CommandEnv, writer io.Writer, collection strin
if err = markVolumeReadonly(commandEnv.option.GrpcDialOption, vid, locations); err != nil { if err = markVolumeReadonly(commandEnv.option.GrpcDialOption, vid, locations); err != nil {
return fmt.Errorf("mark volume %d as readonly on %s: %v", vid, locations[0].Url, err) return fmt.Errorf("mark volume %d as readonly on %s: %v", vid, locations[0].Url, err)
} }
if err = LiveMoveVolume(commandEnv.option.GrpcDialOption, vid, sourceVolumeServer, dst.dataNode.Id, 5*time.Second, toDiskType.String()); err != nil { if err = LiveMoveVolume(commandEnv.option.GrpcDialOption, vid, sourceVolumeServer, dst.dataNode.Id, 5*time.Second, toDiskType.ReadableString()); err != nil {
return fmt.Errorf("move volume %d %s => %s : %v", vid, locations[0].Url, dst.dataNode.Id, err) return fmt.Errorf("move volume %d %s => %s : %v", vid, locations[0].Url, dst.dataNode.Id, err)
} }
@@ -143,7 +143,7 @@ func doVolumeTierMove(commandEnv *CommandEnv, writer io.Writer, collection strin
} }
if !hasFoundTarget { if !hasFoundTarget {
fmt.Fprintf(writer, "can not find disk type %s for volume %d\n", toDiskType.String(), vid) fmt.Fprintf(writer, "can not find disk type %s for volume %d\n", toDiskType.ReadableString(), vid)
} }
return nil return nil

View File

@@ -31,3 +31,10 @@ func (diskType DiskType) String() string {
} }
return string(diskType) return string(diskType)
} }
func (diskType DiskType) ReadableString() string {
if diskType == "" {
return "hdd"
}
return string(diskType)
}