diff options
author | andrew-rykov <arykov@ydb.tech> | 2023-02-14 11:48:58 +0300 |
---|---|---|
committer | andrew-rykov <arykov@ydb.tech> | 2023-02-14 11:48:58 +0300 |
commit | 375d50eb9133bf3b83b03f87079b4593db2d5933 (patch) | |
tree | e00da829cbc2969b23a6e7ed2ee72ff2bb8d42a3 | |
parent | 5ad2a94c03b9a07f1a4e5e9da7dfb3dd4e34977e (diff) | |
download | ydb-375d50eb9133bf3b83b03f87079b4593db2d5933.tar.gz |
hc hardquota monitoring
-rw-r--r-- | ydb/core/health_check/health_check.cpp | 28 | ||||
-rw-r--r-- | ydb/core/health_check/health_check_ut.cpp | 22 |
2 files changed, 30 insertions, 20 deletions
diff --git a/ydb/core/health_check/health_check.cpp b/ydb/core/health_check/health_check.cpp index 49d5577e4e2..409b3594db0 100644 --- a/ydb/core/health_check/health_check.cpp +++ b/ydb/core/health_check/health_check.cpp @@ -202,7 +202,7 @@ public: TVector<TString> StoragePoolNames; THashMap<std::pair<TTabletId, NNodeWhiteboard::TFollowerId>, const NKikimrHive::TTabletInfo*> MergedTabletState; THashMap<TNodeId, TNodeTabletState> MergedNodeTabletState; - ui64 StorageLimit; + ui64 StorageQuota; ui64 StorageUsage; }; @@ -900,10 +900,10 @@ public: void Handle(NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult::TPtr& ev) { TabletRequests.CompleteRequest(ev->Cookie); - if (ev->Get()->GetRecord().GetStatus() == NKikimrScheme::StatusSuccess) { - TString path = ev->Get()->GetRecord().GetPath(); + if (ev->Get()->GetRecord().status() == NKikimrScheme::StatusSuccess) { + TString path = ev->Get()->GetRecord().path(); TDatabaseState& state(DatabaseState[path]); - for (const auto& storagePool : ev->Get()->GetRecord().GetPathDescription().GetDomainDescription().GetStoragePools()) { + for (const auto& storagePool : ev->Get()->GetRecord().pathdescription().domaindescription().storagepools()) { TString storagePoolName = storagePool.name(); state.StoragePoolNames.emplace_back(storagePoolName); StoragePoolState[storagePoolName].Kind = storagePool.kind(); @@ -912,8 +912,8 @@ public: if (path == DomainPath) { state.StoragePoolNames.emplace_back(STATIC_STORAGE_POOL_NAME); } - state.StorageUsage = ev->Get()->GetRecord().GetPathDescription().GetDomainDescription().GetDiskSpaceUsage().GetTables().GetTotalSize(); - state.StorageLimit = ev->Get()->GetRecord().GetPathDescription().GetDomainDescription().GetDatabaseQuotas().Getdata_stream_reserved_storage_quota(); + state.StorageUsage = ev->Get()->GetRecord().pathdescription().domaindescription().diskspaceusage().tables().totalsize(); + state.StorageQuota = ev->Get()->GetRecord().pathdescription().domaindescription().databasequotas().data_size_hard_quota(); DescribeByPath[path] = ev->Release(); } @@ -2172,13 +2172,15 @@ public: break; } } - auto usage = (float)databaseState.StorageUsage / databaseState.StorageLimit; - if (usage > 0.9) { - context.ReportStatus(Ydb::Monitoring::StatusFlag::RED, "Storage usage over 90%", ETags::StorageState); - } else if (usage > 0.85) { - context.ReportStatus(Ydb::Monitoring::StatusFlag::ORANGE, "Storage usage over 85%", ETags::StorageState); - } else if (usage > 0.75) { - context.ReportStatus(Ydb::Monitoring::StatusFlag::YELLOW, "Storage usage over 75%", ETags::StorageState); + if (databaseState.StorageQuota > 0) { + auto usage = (float)databaseState.StorageUsage / databaseState.StorageQuota; + if (usage > 0.9) { + context.ReportStatus(Ydb::Monitoring::StatusFlag::RED, "Storage usage over 90%", ETags::StorageState); + } else if (usage > 0.85) { + context.ReportStatus(Ydb::Monitoring::StatusFlag::ORANGE, "Storage usage over 85%", ETags::StorageState); + } else if (usage > 0.75) { + context.ReportStatus(Ydb::Monitoring::StatusFlag::YELLOW, "Storage usage over 75%", ETags::StorageState); + } } storageStatus.set_overall(context.GetOverallStatus()); } diff --git a/ydb/core/health_check/health_check_ut.cpp b/ydb/core/health_check/health_check_ut.cpp index 6b299c25405..b402d39f2d1 100644 --- a/ydb/core/health_check/health_check_ut.cpp +++ b/ydb/core/health_check/health_check_ut.cpp @@ -57,7 +57,11 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { auto domain = record->mutable_pathdescription()->mutable_domaindescription(); domain->mutable_diskspaceusage()->mutable_tables()->set_totalsize(size); - domain->mutable_databasequotas()->set_data_stream_reserved_storage_quota(quota); + if (quota == 0) { + domain->clear_databasequotas(); + } else { + domain->mutable_databasequotas()->set_data_size_hard_quota(quota); + } } void AddGroupsInControllerSelectGroupsResult(TEvBlobStorage::TEvControllerSelectGroupsResult::TPtr* ev, int groupCount) { @@ -265,7 +269,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { domain->mutable_databasequotas()->set_data_stream_reserved_storage_quota(quota); } - void StorageTest(ui64 usage, ui64 storageIssuesNumber, Ydb::Monitoring::StatusFlag::Status status = Ydb::Monitoring::StatusFlag::GREEN) { + void StorageTest(ui64 usage, ui64 quota, ui64 storageIssuesNumber, Ydb::Monitoring::StatusFlag::Status status = Ydb::Monitoring::StatusFlag::GREEN) { TPortManager tp; ui16 port = tp.GetPort(2134); ui16 grpcPort = tp.GetPort(2135); @@ -285,7 +289,7 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { switch (ev->GetTypeRewrite()) { case TEvSchemeShard::EvDescribeSchemeResult: { auto *x = reinterpret_cast<NSchemeShard::TEvSchemeShard::TEvDescribeSchemeResult::TPtr*>(&ev); - ChangeDescribeSchemeResult(x, usage, 100); + ChangeDescribeSchemeResult(x, usage, quota); break; } } @@ -309,19 +313,23 @@ Y_UNIT_TEST_SUITE(THealthCheckTest) { } Y_UNIT_TEST(StorageLimit95) { - StorageTest(95, 1, Ydb::Monitoring::StatusFlag::RED); + StorageTest(95, 100, 1, Ydb::Monitoring::StatusFlag::RED); } Y_UNIT_TEST(StorageLimit87) { - StorageTest(87, 1, Ydb::Monitoring::StatusFlag::ORANGE); + StorageTest(87, 100, 1, Ydb::Monitoring::StatusFlag::ORANGE); } Y_UNIT_TEST(StorageLimit80) { - StorageTest(80, 1, Ydb::Monitoring::StatusFlag::YELLOW); + StorageTest(80, 100, 1, Ydb::Monitoring::StatusFlag::YELLOW); } Y_UNIT_TEST(StorageLimit50) { - StorageTest(50, 0, Ydb::Monitoring::StatusFlag::GREEN); + StorageTest(50, 100, 0, Ydb::Monitoring::StatusFlag::GREEN); + } + + Y_UNIT_TEST(StorageNoQuota) { + StorageTest(100, 0, 0, Ydb::Monitoring::StatusFlag::GREEN); } } |