Skip to content

Commit caec0aa

Browse files
adameatStekPerepolnenalexv-smirnovRaubzeug
authored andcommitted
Viewer updates v5 (stable-24-3-15-hotfix) (#13480)
Co-authored-by: Andrei Rykov <arykov@ydb.tech> Co-authored-by: AlexSm <alex@ydb.tech> Co-authored-by: Raubzeug <Raubzeug@users.noreply.github.com>
1 parent 791d4c2 commit caec0aa

File tree

10 files changed

+251
-97
lines changed

10 files changed

+251
-97
lines changed

ydb/core/viewer/counters_hosts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class TCountersHostsList : public TActorBootstrapped<TCountersHostsList> {
152152
}
153153
}
154154
}
155-
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKTEXT(Event->Get()) + text.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
155+
Send(Event->Sender, new NMon::TEvHttpInfoRes(Viewer->GetHTTPOKTEXT(Event->Get(), text.Str()), 0, NMon::IEvHttpInfoRes::EContentType::Custom));
156156
PassAway();
157157
}
158158

ydb/core/viewer/json_handlers_viewer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void InitViewerWhoAmIJsonHandler(TJsonHandlers& handlers) {
227227
}
228228

229229
void InitViewerQueryJsonHandler(TJsonHandlers& handlers) {
230-
handlers.AddHandler("/viewer/query", new TJsonHandler<TJsonQuery>(TJsonQuery::GetSwagger()), 4);
230+
handlers.AddHandler("/viewer/query", new TJsonHandler<TJsonQuery>(TJsonQuery::GetSwagger()), 5);
231231
}
232232

