diff options
author | yuryalekseev <yuryalekseev@yandex-team.com> | 2023-02-17 17:51:47 +0300 |
---|---|---|
committer | yuryalekseev <yuryalekseev@yandex-team.com> | 2023-02-17 17:51:47 +0300 |
commit | 2b3cb1e0b4b68b443fb412eb091927b95385f53e (patch) | |
tree | 4770d33568827bcbeef0178f0772ae2b840a911c | |
parent | 53b03848d2c7424227e949900d76e6941650326d (diff) | |
download | ydb-2b3cb1e0b4b68b443fb412eb091927b95385f53e.tar.gz |
Add PDiskId and fill out StorageStatus in dstool device list.
-rw-r--r-- | ydb/apps/dstool/lib/dstool_cmd_device_list.py | 25 | ||||
-rw-r--r-- | ydb/core/mind/bscontroller/cmds_storage_pool.cpp | 3 | ||||
-rw-r--r-- | ydb/core/mind/bscontroller/config_fit_pdisks.cpp | 13 | ||||
-rw-r--r-- | ydb/core/protos/blobstorage_config.proto | 3 |
4 files changed, 39 insertions, 5 deletions
diff --git a/ydb/apps/dstool/lib/dstool_cmd_device_list.py b/ydb/apps/dstool/lib/dstool_cmd_device_list.py index 929b9e9862..63549bfb05 100644 --- a/ydb/apps/dstool/lib/dstool_cmd_device_list.py +++ b/ydb/apps/dstool/lib/dstool_cmd_device_list.py @@ -2,7 +2,7 @@ import ydb.core.protos.blobstorage_config_pb2 as kikimr_bsconfig import ydb.apps.dstool.lib.common as common import ydb.apps.dstool.lib.table as table -description = 'List storage devices' +description = 'List available storage devices' def add_options(p): @@ -15,11 +15,12 @@ def do(args): all_columns = [ 'SerialNumber', - 'NodeId', 'FQDN', 'Path', 'Type', 'StorageStatus', + 'NodeId:PDiskId', + 'NodeId', 'BoxId', ] visible_columns = [ @@ -28,6 +29,7 @@ def do(args): 'Path', 'Type', 'StorageStatus', + 'NodeId:PDiskId', ] table_output = table.TableOutput( @@ -36,14 +38,29 @@ def do(args): rows = [] for device in base_config.Device: + usedByPDisk = True if device.PDiskId > 0 else False + row = {} row['SerialNumber'] = device.SerialNumber row['NodeId'] = device.NodeId row['FQDN'] = node_to_fqdn[device.NodeId] - row['Type'] = kikimr_bsconfig.EPDiskType.Name(device.Type) - row['StorageStatus'] = kikimr_bsconfig.TDriveLifeStage.E.Name(device.LifeStage) row['Path'] = device.Path + row['Type'] = kikimr_bsconfig.EPDiskType.Name(device.Type) row['BoxId'] = device.BoxId + + if usedByPDisk: + row['NodeId:PDiskId'] = '[%u:%u]' % (device.NodeId, device.PDiskId) + else: + row['NodeId:PDiskId'] = 'NULL' + + if usedByPDisk: + if device.LifeStage == kikimr_bsconfig.TDriveLifeStage.E.ADDED_TO_BSC: + row['StorageStatus'] = 'Configured by ydb-dstool' + else: + row['StorageStatus'] = 'Configured by DefineBox' + else: + row['StorageStatus'] = 'FREE' + rows.append(row) table_output.dump(rows, args) diff --git a/ydb/core/mind/bscontroller/cmds_storage_pool.cpp b/ydb/core/mind/bscontroller/cmds_storage_pool.cpp index ec4d9080a0..5b04662fce 100644 --- a/ydb/core/mind/bscontroller/cmds_storage_pool.cpp +++ b/ydb/core/mind/bscontroller/cmds_storage_pool.cpp @@ -457,6 +457,9 @@ namespace NKikimr::NBsController { if (driveInfo.NodeId) { device->SetNodeId(driveInfo.NodeId.GetRef()); } + if (driveInfo.PDiskId) { + device->SetPDiskId(driveInfo.PDiskId.GetRef()); + } if (driveInfo.Path) { device->SetPath(driveInfo.Path.GetRef()); } diff --git a/ydb/core/mind/bscontroller/config_fit_pdisks.cpp b/ydb/core/mind/bscontroller/config_fit_pdisks.cpp index 4f4ace81b4..298c82860c 100644 --- a/ydb/core/mind/bscontroller/config_fit_pdisks.cpp +++ b/ydb/core/mind/bscontroller/config_fit_pdisks.cpp @@ -349,6 +349,11 @@ namespace NKikimr { NKikimrBlobStorage::EDecommitStatus::DECOMMIT_NONE, disk.Serial, disk.LastSeenSerial, disk.LastSeenPath, staticSlotUsage); + // Set PDiskId in DrivesSerials + if (auto info = state.DrivesSerials.FindForUpdate(disk.Serial)) { + info->PDiskId = pdiskId.PDiskId; + } + STLOG(PRI_NOTICE, BS_CONTROLLER, BSCFP02, "Create new pdisk", (PDiskId, pdiskId), (Path, disk.Path)); } @@ -356,6 +361,14 @@ namespace NKikimr { } for (const auto& pdiskId : state.PDisksToRemove) { + // Unset PDiskId in DrivesSerials + if (auto pdiskInfo = state.PDisks.Find(pdiskId)) { + if (state.DrivesSerials.Find(pdiskInfo->ExpectedSerial)) { + auto driveInfo = state.DrivesSerials.FindForUpdate(pdiskInfo->ExpectedSerial); + driveInfo->PDiskId.Clear(); + } + } + STLOG(PRI_NOTICE, BS_CONTROLLER, BSCFP03, "PDisk to remove:", (PDiskId, pdiskId)); } state.CheckConsistency(); diff --git a/ydb/core/protos/blobstorage_config.proto b/ydb/core/protos/blobstorage_config.proto index eee77247ef..fc1a2f1d7f 100644 --- a/ydb/core/protos/blobstorage_config.proto +++ b/ydb/core/protos/blobstorage_config.proto @@ -643,9 +643,10 @@ message TBaseConfig { string SerialNumber = 1; uint64 BoxId = 2; uint32 NodeId = 3; - TDriveLifeStage.E LifeStage = 4; + uint32 PDiskId = 4; string Path = 5; EPDiskType Type = 6; + TDriveLifeStage.E LifeStage = 7; } repeated TPDisk PDisk = 1; |