Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json tenantinfo status metadata cache #5543

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions ydb/core/viewer/json_tenantinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ydb/library/services/services.pb.h>
#include <ydb/core/cms/console/console.h>
#include <ydb/core/base/hive.h>
#include <ydb/core/grpc_services/db_metadata_cache.h>
#include <ydb/core/tx/schemeshard/schemeshard.h>
#include <ydb/core/tx/tx_proxy/proxy.h>
#include <ydb/core/viewer/protos/viewer.pb.h>
Expand All @@ -28,13 +29,15 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
IViewer* Viewer;
THashMap<TString, NKikimrViewer::TTenant> TenantByPath;
THashMap<TPathId, NKikimrViewer::TTenant> TenantBySubDomainKey;
THashMap<TString, NKikimrViewer::EFlag> HcOverallByTenantPath;
THashMap<TString, THolder<NSchemeCache::TSchemeCacheNavigate>> NavigateResult;
THashMap<TTabletId, THolder<TEvHive::TEvResponseHiveDomainStats>> HiveDomainStats;
THashMap<TTabletId, THolder<TEvHive::TEvResponseHiveStorageStats>> HiveStorageStats;
NMon::TEvHttpInfo::TPtr Event;
THashSet<TNodeId> Subscribers;
THashSet<TNodeId> WhiteboardNodesRequested;
THashSet<TString> OffloadTenantsRequested;
THashSet<TString> MetadataCacheRequested;
THashMap<TNodeId, TString> NodeIdsToTenant; // for tablet info
TMap<TNodeId, NKikimrWhiteboard::TEvSystemStateResponse> WhiteboardSystemStateResponse;
THashMap<TString, TMap<TNodeId, NKikimrWhiteboard::TEvTabletStateResponse>> WhiteboardTabletStateResponse;
Expand Down Expand Up @@ -165,6 +168,8 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
hFunc(TEvents::TEvUndelivered, Undelivered);
hFunc(TEvInterconnect::TEvNodeDisconnected, Disconnected);
hFunc(TEvTabletPipe::TEvClientConnected, TBase::Handle);
hFunc(TEvStateStorage::TEvBoardInfo, Handle);
hFunc(NHealthCheck::TEvSelfCheckResultProto, Handle);
cFunc(TEvents::TSystem::Wakeup, HandleTimeout);
}
}
Expand All @@ -179,6 +184,10 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
}
RequestConsoleGetTenantStatus(path);
RequestSchemeCacheNavigate(path);

if (AppData()->FeatureFlags.GetEnableDbMetadataCache()) {
RequestStateStorageMetadataCacheEndpointsLookup(path);
}
}
RequestDone();
}
Expand Down Expand Up @@ -385,6 +394,28 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
RequestDone();
}

void Handle(NHealthCheck::TEvSelfCheckResultProto::TPtr& ev) {
auto result = std::move(ev->Get()->Record);
if (result.database_status_size() == 1) {
HcOverallByTenantPath.emplace(result.database_status(0).name(), GetViewerFlag(result.database_status(0).overall()));
}

RequestDone();
}

void Handle(TEvStateStorage::TEvBoardInfo::TPtr& ev) {
auto activeNode = TDatabaseMetadataCache::PickActiveNode(ev->Get()->InfoEntries);
if (activeNode != 0) {
Subscribers.insert(activeNode);
std::optional<TActorId> cache = MakeDatabaseMetadataCacheId(activeNode);
auto request = MakeHolder<NHealthCheck::TEvSelfCheckRequestProto>();
if (MetadataCacheRequested.insert(ev->Get()->Path).second) {
SendRequest(*cache, request.Release(), IEventHandle::FlagTrackDelivery | IEventHandle::FlagSubscribeOnSession, activeNode);
}
}
RequestDone();
}

void Handle(TEvViewer::TEvViewerResponse::TPtr& ev) {
ui32 nodeId = ev.Get()->Cookie;
auto tenantId = NodeIdsToTenant[nodeId];
Expand All @@ -407,6 +438,14 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
}

