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))
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))

View file

@ -116,7 +116,7 @@ func doVolumeTierMove(commandEnv *CommandEnv, writer io.Writer, collection strin
if sourceVolumeServer == "" {
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
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 {
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)
}
@ -143,7 +143,7 @@ func doVolumeTierMove(commandEnv *CommandEnv, writer io.Writer, collection strin
}
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

View file

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