11#include " console_configs_manager.h"
22#include " console_configs_provider.h"
3+ #include " console_audit.h"
34
45#include < ydb/core/tablet_flat/tablet_flat_executed.h>
56#include < ydb/library/aclib/aclib.h>
@@ -16,6 +17,7 @@ class TConfigsManager::TTxReplaceYamlConfig : public TTransactionBase<TConfigsMa
1617 bool force)
1718 : TBase(self)
1819 , Config(ev->Get ()->Record.GetRequest().config())
20+ , Peer(ev->Get ()->Record.GetPeerName())
1921 , Sender(ev->Sender)
2022 , UserSID(NACLib::TUserToken(ev->Get ()->Record.GetUserToken()).GetUserSID())
2123 , Force(force)
@@ -146,6 +148,7 @@ class TConfigsManager::TTxReplaceYamlConfig : public TTransactionBase<TConfigsMa
146148 auto *issue = ev->Record .AddIssues ();
147149 issue->set_severity (NYql::TSeverityIds::S_ERROR);
148150 issue->set_message (ex.what ());
151+ ErrorReason = ex.what ();
149152 Response = MakeHolder<NActors::IEventHandle>(Sender, ctx.SelfID , ev.Release ());
150153 }
151154
@@ -159,6 +162,14 @@ class TConfigsManager::TTxReplaceYamlConfig : public TTransactionBase<TConfigsMa
159162 ctx.Send (Response.Release ());
160163
161164 if (!Error && Modify && !DryRun) {
165+ AuditLogReplaceConfigTransaction (
166+ /* peer = */ Peer,
167+ /* userSID = */ UserSID,
168+ /* oldConfig = */ Self->YamlConfig ,
169+ /* newConfig = */ Config,
170+ /* reason = */ {},
171+ /* success = */ true );
172+
162173 Self->YamlVersion = Version + 1 ;
163174 Self->YamlConfig = UpdatedConfig;
164175 Self->YamlDropped = false ;
@@ -167,20 +178,30 @@ class TConfigsManager::TTxReplaceYamlConfig : public TTransactionBase<TConfigsMa
167178
168179 auto resp = MakeHolder<TConfigsProvider::TEvPrivate::TEvUpdateYamlConfig>(Self->YamlConfig );
169180 ctx.Send (Self->ConfigsProvider , resp.Release ());
181+ } else if (Error && !DryRun) {
182+ AuditLogReplaceConfigTransaction (
183+ /* peer = */ Peer,
184+ /* userSID = */ UserSID,
185+ /* oldConfig = */ Self->YamlConfig ,
186+ /* newConfig = */ Config,
187+ /* reason = */ ErrorReason,
188+ /* success = */ false );
170189 }
171190
172191 Self->TxProcessor ->TxCompleted (this , ctx);
173192 }
174193
175194private:
176195 const TString Config;
196+ const TString Peer;
177197 const TActorId Sender;
178198 const TString UserSID;
179199 const bool Force = false ;
180200 const bool AllowUnknownFields = false ;
181201 const bool DryRun = false ;
182202 THolder<NActors::IEventHandle> Response;
183203 bool Error = false ;
204+ TString ErrorReason;
184205 bool Modify = false ;
185206 TSimpleSharedPtr<NYamlConfig::TBasicUnknownFieldsCollector> UnknownFieldsCollector = nullptr ;
186207 ui32 Version;
0 commit comments