From 8464b3faa41313d755a8b198c7dc4dca285113c5 Mon Sep 17 00:00:00 2001 From: Ilnaz Nizametdinov Date: Wed, 5 Jun 2024 22:12:08 +0300 Subject: [PATCH] Drop replication with unknown secret (#5248) --- .../tx/replication/controller/replication.cpp | 6 ++-- .../ut_replication/ut_replication.cpp | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ydb/core/tx/replication/controller/replication.cpp b/ydb/core/tx/replication/controller/replication.cpp index cc3f77336023..4d9edfdcb22f 100644 --- a/ydb/core/tx/replication/controller/replication.cpp +++ b/ydb/core/tx/replication/controller/replication.cpp @@ -99,7 +99,7 @@ class TReplication::TImpl { } void Progress(const TActorContext& ctx) { - if (!YdbProxy) { + if (!YdbProxy && !(State == EState::Removing && !Targets)) { THolder ydbProxy; const auto& params = Config.GetSrcConnectionParams(); @@ -117,9 +117,7 @@ class TReplication::TImpl { ydbProxy.Reset(CreateYdbProxy(params.GetEndpoint(), params.GetDatabase(), params.GetOAuthToken().GetToken())); break; default: - if (!(State == EState::Removing && !Targets)) { - ErrorState(TStringBuilder() << "Unexpected credentials: " << params.GetCredentialsCase()); - } + ErrorState(TStringBuilder() << "Unexpected credentials: " << params.GetCredentialsCase()); break; } diff --git a/ydb/core/tx/schemeshard/ut_replication/ut_replication.cpp b/ydb/core/tx/schemeshard/ut_replication/ut_replication.cpp index b7b131ed29a6..8817995f8881 100644 --- a/ydb/core/tx/schemeshard/ut_replication/ut_replication.cpp +++ b/ydb/core/tx/schemeshard/ut_replication/ut_replication.cpp @@ -400,4 +400,36 @@ Y_UNIT_TEST_SUITE(TReplicationTests) { TestDescribeResult(DescribePath(runtime, "/MyRoot/Replication"), {NLs::PathNotExist}); } + Y_UNIT_TEST(DropReplicationWithUnknownSecret) { + TTestBasicRuntime runtime; + TTestEnv env(runtime, TTestEnvOptions().InitYdbDriver(true)); + ui64 txId = 100; + + SetupLogging(runtime); + + TestCreateReplication(runtime, ++txId, "/MyRoot", R"( + Name: "Replication" + Config { + SrcConnectionParams { + StaticCredentials { + User: "user" + PasswordSecretName: "unknown_secret" + } + } + Specific { + Targets { + SrcPath: "/MyRoot1/Table" + DstPath: "/MyRoot2/Table" + } + } + } + )"); + env.TestWaitNotification(runtime, txId); + TestDescribeResult(DescribePath(runtime, "/MyRoot/Replication"), {NLs::PathExist}); + + TestDropReplication(runtime, ++txId, "/MyRoot", "Replication"); + env.TestWaitNotification(runtime, txId); + TestDescribeResult(DescribePath(runtime, "/MyRoot/Replication"), {NLs::PathNotExist}); + } + } // TReplicationTests