diff options
author | yuryalekseev <yuryalekseev@yandex-team.com> | 2023-02-15 18:00:42 +0300 |
---|---|---|
committer | yuryalekseev <yuryalekseev@yandex-team.com> | 2023-02-15 18:00:42 +0300 |
commit | fb4ef51595c8a68be43a9a6bf05d6ebf9c3b8d5d (patch) | |
tree | e5b187141798626af584f35ded1f001eabf776aa | |
parent | f8152c3cdf4f8febc7e23330f4a6e620e5d74fb2 (diff) | |
download | ydb-fb4ef51595c8a68be43a9a6bf05d6ebf9c3b8d5d.tar.gz |
Properly follow the TSerialManagementStage logic.
-rw-r--r-- | ydb/core/blobstorage/pdisk/blobstorage_pdisk_config.h | 12 | ||||
-rw-r--r-- | ydb/core/mind/bscontroller/cmds_drive_status.cpp | 16 | ||||
-rw-r--r-- | ydb/core/mind/bscontroller/config_fit_pdisks.cpp | 2 | ||||
-rw-r--r-- | ydb/core/mind/bscontroller/register_node.cpp | 27 |
4 files changed, 43 insertions, 14 deletions
diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_config.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_config.h index 94f4803ff56..8106255d5eb 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_config.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_config.h @@ -220,11 +220,19 @@ struct TPDiskConfig : public TThrRefBase { } bool CheckSerial(const TString& deviceSerial) const { - if (SerialManagementStage == NKikimrBlobStorage::TSerialManagementStage::CHECK_SERIAL || - SerialManagementStage == NKikimrBlobStorage::TSerialManagementStage::ONLY_SERIAL) { + switch (SerialManagementStage) { + case NKikimrBlobStorage::TSerialManagementStage::CHECK_SERIAL: if (ExpectedSerial && ExpectedSerial != deviceSerial) { return false; } + break; + case NKikimrBlobStorage::TSerialManagementStage::ONLY_SERIAL: + if (ExpectedSerial != deviceSerial) { + return false; + } + break; + default: + break; } return true; } diff --git a/ydb/core/mind/bscontroller/cmds_drive_status.cpp b/ydb/core/mind/bscontroller/cmds_drive_status.cpp index 718c7edee2b..664111a18ba 100644 --- a/ydb/core/mind/bscontroller/cmds_drive_status.cpp +++ b/ydb/core/mind/bscontroller/cmds_drive_status.cpp @@ -190,11 +190,17 @@ namespace NKikimr::NBsController { break; case NKikimrBlobStorage::TSerialManagementStage::CHECK_SERIAL: PDisks.ForEach([&](const TPDiskId& pdiskId, const TPDiskInfo& pdiskInfo) { - TString expected = pdiskInfo.ExpectedSerial; - if (pdiskInfo.Path && (!expected || expected != pdiskInfo.LastSeenSerial)) { - throw TExError() << "pdisk has not ExpectedSerial or ExpectedSerial not equals to LastSeenSerial" - << " pdiskId# " << pdiskId << " expected# " << expected.Quote() - << " lastSeen# " << pdiskInfo.LastSeenSerial; + if (pdiskInfo.ExpectedSerial && pdiskInfo.LastSeenSerial && pdiskInfo.ExpectedSerial != pdiskInfo.LastSeenSerial) { + throw TExError() << "LastSeenSerial doesn't match ExpectedSerial for pdisk" + << TErrorParams::NodeId(pdiskId.NodeId) << TErrorParams::PDiskId(pdiskId.PDiskId); + } + }); + break; + case NKikimrBlobStorage::TSerialManagementStage::ONLY_SERIAL: + PDisks.ForEach([&](const TPDiskId& pdiskId, const TPDiskInfo& pdiskInfo) { + if (pdiskInfo.ExpectedSerial != pdiskInfo.LastSeenSerial) { + throw TExError() << "LastSeenSerial doesn't match ExpectedSerial for pdisk" + << TErrorParams::NodeId(pdiskId.NodeId) << TErrorParams::PDiskId(pdiskId.PDiskId); } }); break; diff --git a/ydb/core/mind/bscontroller/config_fit_pdisks.cpp b/ydb/core/mind/bscontroller/config_fit_pdisks.cpp index b6f09b35dd3..4f4ace81b4e 100644 --- a/ydb/core/mind/bscontroller/config_fit_pdisks.cpp +++ b/ydb/core/mind/bscontroller/config_fit_pdisks.cpp @@ -247,7 +247,7 @@ namespace NKikimr { disk.BoxId = driveInfo.BoxId; disk.HostId = *hostId; disk.LastSeenPath = GetDiskPathFromNode(*nodeId, serial, state, /* throwOnError */ false); - disk.LastSeenSerial = TString(); + disk.LastSeenSerial = serial; disk.NodeId = *nodeId; disk.Path = *path; disk.PDiskCategory = TPDiskCategory(PDiskTypeToPDiskType(driveInfo.PDiskType), driveInfo.Kind); diff --git a/ydb/core/mind/bscontroller/register_node.cpp b/ydb/core/mind/bscontroller/register_node.cpp index ac96ed9a7ce..c763d2e797a 100644 --- a/ydb/core/mind/bscontroller/register_node.cpp +++ b/ydb/core/mind/bscontroller/register_node.cpp @@ -60,14 +60,29 @@ class TBlobStorageController::TTxUpdateNodeDrives // the disk on the node with the same label (path) as pdisk has a different serial number TStringStream log; - if (Self->SerialManagementStage == NKikimrBlobStorage::TSerialManagementStage::CHECK_SERIAL) { + switch (Self->SerialManagementStage) { + case NKikimrBlobStorage::TSerialManagementStage::CHECK_SERIAL: + if (!pdiskInfo.ExpectedSerial && serial) { + // update ExpectedSerial + pdiskInfo.ExpectedSerial = serial; + db.Table<T>().Key(key).Update<T::ExpectedSerial>(serial); + log << "Set ExpectedSerial for pdisk"; + } else { + log << "disk's serial reported by the node doesn't match pdisk's serial, don't update anything"; + } + break; + case NKikimrBlobStorage::TSerialManagementStage::ONLY_SERIAL: // don't update ExpectedSerial so that the corresponding PDisk wouldn't be able to start next time log << "disk's serial reported by the node doesn't match pdisk's serial, don't update anything"; - } else { - log << "disk's serial reported by the node doesn't match pdisk's serial, update the later"; - // update ExpectedSerial - pdiskInfo.ExpectedSerial = serial; - db.Table<T>().Key(key).Update<T::ExpectedSerial>(serial); + break; + default: + if (serial) { + // update ExpectedSerial + pdiskInfo.ExpectedSerial = serial; + db.Table<T>().Key(key).Update<T::ExpectedSerial>(serial); + log << "disk's serial reported by the node doesn't match pdisk's serial, update ExpectedSerial for pdisk"; + } + break; } STLOG(NLog::PRI_ERROR, BS_CONTROLLER, BSCTXRN06, log.Str(), (PDiskId, pdiskId), (Path, pdiskInfo.Path), |