Skip to content

Commit

Permalink
[Disk Manager] rename FilesystemStorageKind to FilesystemKind to make…
Browse files Browse the repository at this point in the history
… it consistent with DiskKind (#1856)
  • Loading branch information
SvartMetal authored Aug 23, 2024
1 parent 07001df commit 036e38b
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 58 deletions.
14 changes: 7 additions & 7 deletions cloud/disk_manager/api/filesystem_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ service FilesystemService {
rpc DescribeModel(DescribeFilesystemModelRequest) returns (FilesystemModel) {}
}

enum FilesystemStorageKind {
FILESYSTEM_STORAGE_KIND_UNSPECIFIED = 0;
FILESYSTEM_STORAGE_KIND_HDD = 1;
FILESYSTEM_STORAGE_KIND_SSD = 2;
enum FilesystemKind {
FILESYSTEM_KIND_UNSPECIFIED = 0;
FILESYSTEM_KIND_HDD = 1;
FILESYSTEM_KIND_SSD = 2;
}

message FilesystemId {
Expand All @@ -46,7 +46,7 @@ message FilesystemModel {
int64 block_size = 1;
int64 size = 2;
int64 channels_count = 3;
FilesystemStorageKind storage_kind = 4;
FilesystemKind kind = 4;
FilesystemPerformanceProfile performance_profile = 5;
}

Expand All @@ -56,7 +56,7 @@ message CreateFilesystemRequest {
string folder_id = 3;
int64 block_size = 4;
int64 size = 5;
FilesystemStorageKind storage_kind = 6;
FilesystemKind kind = 6;
}

message DeleteFilesystemRequest {
Expand All @@ -76,5 +76,5 @@ message DescribeFilesystemModelRequest {
string zone_id = 1;
int64 block_size = 2;
int64 size = 3;
FilesystemStorageKind storage_kind = 4;
FilesystemKind kind = 4;
}
10 changes: 5 additions & 5 deletions cloud/disk_manager/internal/pkg/clients/nfs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ const (
)

func getStorageMediaKind(
kind types.FilesystemStorageKind,
kind types.FilesystemKind,
) (coreprotos.EStorageMediaKind, error) {

switch kind {
case types.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_SSD:
case types.FilesystemKind_FILESYSTEM_KIND_SSD:
return coreprotos.EStorageMediaKind_STORAGE_MEDIA_SSD, nil
case types.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_HDD:
case types.FilesystemKind_FILESYSTEM_KIND_HDD:
return coreprotos.EStorageMediaKind_STORAGE_MEDIA_HDD, nil
default:
return 0, errors.NewNonRetriableErrorf(
Expand Down Expand Up @@ -108,7 +108,7 @@ func (c *client) Create(
params CreateFilesystemParams,
) error {

mediaKind, err := getStorageMediaKind(params.StorageKind)
mediaKind, err := getStorageMediaKind(params.Kind)
if err != nil {
return err
}
Expand Down Expand Up @@ -196,7 +196,7 @@ func (c *client) DescribeModel(
ctx context.Context,
blocksCount uint64,
blockSize uint32,
kind types.FilesystemStorageKind,
kind types.FilesystemKind,
) (FilesystemModel, error) {

mediaKind, err := getStorageMediaKind(kind)
Expand Down
17 changes: 5 additions & 12 deletions cloud/disk_manager/internal/pkg/clients/nfs/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type CreateFilesystemParams struct {
CloudID string
BlockSize uint32
BlocksCount uint64
StorageKind types.FilesystemStorageKind
Kind types.FilesystemKind
}

type FilesystemPerformanceProfile struct {
Expand All @@ -27,7 +27,7 @@ type FilesystemModel struct {
BlockSize uint32
BlocksCount uint64
ChannelsCount uint32
Kind types.FilesystemStorageKind
Kind types.FilesystemKind
PerformanceProfile FilesystemPerformanceProfile
}

Expand All @@ -42,22 +42,15 @@ type Client interface {
params CreateFilesystemParams,
) error

Delete(
ctx context.Context,
filesystemID string,
) error
Delete(ctx context.Context, filesystemID string) error

Resize(
ctx context.Context,
filesystemID string,
size uint64,
) error
Resize(ctx context.Context, filesystemID string, size uint64) error

DescribeModel(
ctx context.Context,
blocksCount uint64,
blockSize uint32,
kind types.FilesystemStorageKind,
kind types.FilesystemKind,
) (FilesystemModel, error)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (c *ClientMock) DescribeModel(
ctx context.Context,
blocksCount uint64,
blockSize uint32,
kind types.FilesystemStorageKind,
kind types.FilesystemKind,
) (nfs.FilesystemModel, error) {

args := c.Called(ctx, blocksCount, blockSize, kind)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func TestFilesystemServiceCreateEmptyFilesystem(t *testing.T) {
ZoneId: "zone-a",
FilesystemId: filesystemID,
},
BlockSize: 4096,
Size: 4096000,
StorageKind: disk_manager.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_HDD,
BlockSize: 4096,
Size: 4096000,
Kind: disk_manager.FilesystemKind_FILESYSTEM_KIND_HDD,
})
require.NoError(t, err)
require.NotEmpty(t, operation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (t *createFilesystemTask) Run(
ZoneID: t.request.Filesystem.ZoneId,
BlocksCount: t.request.BlocksCount,
BlockSize: t.request.BlockSize,
Kind: fsKindToString(t.request.StorageKind),
Kind: fsKindToString(t.request.Kind),
CloudID: t.request.CloudId,
FolderID: t.request.FolderId,

Expand All @@ -80,7 +80,7 @@ func (t *createFilesystemTask) Run(
FolderID: t.request.FolderId,
BlocksCount: t.request.BlocksCount,
BlockSize: t.request.BlockSize,
StorageKind: t.request.StorageKind,
Kind: t.request.Kind,
})
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ message CreateFilesystemRequest {
string FolderId = 4;
uint32 BlockSize = 5;
uint64 BlocksCount = 6;
types.FilesystemStorageKind StorageKind = 7;
types.FilesystemKind Kind = 7;
}

message CreateFilesystemTaskState {}
26 changes: 13 additions & 13 deletions cloud/disk_manager/internal/pkg/services/filesystem/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ func getBlocksCountForSize(size uint64, blockSize uint32) (uint64, error) {
return size / uint64(blockSize), nil
}

func fsKindToString(kind types.FilesystemStorageKind) string {
func fsKindToString(kind types.FilesystemKind) string {
switch kind {
case types.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_SSD:
case types.FilesystemKind_FILESYSTEM_KIND_SSD:
return "ssd"
case types.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_HDD:
case types.FilesystemKind_FILESYSTEM_KIND_HDD:
return "hdd"
}
return "unknown"
}

func prepareFilesystemKind(kind disk_manager.FilesystemStorageKind) (types.FilesystemStorageKind, error) {
func prepareFilesystemKind(kind disk_manager.FilesystemKind) (types.FilesystemKind, error) {
switch kind {
case disk_manager.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_UNSPECIFIED:
case disk_manager.FilesystemKind_FILESYSTEM_KIND_UNSPECIFIED:
fallthrough
case disk_manager.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_HDD:
return types.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_HDD, nil
case disk_manager.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_SSD:
return types.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_SSD, nil
case disk_manager.FilesystemKind_FILESYSTEM_KIND_HDD:
return types.FilesystemKind_FILESYSTEM_KIND_HDD, nil
case disk_manager.FilesystemKind_FILESYSTEM_KIND_SSD:
return types.FilesystemKind_FILESYSTEM_KIND_SSD, nil
default:
return 0, errors.NewInvalidArgumentError(
"unknown filesystem storage kind %v",
Expand Down Expand Up @@ -105,7 +105,7 @@ func (s *service) CreateFilesystem(
return "", err
}

kind, err := prepareFilesystemKind(req.StorageKind)
kind, err := prepareFilesystemKind(req.Kind)
if err != nil {
return "", err
}
Expand All @@ -123,7 +123,7 @@ func (s *service) CreateFilesystem(
FolderId: req.FolderId,
BlockSize: blockSize,
BlocksCount: blocksCount,
StorageKind: kind,
Kind: kind,
},
)
}
Expand Down Expand Up @@ -218,7 +218,7 @@ func (s *service) DescribeFilesystemModel(
blockSize = s.config.GetDefaultBlockSize()
}

kind, err := prepareFilesystemKind(req.StorageKind)
kind, err := prepareFilesystemKind(req.Kind)
if err != nil {
return nil, err
}
Expand All @@ -242,7 +242,7 @@ func (s *service) DescribeFilesystemModel(
BlockSize: int64(model.BlockSize),
Size: int64(uint64(model.BlockSize) * model.BlocksCount),
ChannelsCount: int64(model.ChannelsCount),
StorageKind: req.StorageKind,
Kind: req.Kind,
PerformanceProfile: &disk_manager.FilesystemPerformanceProfile{
MaxReadBandwidth: int64(model.PerformanceProfile.MaxReadBandwidth),
MaxReadIops: int64(model.PerformanceProfile.MaxReadIops),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ func TestCreateDeleteFilesystem(t *testing.T) {
ZoneId: "zone",
FilesystemId: "filesystem",
},
CloudId: "cloud",
FolderId: "folder",
StorageKind: disk_manager.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_HDD,
CloudId: "cloud",
FolderId: "folder",
Kind: disk_manager.FilesystemKind_FILESYSTEM_KIND_HDD,
})
require.NoError(t, err)
require.NotEmpty(t, taskID)
Expand Down Expand Up @@ -331,9 +331,9 @@ func TestCreateResizeFilesystem(t *testing.T) {
ZoneId: "zone",
FilesystemId: "filesystem",
},
CloudId: "cloud",
FolderId: "folder",
StorageKind: disk_manager.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_HDD,
CloudId: "cloud",
FolderId: "folder",
Kind: disk_manager.FilesystemKind_FILESYSTEM_KIND_HDD,
})
require.NoError(t, err)
require.NotEmpty(t, taskID)
Expand Down Expand Up @@ -379,10 +379,10 @@ func TestDescribeModel(t *testing.T) {

reqCtx := getRequestContext(t, ctx)
model, err := service.DescribeFilesystemModel(reqCtx, &disk_manager.DescribeFilesystemModelRequest{
ZoneId: "zone",
BlockSize: 4096,
Size: 100500 * 4096,
StorageKind: disk_manager.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_SSD,
ZoneId: "zone",
BlockSize: 4096,
Size: 100500 * 4096,
Kind: disk_manager.FilesystemKind_FILESYSTEM_KIND_SSD,
})

require.NoError(t, err)
Expand All @@ -391,7 +391,7 @@ func TestDescribeModel(t *testing.T) {
require.Equal(t, model.Size, int64(100500*4096))
require.Equal(t, model.BlockSize, int64(4096))
require.NotEqual(t, model.ChannelsCount, int64(0))
require.Equal(t, model.StorageKind, disk_manager.FilesystemStorageKind_FILESYSTEM_STORAGE_KIND_SSD)
require.Equal(t, model.Kind, disk_manager.FilesystemKind_FILESYSTEM_KIND_SSD)

require.NotEqual(t, model.PerformanceProfile.MaxReadBandwidth, int64(0))
require.NotEqual(t, model.PerformanceProfile.MaxReadIops, int64(0))
Expand Down
6 changes: 3 additions & 3 deletions cloud/disk_manager/internal/pkg/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ message DiskPool {

////////////////////////////////////////////////////////////////////////////////

enum FilesystemStorageKind {
FILESYSTEM_STORAGE_KIND_SSD = 0;
FILESYSTEM_STORAGE_KIND_HDD = 1;
enum FilesystemKind {
FILESYSTEM_KIND_SSD = 0;
FILESYSTEM_KIND_HDD = 1;
}

0 comments on commit 036e38b

Please sign in to comment.