void Undelivered(TEvents::TEvUndelivered::TPtr &ev) {
if (ev->Get()->SourceType == NHealthCheck::EvSelfCheckRequestProto) {
ui32 nodeId = ev.Get()->Cookie;
BLOG_TRACE("Undelivered for node " << nodeId << " event " << ev->Get()->SourceType);
auto tenantId = NodeIdsToTenant[nodeId];
if (HcOverallByTenantPath.emplace(tenantId, NKikimrViewer::EFlag::Grey).second) {
RequestDone();
}
}
if (ev->Get()->SourceType == NNodeWhiteboard::TEvWhiteboard::EvSystemStateRequest) {
ui32 nodeId = ev.Get()->Cookie;
BLOG_TRACE("Undelivered for node " << nodeId << " event " << ev->Get()->SourceType);
Expand Down Expand Up @@ -481,6 +520,11 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
RequestDone();
}
}
if (MetadataCacheRequested.count(tenantId) > 0) {
if (HcOverallByTenantPath.emplace(tenantId, NKikimrViewer::EFlag::Grey).second) {
RequestDone();
}
}
}

NKikimrViewer::TStorageUsage::EType GetStorageType(const TString& poolKind) {
Expand Down Expand Up @@ -747,8 +791,13 @@ class TJsonTenantInfo : public TViewerPipeClient<TJsonTenantInfo> {
tablet.SetCount(prTabletCount);
}
}
tenant.SetOverall(overall);
OverallByDomainId[tenant.GetId()] = overall;
if (HcOverallByTenantPath.count(path) > 0 && HcOverallByTenantPath[path] != NKikimrViewer::EFlag::Grey) {
tenant.SetOverall(HcOverallByTenantPath[path]);
OverallByDomainId[tenant.GetId()] = HcOverallByTenantPath[path];
} else {
tenant.SetOverall(overall);
OverallByDomainId[tenant.GetId()] = overall;
}
}
}
for (const std::pair<const TString, NKikimrViewer::TTenant>& prTenant : TenantByPath) {
Expand Down
20 changes: 20 additions & 0 deletions ydb/core/viewer/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,26 @@ NKikimrViewer::EFlag GetBSGroupOverallFlag(
return GetBSGroupOverallState(info, vDisksIndex, pDisksIndex).Overall;
}

NKikimrViewer::EFlag GetViewerFlag(Ydb::Monitoring::StatusFlag::Status flag) {
switch (flag) {
case Ydb::Monitoring::StatusFlag::GREY:
case Ydb::Monitoring::StatusFlag::UNSPECIFIED:
case Ydb::Monitoring::StatusFlag_Status_StatusFlag_Status_INT_MIN_SENTINEL_DO_NOT_USE_:
case Ydb::Monitoring::StatusFlag_Status_StatusFlag_Status_INT_MAX_SENTINEL_DO_NOT_USE_:
return NKikimrViewer::EFlag::Grey;
case Ydb::Monitoring::StatusFlag::GREEN:
return NKikimrViewer::EFlag::Green;
case Ydb::Monitoring::StatusFlag::BLUE:
return NKikimrViewer::EFlag::Green;
case Ydb::Monitoring::StatusFlag::YELLOW:
return NKikimrViewer::EFlag::Yellow;
case Ydb::Monitoring::StatusFlag::ORANGE:
return NKikimrViewer::EFlag::Orange;
case Ydb::Monitoring::StatusFlag::RED:
return NKikimrViewer::EFlag::Red;
}
}

NKikimrWhiteboard::EFlag GetWhiteboardFlag(NKikimrViewer::EFlag flag) {
switch (flag) {
case NKikimrViewer::EFlag::Grey:
Expand Down
3 changes: 3 additions & 0 deletions ydb/core/viewer/viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <ydb/library/actors/core/event.h>
#include <ydb/core/driver_lib/run/config.h>
#include <ydb/core/viewer/protos/viewer.pb.h>
#include <ydb/public/api/protos/ydb_monitoring.pb.h>
#include <util/system/hostname.h>

namespace NKikimr {
Expand Down Expand Up @@ -272,6 +273,8 @@ NKikimrViewer::EFlag GetFlagFromUsage(double usage);

NKikimrWhiteboard::EFlag GetWhiteboardFlag(NKikimrViewer::EFlag flag);
NKikimrViewer::EFlag GetViewerFlag(NKikimrWhiteboard::EFlag flag);
NKikimrViewer::EFlag GetViewerFlag(Ydb::Monitoring::StatusFlag::Status flag);


} // NViewer
} // NKikimr
Loading