233233
void InitViewerNetInfoJsonHandler(TJsonHandlers& handlers) {

ydb/core/viewer/json_local_rpc.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,13 @@ class TJsonLocalRpc : public TViewerPipeClient {
146146
auto result = MakeHolder<TEvLocalRpcPrivate::TEvGrpcRequestResult<TProtoResult>>();
147147
if constexpr (TRpcEv::IsOp) {
148148
if (response.operation().ready() && response.operation().status() == Ydb::StatusIds::SUCCESS) {
149-
TProtoResult rs;
150-
response.operation().result().UnpackTo(&rs);
151-
result->Message = std::move(rs);
149+
if (response.operation().has_result()) {
150+
TProtoResult rs;
151+
response.operation().result().UnpackTo(&rs);
152+
result->Message = std::move(rs);
153+
} else if constexpr (std::is_same_v<TProtoResult, Ydb::Operations::Operation>) {
154+
result->Message = std::move(response.operation());
155+
}
152156
}
153157
NYql::TIssues issues;
154158
NYql::IssuesFromMessage(response.operation().issues(), issues);

ydb/core/viewer/json_pipe_req.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "json_pipe_req.h"
2+
#include "log.h"
23
#include <library/cpp/json/json_reader.h>
34
#include <library/cpp/json/json_writer.h>
45

@@ -573,6 +574,9 @@ TViewerPipeClient::TRequestResponse<TEvTxProxySchemeCache::TEvNavigateKeySetResu
573574
void TViewerPipeClient::RequestTxProxyDescribe(const TString& path) {
574575
THolder<TEvTxUserProxy::TEvNavigate> request(new TEvTxUserProxy::TEvNavigate());
575576
request->Record.MutableDescribePath()->SetPath(path);
577+
if (!Event->Get()->UserToken.empty()) {
578+
request->Record.SetUserToken(Event->Get()->UserToken);
579+
}
576580
SendRequest(MakeTxProxyID(), request.Release());
577581
}
578582

@@ -739,6 +743,13 @@ void TViewerPipeClient::RequestDone(ui32 requests) {
739743
if (requests == 0) {
740744
return;
741745
}
746+
if (requests > Requests) {
747+
BLOG_ERROR("Requests count mismatch: " << requests << " > " << Requests);
748+
if (Span) {
749+
Span.Event("Requests count mismatch");
750+
}
751+
requests = Requests;
752+
}
742753
Requests -= requests;
743754
if (!DelayedRequests.empty()) {
744755
SendDelayedRequests();
@@ -763,13 +774,15 @@ void TViewerPipeClient::HandleResolveResource(TEvTxProxySchemeCache::TEvNavigate
763774
SharedDatabase = CanonizePath(entry.Path);
764775
if (SharedDatabase == AppData()->TenantName) {
765776
Direct = true;
766-
return Bootstrap(); // retry bootstrap without redirect this time
777+
Bootstrap(); // retry bootstrap without redirect this time
778+
} else {
779+
DatabaseBoardInfoResponse = MakeRequestStateStorageEndpointsLookup(SharedDatabase);
767780
}
768-
DatabaseBoardInfoResponse = MakeRequestStateStorageEndpointsLookup(SharedDatabase);
769781
} else {
770-
ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - shared database not found"));
782+
return ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - shared database not found"));
771783
}
772784
}
785+
RequestDone();
773786
}
774787

775788
void TViewerPipeClient::HandleResolveDatabase(TEvTxProxySchemeCache::TEvNavigateKeySetResult::TPtr& ev) {
@@ -780,24 +793,27 @@ void TViewerPipeClient::HandleResolveDatabase(TEvTxProxySchemeCache::TEvNavigate
780793
if (entry.DomainInfo && entry.DomainInfo->ResourcesDomainKey && entry.DomainInfo->DomainKey != entry.DomainInfo->ResourcesDomainKey) {
781794
ResourceNavigateResponse = MakeRequestSchemeCacheNavigate(TPathId(entry.DomainInfo->ResourcesDomainKey));
782795
Become(&TViewerPipeClient::StateResolveResource);
783-
return;
796+
} else {
797+
DatabaseBoardInfoResponse = MakeRequestStateStorageEndpointsLookup(CanonizePath(entry.Path));
784798
}
785-
DatabaseBoardInfoResponse = MakeRequestStateStorageEndpointsLookup(CanonizePath(entry.Path));
786799
} else {
787-
ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - not found"));
800+
return ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - not found"));
788801
}
789802
}
803+
RequestDone();
790804
}
791805

792806
void TViewerPipeClient::HandleResolve(TEvStateStorage::TEvBoardInfo::TPtr& ev) {
793807
if (DatabaseBoardInfoResponse) {
794808
DatabaseBoardInfoResponse->Set(std::move(ev));
795809
if (DatabaseBoardInfoResponse->IsOk()) {
796-
ReplyAndPassAway(MakeForward(GetNodesFromBoardReply(DatabaseBoardInfoResponse->GetRef())));
810+
return ReplyAndPassAway(MakeForward(GetNodesFromBoardReply(DatabaseBoardInfoResponse->GetRef())));
797811
} else {
798-
ReplyAndPassAway(GetHTTPBADREQUEST("text/plain", "Failed to resolve database - no nodes found"));
812+
Direct = true;
813+
Bootstrap(); // retry bootstrap without redirect this time
799814
}
800815
}
816+
RequestDone();
801817
}
802818

803819
void TViewerPipeClient::HandleTimeout() {

ydb/core/viewer/viewer.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,15 @@ class TViewer : public TActorBootstrapped<TViewer>, public IViewer {
458458
response << "HTTP/1.1 200 Ok\r\n";
459459
response << "Content-Type: " << type << "\r\n";
460460
response << "Content-Length: " << blob.size() << "\r\n";
461-
response << "Date: " << TInstant::Now().ToRfc822String() << "\r\n";
462-
if (lastModified) {
463-
response << "Last-Modified: " << lastModified << "\r\n";
461+
if (name == "/monitoring/index.html") {
462+
response << "Cache-Control: no-store,max-age=0\r\n"; // do not cache
463+
} else {
464+
response << "Date: " << TInstant::Now().ToRfc822String() << "\r\n";
465+
if (lastModified) {
466+
response << "Last-Modified: " << lastModified << "\r\n";
467+
}
468+
response << "Cache-Control: max-age=604800\r\n"; // one week
464469
}
465-
response << "Cache-Control: max-age=604800\r\n"; // one week
466470
response << "\r\n";
467471
response.Write(blob.data(), blob.size());
468472
Send(ev->Sender, new NMon::TEvHttpInfoRes(response.Str(), 0, NMon::IEvHttpInfoRes::EContentType::Custom));

0 commit comments

Comments
 (0)