Skip to content

Commit e088f9e

Browse files
ydbotactions-usergalnatanton-bobkov
authored andcommitted
Update CHANGELOG.md for main:2025-06-15 (#19669)
Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Natasha Pirogova <galnat@ydb.tech> Co-authored-by: anton-bobkov <anton-bobkov@yandex-team.ru>
1 parent cc78f3e commit e088f9e

File tree

1 file changed

+56
-19
lines changed

1 file changed

+56
-19
lines changed

ydb/core/mon/mon.cpp

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,32 +1026,36 @@ class THttpMonInitializator : public TActorBootstrapped<THttpMonInitializator> {
10261026
class THttpMonAuthorizedActorRequest : public TActorBootstrapped<THttpMonAuthorizedActorRequest> {
10271027
public:
10281028
NHttp::TEvHttpProxy::TEvHttpIncomingRequest::TPtr Event;
1029-
TActorId TargetActorId;
1029+
TMon::TRegisterHandlerFields& Fields;
10301030
TMon::TRequestAuthorizer Authorizer;
1031-
TVector<TString> AllowedSIDs;
1031+
NHttp::TEvHttpProxy::TEvSubscribeForCancel::TPtr CancelSubscriber;
10321032

1033-
THttpMonAuthorizedActorRequest(NHttp::TEvHttpProxy::TEvHttpIncomingRequest::TPtr event, TActorId targetActorId, TMon::TRequestAuthorizer authorizer, const TVector<TString>& allowedSIDs)
1033+
THttpMonAuthorizedActorRequest(NHttp::TEvHttpProxy::TEvHttpIncomingRequest::TPtr event, TMon::TRegisterHandlerFields& fields, TMon::TRequestAuthorizer authorizer)
10341034
: Event(std::move(event))
1035-
, TargetActorId(targetActorId)
1035+
, Fields(fields)
10361036
, Authorizer(std::move(authorizer))
1037-
, AllowedSIDs(allowedSIDs)
10381037
{}
10391038

10401039
static constexpr NKikimrServices::TActivity::EType ActorActivityType() {
10411040
return NKikimrServices::TActivity::HTTP_MON_AUTHORIZED_ACTOR_REQUEST;
10421041
}
10431042

10441043
void Bootstrap() {
1045-
if (Authorizer) {
1044+
Send(Event->Sender, new NHttp::TEvHttpProxy::TEvSubscribeForCancel(), IEventHandle::FlagTrackDelivery);
1045+
if (Fields.UseAuth && Authorizer) {
10461046
NActors::IEventHandle* handle = Authorizer(SelfId(), Event->Get()->Request.Get());
10471047
if (handle) {
10481048
Send(handle);
10491049
Become(&THttpMonAuthorizedActorRequest::StateWork);
10501050
return;
10511051
}
10521052
}
1053-
Forward(Event, TargetActorId);
1054-
PassAway();
1053+
Send(new IEventHandle(Fields.Handler, SelfId(), Event->ReleaseBase().Release(), IEventHandle::FlagTrackDelivery, Event->Cookie));
1054+
Become(&THttpMonAuthorizedActorRequest::StateWork);
1055+
}
1056+
1057+
void ReplyWith(NHttp::THttpOutgoingResponsePtr response) {
1058+
Send(Event->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingResponse(response));
10551059
}
10561060

10571061
bool CredentialsProvided() {
@@ -1136,7 +1140,7 @@ class THttpMonAuthorizedActorRequest : public TActorBootstrapped<THttpMonAuthori
11361140
response << "Content-Length: " << body.size() << "\r\n";
11371141
response << "\r\n";
11381142
response << body;
1139-
Send(Event->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingResponse(request->CreateResponseString(response)));
1143+
ReplyWith(request->CreateResponseString(response));
11401144
PassAway();
11411145
}
11421146

@@ -1158,14 +1162,25 @@ class THttpMonAuthorizedActorRequest : public TActorBootstrapped<THttpMonAuthori
11581162
if (result.UserToken) {
11591163
Event->Get()->UserToken = result.UserToken->GetSerializedToken();
11601164
}
1161-
Forward(Event, TargetActorId);
1165+
Send(new IEventHandle(Fields.Handler, SelfId(), Event->ReleaseBase().Release(), IEventHandle::FlagTrackDelivery, Event->Cookie));
1166+
11621167
PassAway();
11631168
}
11641169

1165-
void HandleUndelivered(TEvents::TEvUndelivered::TPtr&) {
1170+
void Cancelled() {
1171+
if (CancelSubscriber) {
1172+
Send(CancelSubscriber->Sender, new NHttp::TEvHttpProxy::TEvRequestCancelled(), 0, CancelSubscriber->Cookie);
1173+
}
1174+
PassAway();
1175+
}
1176+
1177+
void HandleUndelivered(TEvents::TEvUndelivered::TPtr& ev) {
1178+
if (ev->Get()->SourceType == NHttp::TEvHttpProxy::EvSubscribeForCancel) {
1179+
return Cancelled();
1180+
}
11661181
NHttp::THttpIncomingRequestPtr request = Event->Get()->Request;
1167-
Send(Event->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingResponse(
1168-
request->CreateResponseServiceUnavailable(TStringBuilder() << "Auth actor is not available")));
1182+
ReplyWith(request->CreateResponseServiceUnavailable(
1183+
TStringBuilder() << "Auth actor is not available"));
11691184
PassAway();
11701185
}
11711186

@@ -1174,17 +1189,43 @@ class THttpMonAuthorizedActorRequest : public TActorBootstrapped<THttpMonAuthori
11741189
if (result.Status != Ydb::StatusIds::SUCCESS) {
11751190
return ReplyErrorAndPassAway(result);
11761191
}
1177-
if (IsTokenAllowed(result.UserToken.Get(), AllowedSIDs)) {
1192+
if (IsTokenAllowed(result.UserToken.Get(), Fields.AllowedSIDs)) {
11781193
SendRequest(result);
11791194
} else {
11801195
return ReplyForbiddenAndPassAway("SID is not allowed");
11811196
}
11821197
}
11831198

1199+
void Handle(NHttp::TEvHttpProxy::TEvHttpOutgoingResponse::TPtr& ev) {
1200+
ReplyWith(ev->Get()->Response);
1201+
if (ev->Get()->Response->IsDone()) {
1202+
return PassAway();
1203+
}
1204+
}
1205+
1206+
void Handle(NHttp::TEvHttpProxy::TEvHttpOutgoingDataChunk::TPtr& ev) {
1207+
Send(Event->Sender, new NHttp::TEvHttpProxy::TEvHttpOutgoingDataChunk(ev->Get()->DataChunk), 0, Event->Cookie);
1208+
if (ev->Get()->DataChunk && ev->Get()->DataChunk->IsEndOfData()) {
1209+
PassAway();
1210+
}
1211+
}
1212+
1213+
void Handle(NHttp::TEvHttpProxy::TEvSubscribeForCancel::TPtr& ev) {
1214+
CancelSubscriber = std::move(ev);
1215+
}
1216+
1217+
void Handle(NHttp::TEvHttpProxy::TEvRequestCancelled::TPtr& /* ev */) {
1218+
Cancelled();
1219+
}
1220+
11841221
STATEFN(StateWork) {
11851222
switch (ev->GetTypeRewrite()) {
11861223
hFunc(TEvents::TEvUndelivered, HandleUndelivered);
11871224
hFunc(NKikimr::NGRpcService::TEvRequestAuthAndCheckResult, Handle);
1225+
hFunc(NHttp::TEvHttpProxy::TEvHttpOutgoingResponse, Handle);
1226+
hFunc(NHttp::TEvHttpProxy::TEvHttpOutgoingDataChunk, Handle);
1227+
hFunc(NHttp::TEvHttpProxy::TEvSubscribeForCancel, Handle);
1228+
hFunc(NHttp::TEvHttpProxy::TEvRequestCancelled, Handle)
11881229
}
11891230
}
11901231
};
@@ -1276,11 +1317,7 @@ class THttpMonIndexService : public TActor<THttpMonIndexService> {
12761317
while (!url.empty()) {
12771318
auto it = Handlers.find(TString(url));
12781319
if (it != Handlers.end()) {
1279-
if (it->second.UseAuth) {
1280-
Register(new THttpMonAuthorizedActorRequest(std::move(ev), it->second.Handler, Authorizer, it->second.AllowedSIDs));
1281-
} else {
1282-
Forward(ev, it->second.Handler);
1283-
}
1320+
Register(new THttpMonAuthorizedActorRequest(std::move(ev), it->second, Authorizer));
12841321
return;
12851322
} else {
12861323
if (url.EndsWith('/')) {

0 commit comments

Comments
 (0)