Skip to content

Commit b120806

Browse files
committed
BUG#35416666 Incorrect SSL options when rebooting a cluster
When rebooting a cluster configured with SSL options (i.e.: memberAuthType) and switching the comm stack to "mysql", the seed instance isn't rebooted with the correct SSL options. This patch fixes this issue by making sure that the cluster (the primary and all remaining members) are correctly set with the SSL options specified during the Cluster setup. Change-Id: Ib66a18d109ff7f47e56877406c71c9dec2412868
1 parent f5ef1bd commit b120806

File tree

4 files changed

+51
-14
lines changed

4 files changed

+51
-14
lines changed

modules/adminapi/cluster/add_instance.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void Add_instance::do_run() {
664664
m_target_instance, m_options.cert_subject, m_gr_opts,
665665
!recovery_certificates);
666666

667-
// if recovery accounts need certificates, we much ensure that the
667+
// if recovery accounts need certificates, we must ensure that the
668668
// recovery accounts of all members also exist on the target instance
669669
if (recovery_certificates) {
670670
m_cluster_impl->create_replication_users_at_instance(

modules/adminapi/cluster/rejoin_instance.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ void Rejoin_instance::do_run() {
289289
m_target_instance, m_auth_cert_subject, m_gr_opts,
290290
!recovery_certificates, m_options.dry_run);
291291

292+
// if recovery accounts need certificates, we must ensure that the
293+
// recovery accounts of all members also exist on the target instance
294+
if (recovery_certificates) {
295+
m_cluster_impl->create_replication_users_at_instance(m_target_instance);
296+
}
297+
292298
// Set the allowlist to 'AUTOMATIC' to ensure no older values are used
293299
m_gr_opts.ip_allowlist = "AUTOMATIC";
294300

modules/adminapi/dba/reboot_cluster_from_complete_outage.cc

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ void Reboot_cluster_from_complete_outage::reboot_seed() {
771771
// - The recovery credentials have the required Grants
772772
//
773773
// For those reasons, we must simply re-create the recovery account
774+
bool requires_certificates{false};
774775
if (m_options.gr_options.communication_stack.value_or("") ==
775776
kCommunicationStackMySQL) {
776777
// If it's a Replica cluster, we must disable the binary logging and
@@ -849,6 +850,35 @@ void Reboot_cluster_from_complete_outage::reboot_seed() {
849850
options.auto_failover = false;
850851
options.mysql_comm_stack_supported = true;
851852

853+
auto auth_type = m_cluster->impl()->query_cluster_auth_type();
854+
switch (auth_type) {
855+
case Replication_auth_type::PASSWORD:
856+
case Replication_auth_type::CERT_ISSUER_PASSWORD:
857+
case Replication_auth_type::CERT_SUBJECT_PASSWORD:
858+
options.requires_password = true;
859+
break;
860+
default:
861+
options.requires_password = false;
862+
break;
863+
}
864+
865+
switch (auth_type) {
866+
case Replication_auth_type::CERT_SUBJECT:
867+
case Replication_auth_type::CERT_SUBJECT_PASSWORD:
868+
options.cert_subject =
869+
m_cluster->impl()->query_cluster_instance_auth_cert_subject(
870+
*m_target_instance);
871+
[[fallthrough]];
872+
case Replication_auth_type::CERT_ISSUER:
873+
case Replication_auth_type::CERT_ISSUER_PASSWORD:
874+
options.cert_issuer =
875+
m_cluster->impl()->query_cluster_auth_cert_issuer();
876+
requires_certificates = true;
877+
break;
878+
default:
879+
break;
880+
}
881+
852882
repl_account = mysqlshdk::gr::create_recovery_user(
853883
repl_account.user, *m_target_instance, hosts, options);
854884
}
@@ -934,25 +964,18 @@ void Reboot_cluster_from_complete_outage::reboot_seed() {
934964
}
935965
}
936966

937-
log_info("Starting cluster with '%s' using account %s",
967+
resolve_ssl_mode_option("memberSslMode", "Cluster", *m_target_instance,
968+
&m_options.gr_options.ssl_mode);
969+
970+
log_info("Starting cluster with '%s' (%s) using account %s",
938971
m_target_instance->descr().c_str(),
972+
to_string(m_options.gr_options.ssl_mode).c_str(),
939973
m_target_instance->get_connection_options().get_user().c_str());
940974

941975
// Determine the topology mode to use.
942976
auto multi_primary = m_cluster->impl()->get_cluster_topology_type() ==
943977
mysqlshdk::gr::Topology_mode::MULTI_PRIMARY;
944978

945-
bool requires_certificates{false};
946-
switch (m_cluster->impl()->query_cluster_auth_type()) {
947-
case mysqlsh::dba::Replication_auth_type::CERT_ISSUER:
948-
case mysqlsh::dba::Replication_auth_type::CERT_SUBJECT:
949-
case mysqlsh::dba::Replication_auth_type::CERT_ISSUER_PASSWORD:
950-
case mysqlsh::dba::Replication_auth_type::CERT_SUBJECT_PASSWORD:
951-
requires_certificates = true;
952-
default:
953-
break;
954-
}
955-
956979
// Start the cluster to bootstrap Group Replication.
957980
mysqlsh::dba::start_cluster(*m_target_instance, m_options.gr_options,
958981
requires_certificates, multi_primary,

unittest/scripts/auto/js_adminapi/scripts/ssl_auth_more.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ function test_add_instance(commStack, recoverMethod) {
4242

4343
testutil.waitMemberState(__mysql_sandbox_port2, "ONLINE");
4444

45+
if (commStack.toLowerCase() == "xcom" && (__version_num >= 80027)) {
46+
47+
testutil.stopGroup([__mysql_sandbox_port1, __mysql_sandbox_port2]);
48+
EXPECT_NO_THROWS(function(){ cluster = dba.rebootClusterFromCompleteOutage("cluster", {switchCommunicationStack: "mysql"}); });
49+
50+
EXPECT_NE("", session.runSql("SELECT ssl_type FROM mysql.user WHERE (user LIKE 'mysql_innodb_cluster_%');").fetchOne()[0]);
51+
EXPECT_NE("", session.runSql("SELECT authentication_string FROM mysql.user WHERE (user LIKE 'mysql_innodb_cluster_%');").fetchOne()[0]);
52+
}
53+
4554
cluster.dissolve();
4655
}
4756

@@ -73,7 +82,6 @@ reset_instance(session);
7382
//@<> create cluster comm stack xcom with primary offline
7483
shell.connect(__sandbox_uri1);
7584

76-
7785
var cluster;
7886
if (__version_num < 80027) {
7987
EXPECT_NO_THROWS(function() { cluster = dba.createCluster("cluster", { memberAuthType: "CERT_SUBJECT_PASSWORD", certIssuer: "/CN=Test_CA", certSubject: `/CN=${hostname}/L=machine1` }); });

0 commit comments

Comments
 (0)