aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryuryalekseev <yuryalekseev@yandex-team.com>2023-02-14 22:40:10 +0300
committeryuryalekseev <yuryalekseev@yandex-team.com>2023-02-14 22:40:10 +0300
commit85e26a91af63c7926f981b4fa7d0be6737e387d1 (patch)
tree8be3f016fe115667080c97ffe4b2a14d1488f4f8
parentbd1053d7928808e8c89aecfb118bfdfd81bc9b5d (diff)
downloadydb-85e26a91af63c7926f981b4fa7d0be6737e387d1.tar.gz
Keep all relevant data updated in DrivesSerials. Use it in TAddDriveSerial.
-rw-r--r--ydb/core/mind/bscontroller/cmds_drive_status.cpp41
-rw-r--r--ydb/core/mind/bscontroller/register_node.cpp4
2 files changed, 9 insertions, 36 deletions
diff --git a/ydb/core/mind/bscontroller/cmds_drive_status.cpp b/ydb/core/mind/bscontroller/cmds_drive_status.cpp
index cc35357f91..718c7edee2 100644
--- a/ydb/core/mind/bscontroller/cmds_drive_status.cpp
+++ b/ydb/core/mind/bscontroller/cmds_drive_status.cpp
@@ -96,8 +96,6 @@ namespace NKikimr::NBsController {
TStatus& /*status*/) {
const auto& serial = cmd.GetSerial();
- auto boxId = cmd.GetBoxId();
-
auto driveInfo = DrivesSerials.Find(serial);
if (!driveInfo) {
throw TExError() << "Couldn't get drive info for disk with serial number" << TErrorParams::DiskSerialNumber(serial);
@@ -115,35 +113,15 @@ namespace NKikimr::NBsController {
throw TExError() << "Couldn't get node id for disk with serial number" << TErrorParams::DiskSerialNumber(serial);
}
- auto nodeId = driveInfo->NodeId.GetRef();
-
- const auto& nodes = Nodes.Get();
- auto nodeIt = nodes.find(nodeId);
- if (nodeIt == nodes.end()) {
- throw TExError() << "Couldn't find node by node id" << TErrorParams::NodeId(nodeId) << " for disk with serial number" << TErrorParams::DiskSerialNumber(serial);
+ if (!driveInfo->Path) {
+ throw TExError() << "Couldn't get path for disk with serial number" << TErrorParams::DiskSerialNumber(serial);
}
- const auto& nodeInfo = nodeIt->second;
- auto driveIt = nodeInfo.KnownDrives.find(serial);
- if (driveIt == nodeInfo.KnownDrives.end()) {
- throw TExError() << "Couldn't find disk on node" << TErrorParams::NodeId(nodeId) << " by serial number" << TErrorParams::DiskSerialNumber(serial);
- }
-
- // delete SEEN or REMOVED entry, if any, but keep its GUID
- auto guid = driveInfo ? std::make_optional(driveInfo->Guid) : std::nullopt;
- if (driveInfo) {
- DrivesSerials.DeleteExistingEntry(serial);
- }
-
- auto driveInfoMutable = DrivesSerials.ConstructInplaceNewEntry(serial, boxId);
- if (guid) {
- driveInfoMutable->Guid = *guid;
- }
+ auto driveInfoMutable = DrivesSerials.FindForUpdate(serial);
+ driveInfoMutable->BoxId = cmd.GetBoxId();
driveInfoMutable->Kind = cmd.GetKind();
if (cmd.GetPDiskType() != NKikimrBlobStorage::UNKNOWN_TYPE) {
driveInfoMutable->PDiskType = cmd.GetPDiskType();
- } else {
- driveInfoMutable->PDiskType = PDiskTypeToPDiskType(driveIt->second.DeviceType);
}
TString config;
if (!cmd.GetPDiskConfig().SerializeToString(&config)) {
@@ -151,13 +129,11 @@ namespace NKikimr::NBsController {
}
driveInfoMutable->PDiskConfig = config;
driveInfoMutable->LifeStage = NKikimrBlobStorage::TDriveLifeStage::ADDED_TO_BSC;
- driveInfoMutable->NodeId = nodeId;
- driveInfoMutable->Path = driveIt->second.Path;
- Fit.Boxes.insert(boxId);
+ Fit.Boxes.insert(cmd.GetBoxId());
STLOG(PRI_INFO, BS_CONTROLLER_AUDIT, BSCA00, "AddDriveSerial", (UniqueId, UniqueId), (Serial, serial),
- (BoxId, boxId));
+ (BoxId, cmd.GetBoxId()));
}
void TBlobStorageController::TConfigState::ExecuteStep(const NKikimrBlobStorage::TRemoveDriveSerial& cmd,
@@ -179,12 +155,7 @@ namespace NKikimr::NBsController {
}
auto driveInfoMutable = DrivesSerials.FindForUpdate(serial);
- driveInfoMutable->NodeId.Clear();
- driveInfoMutable->PDiskId.Clear();
driveInfoMutable->LifeStage = NKikimrBlobStorage::TDriveLifeStage::REMOVED_FROM_BSC;
- driveInfoMutable->Path.Clear();
- driveInfoMutable->PDiskType = NKikimrBlobStorage::UNKNOWN_TYPE;
- driveInfoMutable->BoxId = 0;
Fit.Boxes.insert(driveInfo->BoxId);
diff --git a/ydb/core/mind/bscontroller/register_node.cpp b/ydb/core/mind/bscontroller/register_node.cpp
index 39202a7ed1..ac96ed9a7c 100644
--- a/ydb/core/mind/bscontroller/register_node.cpp
+++ b/ydb/core/mind/bscontroller/register_node.cpp
@@ -98,6 +98,7 @@ class TBlobStorageController::TTxUpdateNodeDrives
newInfo->LifeStage = NKikimrBlobStorage::TDriveLifeStage::SEEN_ON_NODE;
newInfo->NodeId = nodeId;
newInfo->Path = data.GetPath();
+ newInfo->PDiskType = data.GetDeviceType();
Self->DrivesSerials.emplace(serial, std::move(newInfo));
} else if (it->second->LifeStage == NKikimrBlobStorage::TDriveLifeStage::ADDED_TO_BSC) {
if (it->second->NodeId != nodeId) {
@@ -110,9 +111,10 @@ class TBlobStorageController::TTxUpdateNodeDrives
"Received drive by NewPath, but drive is reported as placed by OldPath",
(NewPath, data.GetPath()), (OldPath, it->second->Path), (Serial, serial));
}
- } else if (it->second->LifeStage == NKikimrBlobStorage::TDriveLifeStage::SEEN_ON_NODE) {
+ } else {
it->second->NodeId = nodeId;
it->second->Path = data.GetPath();
+ it->second->PDiskType = data.GetDeviceType();
}
NPDisk::TDriveData driveData;
DriveDataToDriveData(data, driveData);