Skip to content

Commit

Permalink
Drop replication with unknown secret (ydb-platform#5248)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberROFL committed Jun 10, 2024
1 parent 36bfe84 commit 8464b3f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ydb/core/tx/replication/controller/replication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TReplication::TImpl {
}

void Progress(const TActorContext& ctx) {
if (!YdbProxy) {
if (!YdbProxy && !(State == EState::Removing && !Targets)) {
THolder<IActor> ydbProxy;
const auto& params = Config.GetSrcConnectionParams();

Expand All @@ -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;
}

Expand Down
32 changes: 32 additions & 0 deletions ydb/core/tx/schemeshard/ut_replication/ut_replication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8464b3f

Please sign in to comment.