|
1 |
| -#include "distconf_audit.h" |
2 | 1 | #include "distconf_invoke.h"
|
3 | 2 |
|
| 3 | +#include <ydb/core/audit/audit_log.h> |
| 4 | +#include <ydb/core/util/address_classifier.h> |
| 5 | + |
4 | 6 | namespace NKikimr::NStorage {
|
5 | 7 |
|
6 | 8 | using TInvokeRequestHandlerActor = TDistributedConfigKeeper::TInvokeRequestHandlerActor;
|
@@ -191,20 +193,43 @@ namespace NKikimr::NStorage {
|
191 | 193 | return;
|
192 | 194 | }
|
193 | 195 |
|
194 |
| - const auto& replaceConfig = Event->Get()->Record.GetReplaceStorageConfig(); |
195 |
| - TStringBuilder oldConfig; |
196 |
| - oldConfig << Self->MainConfigYaml << (Self->StorageConfigYaml ? *Self->StorageConfigYaml : ""); |
197 |
| - TStringBuilder newConfig; |
198 |
| - newConfig << *NewYaml << (NewStorageYaml ? *NewStorageYaml : ""); |
199 |
| - NACLib::TUserToken userToken = NACLib::TUserToken{replaceConfig.GetUserToken()}; |
200 |
| - AuditLogReplaceConfig( |
201 |
| - /* peer = */ replaceConfig.GetPeerName(), |
202 |
| - /* userSID = */ userToken.GetUserSID(), |
203 |
| - /* sanitizedToken = */ userToken.GetSanitizedToken(), |
204 |
| - /* oldConfig = */ oldConfig, |
205 |
| - /* newConfig = */ newConfig, |
206 |
| - /* reason = */ {}, |
207 |
| - /* success = */ true); |
| 196 | + if (const auto& record = Event->Get()->Record; record.HasReplaceStorageConfig()) { |
| 197 | + AUDIT_LOG( |
| 198 | + const auto& replaceConfig = record.GetReplaceStorageConfig(); |
| 199 | + |
| 200 | + const TString oldConfig = TStringBuilder() |
| 201 | + << Self->MainConfigYaml |
| 202 | + << Self->StorageConfigYaml.value_or(""); |
| 203 | + |
| 204 | + TStringBuilder newConfig; |
| 205 | + if (replaceConfig.HasYAML()) { |
| 206 | + newConfig << replaceConfig.GetYAML(); |
| 207 | + } else { |
| 208 | + newConfig << Self->MainConfigYaml; |
| 209 | + } |
| 210 | + if (replaceConfig.HasStorageYAML()) { |
| 211 | + newConfig << replaceConfig.GetStorageYAML(); |
| 212 | + } else if (replaceConfig.HasSwitchDedicatedStorageSection() && !replaceConfig.GetSwitchDedicatedStorageSection()) { |
| 213 | + // dedicated storage YAML is switched off by this operation -- no storage config will be set |
| 214 | + } else if (Self->StorageConfigYaml) { |
| 215 | + newConfig << *Self->StorageConfigYaml; |
| 216 | + } |
| 217 | + |
| 218 | + NACLib::TUserToken userToken(replaceConfig.GetUserToken()); |
| 219 | + |
| 220 | + auto wrapEmpty = [](const TString& value) { return value ? value : TString("{none}"); }; |
| 221 | + |
| 222 | + AUDIT_PART("component", TString("distconf")) |
| 223 | + AUDIT_PART("remote_address", wrapEmpty(NKikimr::NAddressClassifier::ExtractAddress(replaceConfig.GetPeerName()))) |
| 224 | + AUDIT_PART("subject", wrapEmpty(userToken.GetUserSID())) |
| 225 | + AUDIT_PART("sanitized_token", wrapEmpty(userToken.GetSanitizedToken())) |
| 226 | + AUDIT_PART("status", TString("SUCCESS")) |
| 227 | + AUDIT_PART("reason", TString(), false) |
| 228 | + AUDIT_PART("operation", TString("REPLACE CONFIG")) |
| 229 | + AUDIT_PART("old_config", oldConfig) |
| 230 | + AUDIT_PART("new_config", newConfig) |
| 231 | + ); |
| 232 | + } |
208 | 233 |
|
209 | 234 | Self->CurrentProposedStorageConfig.emplace(std::move(*config));
|
210 | 235 |
|
|
0 commit comments